migrate nvim config to 0.12.0: vim.pack, ui2, snacks -> mini, just general spring cleaning

This commit is contained in:
Martin Larsson 2026-04-05 20:05:00 +02:00
parent d1178fbe59
commit 14b1a9b057
70 changed files with 1081 additions and 1483 deletions

View file

@ -66,8 +66,12 @@ keybind = ctrl+shift+h=csi:11~
keybind = ctrl+shift+j=csi:12~
keybind = ctrl+shift+k=csi:13~
keybind = ctrl+shift+l=csi:14~
keybind = ctrl+1=csi:15~
keybind = ctrl+2=csi:19~
keybind = ctrl+3=csi:21~
keybind = ctrl+4=csi:23~
keybind = ctrl+5=csi:24~
keybind = ctrl+1=csi:25~
keybind = ctrl+2=csi:26~
keybind = ctrl+3=csi:28~
keybind = ctrl+4=csi:29~
keybind = ctrl+5=csi:31~
keybind = ctrl+6=csi:32~
keybind = ctrl+7=csi:33~
keybind = ctrl+8=csi:34~

View file

@ -1,6 +1,13 @@
{
"diagnostics.globals": [
"vim"
"Snacks"
"vim",
"MiniExtra",
"MiniIcons",
"MiniNotify",
"MiniPick",
"MiniSessions",
"MiniSurround",
"MiniStart",
"MiniDiff"
]
}

View file

@ -1,38 +1,10 @@
vim.api.nvim_create_augroup("ColorsyncEvents", { clear = true })
vim.loader.enable() -- cache for faster startups
require('vim._core.ui2').enable({})
-- Load keymaps before loading any plugins
require("colorsync_integration")
require("keymaps")
-- Change and personalize native vim settings
vim.opt = require("vim_opt")
-- Initialize Lazy package manager
require("lazy_init")
-- Initialize the sticky terminal window at the bottom
require("vim_opt")
require("terminal")
-- Initialize the custom window management functionality
require("window_management").setup()
-- Initializes custom commands and keybindings for handling code formatting
require("format_handler").setup()
-- Initialize the custom close handler for handling window closing events
require("close_handler").setup()
-- Set configs for servers and enable them in the Neovim LSP Client
require("lspsetup")
-- Set configs for nvim-dap so we can debug
require("dapsetup")
-- Change built in settings related to diagnostics
require("diagnostics")
--[[
-- Annoyances in Neovim environment:
-- 1. codelldb doesn't terminate C++ program after debugging. : Don't know how to fix, have asked for help.
-- 2. Sometimes very seldomly the cursor stops rendering, the only fix I found is to restart Neovim.
-- 3. Remove usage of dap-go, dap-python, and rustaceanvim. These are really just providing DAP/LSP configs which I prefer to have without plugin bloat. However, they require more to setup than your average conf.
--]]

View file

@ -1,43 +0,0 @@
{
"LuaSnip": { "branch": "master", "commit": "5a1e39223db9a0498024a77b8441169d260c8c25" },
"blink.cmp": { "branch": "main", "commit": "451168851e8e2466bc97ee3e026c3dcb9141ce07" },
"codediff.nvim": { "branch": "main", "commit": "93cd80c56f71af4671388c568a37d4c84c3ddefa" },
"colorful-menu.nvim": { "branch": "master", "commit": "b51a659459df8d078201aefc995db8175ed55e84" },
"demicolon.nvim": { "branch": "main", "commit": "a9ca137474b3a02e1d6ac48bfdb1985172e2ec9a" },
"fff.nvim": { "branch": "main", "commit": "dd56a3a8a8a5a85522badaf6485f28c8f7a7c840" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" },
"goto-preview": { "branch": "main", "commit": "d2d6923c9b9e0e43f0b9b566f261a8b1ae016540" },
"incline.nvim": { "branch": "main", "commit": "8b54c59bcb23366645ae10edca6edfb9d3a0853e" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" },
"live-rename.nvim": { "branch": "main", "commit": "3a3cddf23b89a17992f9ca67afc5858077769462" },
"logger.nvim": { "branch": "main", "commit": "63dd10c9b9a159fd6cfe08435d9606384ff103c5" },
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
"lush.nvim": { "branch": "main", "commit": "9c60ec2279d62487d942ce095e49006af28eed6e" },
"markview.nvim": { "branch": "main", "commit": "1861f959599ae03cfd59f56222a542035b0cd947" },
"neogit": { "branch": "master", "commit": "d3890fc3cdf0859845a86b2be306bba01458df1a" },
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" },
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" },
"nvim-dap-repl-highlights": { "branch": "master", "commit": "f31deba47fe3ee6ff8d2f13d9dbd06b2d1ae06b5" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
"nvim-lightbulb": { "branch": "master", "commit": "aa3a8b0f4305b25cfe368f6c9be9923a7c9d0805" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-norrsken": { "branch": "master", "commit": "692c2a0f81905dc6fd3011361740d610dfa8052d" },
"nvim-surround": { "branch": "main", "commit": "61319d4bd1c5e336e197defa15bd104c51f0fb29" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-context": { "branch": "master", "commit": "adf4b6b0420b7be6c717ef0ac7993183d6c201b1" },
"nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" },
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
"persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" },
"persistent-breakpoints.nvim": { "branch": "main", "commit": "d1656221836207787b8a7969cc2dc72668c4742a" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"rustaceanvim": { "branch": "master", "commit": "e9c5aaba16fead831379d5f44617547a90b913c7" },
"snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" },
"tiny-glimmer.nvim": { "branch": "main", "commit": "932e6c2cc4a43ce578f007db1f8f61ad6798f938" },
"tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "ba133b3e932416e4b9507095731a6d7276878fe8" },
"visual-whitespace.nvim": { "branch": "main", "commit": "49ff2b1c572ed7033a584381fa23aad2bf3bb258" }
}

View file

@ -13,7 +13,7 @@ local function set_python_path(path)
client.config.settings = vim.tbl_deep_extend("force", client.config.settings,
{ python = { pythonPath = path } })
end
client.notify("workspace/didChangeConfiguration", { settings = nil })
client:notify("workspace/didChangeConfiguration", { settings = nil })
end
end

View file

@ -5,7 +5,7 @@ local function switch_source_header()
local bufnr = utils.validate_bufnr(0)
local clangd_client = vim.lsp.get_clients({ bufnr = bufnr, name = "clangd" })[1]
if clangd_client then
clangd_client.request(
clangd_client:request(
"textDocument/switchSourceHeader",
{ uri = vim.uri_from_bufnr(bufnr) },
function(err, result)
@ -13,13 +13,13 @@ local function switch_source_header()
error(tostring(err))
end
if not result then
print "Corresponding file cannot be determined"
vim.notify("Corresponding file cannot be determined", vim.log.levels.WARN)
return
end
vim.api.nvim_command("drop " .. vim.uri_to_fname(result))
end, bufnr)
else
print "method textDocument/switchSourceHeader is not supported by any servers active on the current buffer"
vim.notify("textDocument/switchSourceHeader is not supported by any servers active on the current buffer", vim.log.levels.WARN)
end
end
@ -44,9 +44,9 @@ return {
"compile_flags.txt",
"configure.ac",
},
on_attach = function()
on_attach = function(_, bufnr)
utils.set_keymap_list({
{ "<leader>h", switch_source_header, },
{ "<leader>h", switch_source_header, { buf = bufnr } },
})
end,
}

View file

@ -51,7 +51,10 @@ return {
local fname = vim.api.nvim_buf_get_name(bufnr)
root_file_patterns = insert_package_json(root_file_patterns, "eslintConfig", fname)
on_dir(vim.fs.dirname(vim.fs.find(root_file_patterns, { path = fname, upward = true })[1]))
local root = vim.fs.find(root_file_patterns, { path = fname, upward = true })[1]
if root then
on_dir(vim.fs.dirname(root))
end
end,
workspace_required = true,
settings = {

View file

@ -30,16 +30,12 @@ return {
version = "LuaJIT"
},
diagnostics = {
globals = { "vim", "Snacks" },
globals = { "vim" },
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
}
}

View file

@ -1,22 +0,0 @@
-- Helper function for the 'MigrateToSvelte5' LSP command.
-- This function will be called by the user command created in on_attach.
local function migrate_to_svelte_5_command(client)
client:exec_param({
command = "migrate_to_svelte_5",
arguments = { vim.uri_from_bufnr(vim.api.nvim_get_current_buf()) },
})
end
return {
cmd = { "svelteserver", "--stdio" },
filetypes = { "svelte" },
root_markers = { "package.json", ".git/" },
on_attach = function(client, bufnr)
local fn = function() migrate_to_svelte_5_command(client) end
vim.api.nvim_buf_create_user_command(bufnr, "SvelteMigrateToSvelte5", fn, {
desc = "Svelte: Migrate Component to Svelte 5 Syntax (via LSP).",
})
end,
}

View file

@ -63,9 +63,12 @@ return {
-- ts_ls provides `source.*` code actions that apply to the whole file. These only appear in
-- `vim.lsp.buf.code_action()` if specified in `context.only`.
vim.api.nvim_buf_create_user_command(bufnr, "LspTypescriptSourceAction", function()
local kinds = vim.tbl_get(client.server_capabilities, "codeActionProvider", "codeActionKinds")
if not kinds then return end
local source_actions = vim.tbl_filter(function(action)
return vim.startswith(action, "source.")
end, client.server_capabilities.codeActionProvider.codeActionKinds)
end, kinds)
vim.lsp.buf.code_action({
context = {

View file

@ -1,41 +0,0 @@
local utils = require("utils")
local M = {}
local callbacks = {}
local handle_count = 1
function M.setup()
utils.set_keymap_list({
{
"<Leader>q",
function()
for _, cb in ipairs(callbacks) do
if cb ~= nil then
cb()
end
end
end,
},
})
end
function M.register_on_close_cb(cb)
assert(type(cb) == "function", "Callback must be a function")
local handle = handle_count
handle_count = handle_count + 1
table.insert(callbacks, cb)
return handle
end
function M.remove_on_close_cb(cb_handle)
assert(type(cb_handle) == "number", "Callback handle must be a number")
assert(cb_handle > 0 and cb_handle <= #callbacks, "Invalid callback handle")
assert(callbacks[cb_handle] ~= nil, "Callback does not exist")
callbacks[cb_handle] = nil
end
return M

View file

@ -0,0 +1,22 @@
local filepath = vim.fs.joinpath(os.getenv("HOME"), ".local/state/colorsync/current")
vim.api.nvim_create_augroup("ColorsyncEvents", { clear = true })
local handle = vim.uv.new_fs_event()
if not handle then
vim.notify("colorsync: failed to create fs event handle", vim.log.levels.ERROR)
return
end
handle:start(filepath, {}, function(err)
if err then
vim.schedule(function()
vim.notify("colorsync: error watching " .. filepath .. "\n" .. err, vim.log.levels.ERROR)
end)
return
end
vim.schedule(function()
vim.api.nvim_exec_autocmds("User", { pattern = "ColorsyncThemeChanged", modeline = false })
end)
end)

View file

@ -1,47 +0,0 @@
local utils = require("utils")
local dap = require("dap")
local dir_path = "dap"
utils.foreach(utils.get_file_names_in_dir(dir_path, "*.lua", true), function(adapter)
dap.adapters[adapter] = require(dir_path .. "/" .. adapter)
end)
vim.api.nvim_create_user_command("LaunchTemplate", function()
local template = {
'{',
' "version": "0.2.0",',
' "configurations": [',
' {',
' "type": "codelldb",',
' "request": "launch",',
' "name": "Launch",',
' "program": "${workspaceFolder}/build/binary",',
' "cwd": "${workspaceFolder}",',
' "args": [],',
' "stopOnEntry": false,',
' "environment": []',
' }',
' ]',
'}',
}
local bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, template)
end, {})
-- Do not define default fallbacks until I have a better way of handling a default selected configuration.
-- I never want to be prompted for a configuration, we should have ae serialized active config which is always run unless changed.
-- -- Define configurations
-- dap.configurations.cpp = {
-- {
-- name = "Launch File",
-- type = "codelldb",
-- request = "launch",
-- program = function()
-- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
-- end,
-- cwd = "${workspaceFolder}",
-- stopOnEntry = false,
-- args = {},
-- },
-- }

View file

@ -1,14 +1,6 @@
local sev = vim.diagnostic.severity
vim.diagnostic.config({
-- underline = true,
-- This enables the diagnostics at end of line
-- virtual_text = {
-- prefix = "●",
-- },
-- Disable this whilst using tiny inline diagnostics
virtual_text = false,
-- This enables the separate buffer diagnostics
-- virtual_lines = true,
update_in_insert = true,
signs = {
text = {

View file

@ -1,30 +0,0 @@
local M = {}
M.format_on_save = true
function M.format(force)
local do_force = force or false
if M.format_on_save or do_force then
vim.lsp.buf.format()
end
end
function M.format_enable()
M.format_on_save = true
end
function M.format_disable()
M.format_on_save = false
end
function M.setup()
local user_commands = {
{ "FormatEnable", "lua require('format_handler').format_enable()" },
{ "FormatDisable", "lua require('format_handler').format_disable()" },
{ "Format", "lua require('format_handler').format(true)" },
}
for _, cmd in ipairs(user_commands) do
vim.api.nvim_command("command! " .. cmd[1] .. " " .. cmd[2])
end
end
return M

View file

@ -7,7 +7,7 @@ g.maplocalleader = " "
local move_up = { "v:count || mode(1)[0:1] == \"no\" ? \"k\" : \"gk\"", { expr = true } }
local move_down = { "v:count || mode(1)[0:1] == \"no\" ? \"j\" : \"gj\"", { expr = true } }
utils.foreach({
for _, mode_mapping in ipairs({
{
"n",
{
@ -17,6 +17,7 @@ utils.foreach({
{ "grr", "<Nop>", },
{ "gri", "<Nop>", },
{ "gO", "<Nop>", },
{ "grt", "<Nop>", },
-- Navigation
{ "<C-Left>", "<C-w>h", },
{ "<C-Down>", "<C-w>j", },
@ -48,9 +49,6 @@ utils.foreach({
-- Maps to remove
{ "<C-z>", "<Nop>", },
-- Marks are less frequently used than leaping, also, less relevant with arrow and fzf navigation.
-- Prioritize regular m for leaping, and <leader>m for setting marks.
-- { "<leader>m", "m", },
{ "[d", function()
vim.diagnostic.jump({ count = -1, float = false })
end },
@ -67,15 +65,19 @@ utils.foreach({
end
end },
{ "<C-t>", ":$tabnew %<CR>", { silent = true }, },
-- These are mapped to C-1 through C-5 in ghostty, sending escape codes for F keys
{ "<F5>", ":1tabn<CR>", { silent = true }, },
{ "<F8>", ":2tabn<CR>", { silent = true }, },
{ "<F10>", ":3tabn<CR>", { silent = true }, },
{ "<F11>", ":4tabn<CR>", { silent = true }, },
{ "<F12>", ":5tabn<CR>", { silent = true }, },
{ "<F15>", ":1tabn<CR>", { silent = true }, },
{ "<F16>", ":2tabn<CR>", { silent = true }, },
{ "<F17>", ":3tabn<CR>", { silent = true }, },
{ "<F18>", ":4tabn<CR>", { silent = true }, },
{ "<F19>", ":5tabn<CR>", { silent = true }, },
{ "<F20>", ":6tabn<CR>", { silent = true }, },
{ "<F21>", ":7tabn<CR>", { silent = true }, },
{ "<F22>", ":8tabn<CR>", { silent = true }, },
{ "z/", '/\\%><C-r>=line("w0")-1<CR>l\\%<<C-r>=line("w$")+1<CR>l', { silent = false, desc = "Search in viewport" }, },
{ "z?", '?\\%><C-r>=line("w0")-1<CR>l\\%<<C-r>=line("w$")+1<CR>l', { silent = false, desc = "Search in viewport" }, }
{ "z?", '?\\%><C-r>=line("w0")-1<CR>l\\%<<C-r>=line("w$")+1<CR>l', { silent = false, desc = "Search in viewport" }, },
{ "<leader>u", ":Undotree<CR>", { silent = true } },
}
},
{
@ -88,9 +90,6 @@ utils.foreach({
{ "<tab>", ">gv", },
{ "<S-tab>", "<gv", },
-- Marks are less frequently used than leaping, also, less relevant with arrow and fzf navigation.
-- Prioritize regular m for leaping, and <leader>m for setting marks.
{ "<leader>m", "m", },
{ "/", "<C-\\><C-n>`</\\%V", },
{ "?", "<C-\\><C-n>`>?\\%V", },
},
@ -111,8 +110,6 @@ utils.foreach({
{ "<C-q>", "<C-\\><C-N>", },
}
},
}, function(mode_mapping)
local mode = mode_mapping[1]
local mappings = mode_mapping[2]
utils.set_keymap_list(mappings, mode)
end)
}) do
utils.set_keymap_list(mode_mapping[2], mode_mapping[1])
end

View file

@ -1,23 +0,0 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Initialize plugins, add a plugin by creating a new file in the plugins dir
require("lazy").setup("plugs", {
git = {
timeout = 300
},
dev = {
path = "~/dev/git/",
fallback = true,
},
})

View file

@ -1,43 +0,0 @@
local inlay_hints_handler = require("inlay_hints_handler")
local format_handler = require("format_handler")
local utils = require("utils")
local lsp = vim.lsp.buf
local api = vim.api
local M = {}
function M.configure_generic_client(client, bufnr)
inlay_hints_handler.add_buffer(bufnr)
if client.server_capabilities.documentFormattingProvider then
api.nvim_buf_create_user_command(bufnr, "Format", lsp.format, { nargs = 0 })
api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
format_handler.format()
end,
})
end
-- Built-in LSP completion.
-- Could switch to this if they just appeared automatically when typing, and didn't
-- only rely on showing when the servers completionCharacters are typed.
-- if client:supports_method("textDocument/completion") then
-- vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })
-- end
for mode, keys in pairs({
n = {
{ "K", function() lsp.hover() end, { buffer = bufnr } },
{ "<leader>a", function() lsp.code_action() end, { buffer = bufnr } },
},
i = {
{ "<C-s>", function() lsp.signature_help() end, { buffer = bufnr } },
},
}) do
utils.set_keymap_list(keys, mode)
end
end
return M

View file

@ -1,14 +1,81 @@
local utils = require("utils")
local lsplib = require("lsplib")
local inlay_hints_handler = require("inlay_hints_handler")
local format_on_save = true
vim.api.nvim_create_user_command("FormatEnable", function() format_on_save = true end, {})
vim.api.nvim_create_user_command("FormatDisable", function() format_on_save = false end, {})
vim.api.nvim_create_user_command("Format", function() vim.lsp.buf.format() end, {})
vim.lsp.config("*", {
root_markers = { ".git" },
})
local servers = {}
utils.foreach(utils.get_file_names_in_dir("../lsp", "*.lua", true), function(server_name)
table.insert(servers, server_name)
end)
local lsp_dir = vim.fs.joinpath(vim.fn.stdpath("config"), "lsp")
for name, type in vim.fs.dir(lsp_dir) do
if type == "file" and name:match("%.lua$") then
table.insert(servers, (name:gsub("%.lua$", "")))
end
end
local lsp_pick_ns = vim.api.nvim_create_namespace("lsp_pick")
local function lsp_pick(scope)
vim.lsp.buf[scope]({
on_list = function(options)
if #options.items == 1 then
local item = options.items[1]
vim.cmd("normal! m'")
vim.cmd.drop(item.filename)
if item.lnum <= vim.api.nvim_buf_line_count(0) then
vim.api.nvim_win_set_cursor(0, { item.lnum, (item.col or 1) - 1 })
end
return
end
local cwd = (vim.uv.cwd() or "") .. "/"
local home = (vim.env.HOME or "") .. "/"
for _, item in ipairs(options.items) do
local icon, icon_hl = MiniIcons.get("file", item.filename)
local rel = item.filename
if rel:sub(1, #cwd) == cwd then
rel = rel:sub(#cwd + 1)
elseif rel:sub(1, #home) == home then
rel = "~/" .. rel:sub(#home + 1)
end
local prefix = string.format("%s:%d:%d:", rel, item.lnum, item.col or 0)
item.path = item.filename
item.icon_hl = icon_hl
item.icon_end = #icon
item.prefix_end = #icon + 1 + #prefix
item.text = string.format("%s %s %s", icon, prefix, vim.trim(item.text or ""))
end
MiniPick.start({
source = {
name = string.format("LSP (%s)", scope),
items = options.items,
show = function(buf_id, items_to_show, query)
MiniPick.default_show(buf_id, items_to_show, query)
vim.api.nvim_buf_clear_namespace(buf_id, lsp_pick_ns, 0, -1)
for i, item in ipairs(items_to_show) do
vim.api.nvim_buf_set_extmark(buf_id, lsp_pick_ns, i - 1, 0, {
end_col = item.icon_end,
hl_group = item.icon_hl,
priority = 200,
})
vim.api.nvim_buf_set_extmark(buf_id, lsp_pick_ns, i - 1, item.icon_end + 1, {
end_col = item.prefix_end,
hl_group = "Comment",
priority = 200,
})
end
end,
preview = MiniPick.default_preview,
choose = MiniPick.default_choose,
},
})
end,
})
end
vim.lsp.enable(servers)
vim.api.nvim_create_autocmd("LspAttach", {
@ -17,6 +84,33 @@ vim.api.nvim_create_autocmd("LspAttach", {
local bufnr = args.buf
assert(client, "LspAttach: client is nil")
lsplib.configure_generic_client(client, bufnr)
end
inlay_hints_handler.add_buffer(bufnr)
if client:supports_method("textDocument/formatting") then
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 })
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
if format_on_save then vim.lsp.buf.format() end
end,
})
end
for mode, keys in pairs({
n = {
{ "K", function() vim.lsp.buf.hover() end, { buf = bufnr } },
{ "<leader>a", function() vim.lsp.buf.code_action() end, { buf = bufnr } },
{ "gd", function() lsp_pick("definition") end, { buf = bufnr } },
{ "gD", function() lsp_pick("declaration") end, { buf = bufnr } },
{ "gr", function() lsp_pick("references") end, { buf = bufnr, nowait = true } },
{ "gi", function() lsp_pick("implementation") end, { buf = bufnr } },
{ "gt", function() lsp_pick("type_definition") end, { buf = bufnr } },
},
i = {
{ "<C-s>", function() vim.lsp.buf.signature_help() end, { buf = bufnr } },
},
}) do
utils.set_keymap_list(keys, mode)
end
end,
})

View file

@ -1,76 +0,0 @@
return {
"saghen/blink.cmp",
dependencies = {
{
"L3MON4D3/LuaSnip",
version = "v2.*",
dependencies = { "rafamadriz/friendly-snippets", },
config = function()
local ls = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
ls.filetype_extend("typescriptreact", { "html" })
ls.filetype_extend("javascriptreact", { "html" })
ls.config.set_config({
enable_autosnippets = false,
store_selection_keys = false,
})
end
},
},
version = "1.*",
opts = {
keymap = { preset = "super-tab" },
appearance = {
nerd_font_variant = "mono"
},
-- (Default) Only show the documentation popup when manually triggered
completion = {
documentation = {
auto_show = false,
},
menu = {
draw = {
-- We don't need label_description now because label and label_description are already
-- combined together in label by colorful-menu.nvim.
columns = { { "kind_icon" }, { "label", gap = 1 } },
components = {
label = {
text = function(ctx)
return require("colorful-menu").blink_components_text(ctx)
end,
highlight = function(ctx)
return require("colorful-menu").blink_components_highlight(ctx)
end,
},
},
},
},
},
snippets = {
preset = "luasnip",
-- Disable snippet navigation while keeping expansion
active = function() return false end,
},
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = { "lsp", "path", "snippets", "buffer", },
per_filetype = {
codecompanion = { "codecompanion", },
},
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" }
},
opts_extend = { "sources.default" },
}

View file

@ -1,5 +0,0 @@
return {
"esmuellert/codediff.nvim",
dependencies = { "MunifTanjim/nui.nvim" },
cmd = "CodeDiff",
}

View file

@ -1,4 +0,0 @@
return {
"xzbdmw/colorful-menu.nvim",
opts = {},
}

View file

@ -1,12 +0,0 @@
return {
"mawkler/demicolon.nvim",
dependenies = {
"nvim-treesitter/nvim-treesitter",
"nvim-treesitter/nvim-treesitter-textobjects",
},
opts = {
keymaps = {
repeat_motions = "stateful",
},
},
}

View file

@ -1,5 +0,0 @@
return {
"nvim-tree/nvim-web-devicons",
event = "VeryLazy",
lazy = true,
}

View file

@ -1,12 +0,0 @@
return {
"dmtrKovalenko/fff.nvim",
build = "nix run .#release",
lazy = false,
keys = {
{
"<leader>f",
function() require("fff").find_files() end,
desc = "FFFind files",
}
}
}

View file

@ -1,29 +0,0 @@
local close_handler = require("close_handler")
local close_cb_handle = 0
return {
"rmagatti/goto-preview",
dependencies = { "rmagatti/logger.nvim" },
event = "BufEnter",
config = true, -- necessary as per https://github.com/rmagatti/goto-preview/issues/88
opts = {
post_open_hook = function(_, _)
close_cb_handle = close_handler.register_on_close_cb(function()
require("goto-preview").close_all_win()
end)
end,
post_close_hook = function(_, _)
close_handler.remove_on_close_cb(close_cb_handle)
end,
border = { "", "", "", "", "", "", "", "" },
focus_on_open = true,
stack_floating_preview_windows = false,
preview_window_title = { enable = true, position = "left" },
vim_ui_input = false,
},
keys = {
{ "gp", function() require("goto-preview").goto_preview_definition() end, },
{ "gy", function() require("goto-preview").goto_preview_type_definition() end, },
},
}

View file

@ -1,115 +0,0 @@
local utils = require("utils")
return {
"b0o/incline.nvim",
dependencies = {
{
"lewis6991/gitsigns.nvim",
opts = {},
keys = {
{ "[g", function() require("gitsigns").nav_hunk("prev") end, },
{ "]g", function() require("gitsigns").nav_hunk("next") end, },
}
}
},
config = function()
local function setup_incline()
require("incline").setup({
window = {
padding = 0,
},
hide = {
cursorline = true,
},
render = function(props)
local fullpath = vim.api.nvim_buf_get_name(props.buf)
local filename = vim.fn.fnamemodify(fullpath, ":t")
if filename == "" then
filename = "[No Name]"
end
local function get_ft_icon()
local ft_icon, ft_color = require("nvim-web-devicons").get_icon_color(filename)
return { (ft_icon or "") .. " ", guifg = ft_color, guibg = "none" }
end
local function get_file_path()
local path_display = ""
if fullpath == "" then
path_display = filename
else
local parts = {}
for part in string.gmatch(vim.fn.fnamemodify(fullpath, ":.:h"), "[^/]+") do
table.insert(parts, part)
end
local ellipsis = ""
local max_path_parts = 2
if #parts > max_path_parts then
local start_index = #parts - max_path_parts + 1
path_display = ellipsis .. "/" .. table.concat(parts, "/", start_index)
elseif #parts > 0 then
path_display = table.concat(parts, "/")
end
if path_display ~= "" then
path_display = path_display .. "/" .. filename
else
path_display = filename
end
end
return { path_display .. "", gui = vim.bo[props.buf].modified and "bold,italic" or "bold" }
end
local function get_git_diff()
local icons = { removed = "", changed = "", added = "" }
local signs = vim.b[props.buf].gitsigns_status_dict
local labels = {}
if signs == nil then
return labels
end
for name, icon in pairs(icons) do
if tonumber(signs[name]) and signs[name] > 0 then
table.insert(labels, { icon .. " " .. signs[name] .. " ", group = "Diff" .. name })
end
end
if #labels > 0 then
table.insert(labels, { "" })
end
return labels
end
local function get_diagnostic_label()
local icons = { error = "", warn = "", info = "", hint = "" }
local label = {}
for severity, icon in pairs(icons) do
local n = #vim.diagnostic.get(props.buf,
{ severity = vim.diagnostic.severity[string.upper(severity)] })
if n > 0 then
table.insert(label, { icon .. " " .. n .. " ", group = "DiagnosticSign" .. severity })
end
end
if #label > 0 then
table.insert(label, { "" })
end
return label
end
return {
{ " " },
{ get_diagnostic_label() },
{ get_git_diff() },
{ get_ft_icon() },
{ get_file_path() },
{ " " }
}
end,
})
end
utils.create_user_event_cb("ColorsyncThemeChanged", setup_incline, "ColorsyncEvents")
setup_incline()
end
}

View file

@ -1,28 +0,0 @@
return {
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
"saghen/blink.cmp",
opts = {
sources = {
-- add lazydev to your completion providers
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
},
},
},
},
}

View file

@ -1,44 +0,0 @@
return {
"saecki/live-rename.nvim",
opts = {
-- Send a `textDocument/prepareRename` request to the server to
-- determine the word to be renamed, can be slow on some servers.
-- Otherwise fallback to using `<cword>`.
prepare_rename = true,
--- The timeout for the `textDocument/prepareRename` request and final
--- `textDocument/rename` request when submitting.
request_timeout = 1500,
-- Make an initial `textDocument/rename` request to gather other
-- occurences which are edited and use these ranges to preview.
-- If disabled only the word under the cursor will have a preview.
show_other_ocurrences = true,
-- Try to infer patterns from the initial `textDocument/rename` request
-- and use these to show hopefully better edit previews.
use_patterns = true,
-- The register which is used to temporarily record a macro into. This
-- macro can then be executed on other symbols using the `macrorepeat`
-- rename option.
scratch_register = "l",
keys = {
submit = {
{ "n", "<cr>" },
{ "v", "<cr>" },
{ "i", "<cr>" },
},
cancel = {
{ "n", "<esc>" },
{ "n", "q" },
},
},
hl = {
current = "CurSearch",
others = "Search",
},
}
,
keys = {
{ "<leader>r", function()
require("live-rename").rename({ cursorpos = 0 })
end },
},
}

View file

@ -1,79 +0,0 @@
local utils = require("utils")
local function resize_mode()
if require("window_management").is_in_resizing_mode() then
return "▲ Resizing ▼ "
else
return " "
end
end
local tabs = {
"tabs",
use_mode_colors = true,
tabs_color = {
active = "lualine_b_command",
},
show_modified_status = false,
component_separators = {
left = "",
right = ""
},
}
return {
"nvim-lualine/lualine.nvim",
dependencies = {
"nvim-tree/nvim-web-devicons"
},
event = "VeryLazy",
lazy = true,
config = function()
local function setup_lualine()
require("lualine").setup({
options = {
theme = require("norrsken.integrations.lualine"),
globalstatus = true,
section_separators = {
left = "",
right = "",
},
component_separators = {
left = "",
right = ""
},
icons_enabled = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
{
"diagnostics",
sources = { "nvim_lsp" },
sections = { "error", "warn", "info", "hint" },
update_in_insert = false,
},
resize_mode,
},
lualine_c = { tabs },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {}
},
tabline = {},
})
end
utils.create_user_event_cb("ColorsyncThemeChanged", setup_lualine, "ColorsyncEvents")
setup_lualine()
end
}

View file

@ -1,8 +0,0 @@
return {
"OXY2DEV/markview.nvim",
lazy = false,
priority = 49,
dependencies = {
"saghen/blink.cmp"
},
}

View file

@ -1,9 +0,0 @@
return {
"NeogitOrg/neogit",
event = "VeryLazy",
lazy = true,
opts = {},
keys = {
{ "<leader>v", function() require("neogit").open() end }
},
}

View file

@ -1,64 +0,0 @@
return {
"folke/noice.nvim",
event = "VeryLazy",
lazy = true,
dependencies = {
{ "MunifTanjim/nui.nvim", lazy = true },
},
opts = {
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
},
signature = {
auto_open = true,
opts = {
position = {
row = 2,
col = 0,
},
},
},
},
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = false, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = true, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
notify = {
level = "warn",
},
views = {
cmdline_popup = {
border = {
style = "single",
padding = { 0, 0 },
},
},
cmdline_popupmenu = {
border = {
style = "single",
padding = { 0, 0 },
},
},
hover = {
border = {
style = "single",
},
},
confirm = {
border = {
style = "single",
},
},
popup = {
border = {
style = "single",
},
},
},
},
}

View file

@ -1,14 +0,0 @@
return {
"LarssonMartin1998/nvim-norrsken",
priority = 1010,
opts = {
integrations = {
lualine = true,
blink = true,
noice = true,
incline = true,
neogit = true,
tiny_inline_diagnostics = true,
},
},
}

View file

@ -1,130 +0,0 @@
local utils = require("utils")
local inlay_hints_handler = require("inlay_hints_handler")
local is_debug_mode_active = false
return {
"mfussenegger/nvim-dap",
dependencies = {
{
"rcarriga/nvim-dap-ui",
opts = {
controls = {
enabled = false,
},
layouts = {
{
elements = {
{
id = "watches",
size = 0.5
},
{
id = "stacks",
size = 0.5
}
},
position = "bottom",
size = 15
}
},
}
},
-- Special adapters
{ "leoluz/nvim-dap-go", opts = {} },
{ "nvim-neotest/nvim-nio", lazy = true },
{ "LiadOz/nvim-dap-repl-highlights", opts = {} },
{ "theHamsta/nvim-dap-virtual-text", opts = {} },
{ "Weissle/persistent-breakpoints.nvim", opts = { load_breakpoints_event = { "BufReadPost" } } },
},
config = function()
local dap = require("dap")
local virtual_text = require("nvim-dap-virtual-text/virtual_text")
local breakpoint_api = require("persistent-breakpoints.api")
local stepping_keymaps = {
{ "<F10>", function() dap.step_over() end },
{ "<F11>", function() dap.step_into() end },
{ "<F12>", function() dap.step_out() end },
{
"<leader>dc",
function()
local columns = vim.o.columns
local lines = vim.o.lines
require("dapui").float_element("console", {
enter = true,
title = "output",
border = "rounded",
position = "center",
width = math.floor(columns * 0.8),
height = math.floor(lines * 0.6),
})
end
},
}
local dap_signs = {
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
{ "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } },
{ "DapBreakpointCondition", { text = "🟥", texthl = "", linehl = "", numhl = "" } },
}
for _, sign in ipairs(dap_signs) do
vim.fn.sign_define(unpack(sign))
end
local function enter_debug_mode()
if is_debug_mode_active then
return
end
utils.set_keymap_list(stepping_keymaps)
is_debug_mode_active = true
inlay_hints_handler.disable()
require("dapui").open()
end
local function exit_debug_mode()
if not is_debug_mode_active then
return
end
utils.del_keymap_list(stepping_keymaps)
is_debug_mode_active = false
inlay_hints_handler.restore()
virtual_text.clear_virtual_text()
require("dapui").close()
end
for _, request in ipairs({
{ "attach", enter_debug_mode },
{ "launch", enter_debug_mode },
}) do
dap.listeners.before[request[1]]["dapui_config"] = request[2]
end
for _, event in ipairs({
{ "event_terminated", exit_debug_mode },
{ "event_exited", exit_debug_mode },
}) do
dap.listeners.after[event[1]]["dapui_config"] = event[2]
end
local function dap_stop()
dap.terminate()
dap.close()
exit_debug_mode()
end
utils.set_keymap_list({
{ "<leader>dr", dap.continue },
{ "<leader>bt", breakpoint_api.toggle_breakpoint },
{ "<leader>bc", breakpoint_api.set_conditional_breakpoint },
{ "<leader>br", breakpoint_api.clear_all_breakpoints },
{ "<leader>ds", dap_stop },
})
end,
}

View file

@ -1,12 +0,0 @@
return {
"kosayoda/nvim-lightbulb",
opts = {
hide_in_unfocused_buffer = true,
code_lenses = true,
sign = { enabled = true, },
virtual_text = { enabled = false, },
float = { enabled = false, },
status_text = { enabled = false, },
autocmd = { enabled = true, updatetime = 25, },
},
}

View file

@ -1,5 +0,0 @@
return {
"folke/persistence.nvim",
event = "BufReadPre", -- this will only start session saving when an actual file was opened
opts = {}
}

View file

@ -1,5 +0,0 @@
return {
"nvim-lua/plenary.nvim",
branch = "master",
lazy = true,
}

View file

@ -1,177 +0,0 @@
return {
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = {
styles = {
notification = { border = "single", },
notification_history = { border = "single", },
blame_line = { border = "single", },
input = { border = "single", },
scratch = { border = "single", },
snacks_image = { border = "single", },
},
gitbrowse = {
enabled = true,
what = "branch",
},
picker = {
enabled = true,
ui_select = true,
formatters = {
filename_first = true,
truncate = 40,
filename_only = false,
icon_width = 2,
git_status_hl = true,
},
sources = {
recent = {
filter = {
cwd = true,
paths = {
[vim.fn.stdpath("data")] = false,
[vim.fn.stdpath("cache")] = false,
[vim.fn.stdpath("state")] = false,
},
},
},
files = {
hidden = true,
}
},
win = {
input = { border = "single", },
list = { border = "single", },
preview = { border = "single", },
},
layouts = {
default = {
layout = {
backdrop = false,
row = 1,
width = 0.6,
min_width = 80,
height = 0.95,
border = "none",
box = "vertical",
{
box = "vertical",
border = "single",
title = "{title} {live} {flags}",
title_pos = "center",
{ win = "input", height = 1, border = "bottom" },
{ win = "list", border = "none" },
},
{ win = "preview", title = "{preview}", height = 0.65, border = "single" },
},
},
select = {
preview = false,
layout = {
backdrop = false,
width = 0.5,
min_width = 80,
height = 0.4,
min_height = 3,
box = "vertical",
border = "single",
title = "{title}",
title_pos = "center",
{ win = "input", height = 1, border = "bottom" },
{ win = "list", border = "none" },
{ win = "preview", title = "{preview}", height = 0.4, border = "top" },
},
},
},
},
dashboard = {
enabled = true,
preset = {
keys = {
{ icon = "", key = "f", desc = "Find File", action = ":lua Snacks.dashboard.pick('files')" },
{ icon = "", key = "n", desc = "New File", action = ":ene | startinsert" },
{ icon = "", key = "g", desc = "Find Text", action = ":lua Snacks.dashboard.pick('live_grep')" },
{ icon = "", key = "c", desc = "Config", action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})" },
{ icon = "", key = "s", desc = "Restore Session", section = "session" },
{ icon = "󰒲 ", key = "L", desc = "Lazy", action = ":Lazy", enabled = package.loaded.lazy ~= nil },
{ icon = "", key = "q", desc = "Quit", action = ":qa" },
},
},
},
debug = { enabled = true, },
indent = {
enabled = true,
animate = {
enabled = false,
},
},
input = { enabled = true, },
notifier = {
enabled = true,
padding = false,
},
quickfile = { enabled = true, },
scroll = {
enabled = false,
animate = {
duration = { step = 5, total = 500 },
easing = "outCirc",
},
animate_repeat = {
delay = 100,
duration = { step = 3, total = 50 },
easing = "outCirc",
},
},
words = {
enabled = true,
debounce = 100,
},
zen = {
enabled = false,
toggles = { dim = false, },
on_open = function()
_G["snacks_zen_mode"] = true
end,
on_close = function()
_G["snacks_zen_mode"] = false
end,
},
},
keys = {
{ "gB", function() Snacks.gitbrowse() end, },
{ "<leader>z", function() Snacks.zen() end, },
{ "<leader>g", function() Snacks.picker.grep() end, },
{ "<leader>b", function() Snacks.picker.buffers() end, },
{ "<leader>l", function() Snacks.picker.git_log_file() end, },
{ "<leader>o", function() Snacks.picker.lsp_workspace_symbols() end, },
{ "<leader>s", function() Snacks.picker.lsp_symbols() end, },
{ "<leader>n", function() Snacks.picker.notifications({ win = { preview = { wo = { wrap = true } } } }) end },
{ "<leader>d", function() Snacks.picker.diagnostics({ win = { preview = { wo = { wrap = true } } } }) end },
{ "<leader>e", function() Snacks.rename.rename_file({}) end },
{ "gd", function() Snacks.picker.lsp_definitions() end, },
{ "gD", function() Snacks.picker.lsp_declarations() end, },
{ "gr", function() Snacks.picker.lsp_references() end, nowait = true, },
{ "gi", function() Snacks.picker.lsp_implementations() end, },
{ "gt", function() Snacks.picker.lsp_type_definitions() end, },
},
init = function()
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = function()
_G.inspect = function(...)
Snacks.debug.inspect(...)
end
_G.backtrace = function()
Snacks.debug.backtrace()
end
vim.print = _G.inspect
end,
})
end
}

View file

@ -1,15 +0,0 @@
return {
"kylechui/nvim-surround",
version = "*",
event = "VeryLazy",
lazy = true,
opts = {
-- Make sure that we never get whitespaces when adding surroundings
surrounds = {
["("] = { add = { "(", ")" }, },
["{"] = { add = { "{", "}" }, },
["<"] = { add = { "<", ">" }, },
["["] = { add = { "[", "]" }, },
}
}
}

View file

@ -1,42 +0,0 @@
return {
"rachartier/tiny-glimmer.nvim",
opts = {
refresh_interval_ms = 6,
overwrite = {
auto_map = true,
paste = {
enabled = true,
default_animation = {
name = "fade",
settings = {
from_color = "DiffText",
},
},
},
undo = {
enabled = true,
default_animation = {
name = "fade",
settings = {
from_color = "DiffDelete",
},
},
},
redo = {
enabled = true,
default_animation = {
name = "fade",
settings = {
from_color = "DiffAdd",
},
},
},
},
animations = {
fade = {
chars_for_max_duration = 1,
to_color = "Folded"
},
}
},
}

View file

@ -1,19 +0,0 @@
return {
"rachartier/tiny-inline-diagnostic.nvim",
event = "VeryLazy",
priority = 1000,
config = function()
require("tiny-inline-diagnostic").setup({
preset = "modern",
transparent_bg = false,
transparent_cursorline = false,
options = {
multilines = {
enabled = true,
always_show = true,
},
},
})
vim.diagnostic.config({ virtual_text = false })
end
}

View file

@ -1,120 +0,0 @@
local function ts_select(query)
return function() require("nvim-treesitter-textobjects.select").select_textobject(query, "textobjects") end
end
local function ts_move_prev(query)
return function() require("nvim-treesitter-textobjects.move").goto_previous_start(query, "textobjects") end
end
local function ts_move_next(query)
return function() require("nvim-treesitter-textobjects.move").goto_next_start(query, "textobjects") end
end
-- TODO: Move away from master branch after updating to Neovim 0.12 and use the rewrite
return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPre", "BufNewFile" },
branch = "master",
build = ":TSUpdate",
dependencies = {
{
"nvim-treesitter/nvim-treesitter-context",
opts = {
max_lines = 2, -- How many lines the window should span. Values <= 0 mean no limit.
multiline_threshold = 3, -- Maximum number of lines to show for a single context
trim_scope = "inner", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
}
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
init = function()
-- Disable entire built-in ftplugin mappings to avoid conflicts.
-- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins.
vim.g.no_plugin_maps = true
end,
opts = {
select = {
lookahead = true,
},
move = {
set_jumps = true,
},
},
keys = {
-- select
{ "ic", ts_select("@class.inner"), mode = { "x", "o" } },
{ "ac", ts_select("@class.outer"), mode = { "x", "o" } },
{ "ii", ts_select("@conditional.inner"), mode = { "x", "o" } },
{ "ai", ts_select("@conditional.outer"), mode = { "x", "o" } },
{ "if", ts_select("@function.inner"), mode = { "x", "o" } },
{ "af", ts_select("@function.outer"), mode = { "x", "o" } },
{ "il", ts_select("@loop.inner"), mode = { "x", "o" } },
{ "al", ts_select("@loop.outer"), mode = { "x", "o" } },
{ "ia", ts_select("@attribute.inner"), mode = { "x", "o" } },
{ "aa", ts_select("@attribute.outer"), mode = { "x", "o" } },
-- move
{ "[f", ts_move_prev("@function.outer"), mode = { "n", "x", "o" } },
{ "[i", ts_move_prev("@conditional.outer"), mode = { "n", "x", "o" } },
{ "[c", ts_move_prev("@class.outer"), mode = { "n", "x", "o" } },
{ "[l", ts_move_prev("@loop.outer"), mode = { "n", "x", "o" } },
{ "]f", ts_move_next("@function.outer"), mode = { "n", "x", "o" } },
{ "]i", ts_move_next("@conditional.outer"), mode = { "n", "x", "o" } },
{ "]c", ts_move_next("@class.outer"), mode = { "n", "x", "o" } },
{ "]l", ts_move_next("@loop.outer"), mode = { "n", "x", "o" } },
},
},
},
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"vim",
"vimdoc",
"bash",
"lua",
"c",
"cpp",
"c_sharp",
"rust",
"cmake",
"make",
"yaml",
"ninja",
"gitignore",
"markdown",
"markdown_inline",
"hyprlang",
"json",
"html",
"hlsl",
"glsl",
"gdshader",
"gdscript",
"dockerfile",
"dart",
"go",
"zig",
"css",
"regex",
"dap_repl",
"muttrc",
"python",
"latex",
"typst",
"ruby",
"svelte",
"typescript",
"just",
"tsx",
"javascript",
"jsonc",
},
sync_install = false,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = { enable = true },
})
end
}

View file

@ -1,6 +0,0 @@
return {
"mcauley-penney/visual-whitespace.nvim",
config = true,
event = "ModeChanged *:[vV\22]",
opts = {},
}

View file

@ -1,9 +1,9 @@
local utils = require("utils")
local terminal_window = nil
local terminal_bufnr = nil
local function open_terminal_window()
local utils = require("utils")
if terminal_bufnr and vim.api.nvim_buf_is_valid(terminal_bufnr) and utils.is_buf_buftype(terminal_bufnr, "terminal") then
if terminal_bufnr and vim.api.nvim_buf_is_valid(terminal_bufnr) and vim.bo[terminal_bufnr].buftype == "terminal" then
vim.cmd("botright split")
terminal_window = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(terminal_window, terminal_bufnr)
@ -21,7 +21,6 @@ local function toggle_terminal()
return
end
local utils = require("utils")
open_terminal_window()
local term_height = vim.api.nvim_get_option_value("lines", {})

View file

@ -1,34 +1,16 @@
local M = {}
M.colorsync_theme = nil
function M.set_keymap_list(keymap_list, mode)
mode = mode or "n"
M.foreach(keymap_list, function(mapping)
for _, mapping in ipairs(keymap_list) do
vim.keymap.set(mode, mapping[1], mapping[2], mapping[3] or {})
end)
end
end
function M.del_keymap_list(keymap_list, mode)
mode = mode or "n"
M.foreach(keymap_list, function(mapping)
for _, mapping in ipairs(keymap_list) do
vim.keymap.del(mode, mapping[1])
end)
end
function M.get_file_names_in_dir(dir, expr, strip_extension)
local path = vim.fn.stdpath("config") .. "/lua/" .. dir
local files_str = vim.fn.globpath(path, expr, true)
local has_line_breaks = vim.fn.match(files_str, [[\n]]) > -1
local files = has_line_breaks and vim.fn.split(files_str, "\n") or { files_str }
local should_strip_extension = strip_extension or false
if should_strip_extension then
return vim.tbl_map(function(file)
return vim.fn.fnamemodify(file, ":t:r")
end, files)
else
return files
end
end
@ -37,61 +19,6 @@ function M.validate_bufnr(bufnr)
return bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr
end
function M.xpcallmsg(fn, err_msg, err_container)
return xpcall(fn, function(err)
if err_container then
table.insert(err_container, err_msg .. ": " .. err)
else
error(err_msg .. ": " .. err)
end
end)
end
function M.foreach(t, f)
for _, v in pairs(t) do
f(v)
end
end
function M.create_user_event_cb(event_name, function_callback, augroup)
assert(event_name and event_name ~= "", "Event name must be provided")
assert(function_callback and type(function_callback) == "function", "Callback must be a valid function")
local cmd = {
callback = function_callback,
pattern = event_name,
}
if augroup then
cmd.group = augroup
end
vim.api.nvim_create_autocmd("User", cmd)
end
function M.broadcast_event(event_name)
vim.api.nvim_command("doautocmd <nomodeline> User " .. event_name)
end
function M.add_opts_to_all_mappings(mappings, opts)
assert(opts and mappings)
for _, modes in pairs(mappings) do
for _, mapping in pairs(modes) do
local existing_opts = mapping.opts or {}
mapping.opts = vim.tbl_extend("force", existing_opts, opts)
end
end
end
function M.is_buf_filetype(bufnr, filetype)
return vim.api.nvim_get_option_value("filetype", { buf = bufnr }) == filetype
end
function M.is_buf_buftype(bufnr, buftype)
return vim.api.nvim_get_option_value("buftype", { buf = bufnr }) == buftype
end
function M.lock_buf_to_window(win_id, bufnr, filetype)
local augroup_id = vim.api.nvim_create_augroup("LockWindow" .. win_id, { clear = true })
@ -108,7 +35,7 @@ function M.lock_buf_to_window(win_id, bufnr, filetype)
return
end
if M.is_buf_filetype(current_buf, filetype) then
if vim.bo[current_buf].filetype == filetype then
bufnr = current_buf
return
end

View file

@ -10,14 +10,11 @@ opt.clipboard = "unnamedplus"
-- Highlight the currently selected row
opt.cursorline = true
opt.cursorlineopt = "both"
opt.cursorlineopt = "line"
opt.breakindent = true
opt.breakindentopt = "list:-1"
-- Disable home screen
opt.shortmess:append("sI")
-- Signcolumn
opt.signcolumn = "yes:2" -- Adds a spacing to the left which can contain gutter icons
opt.fillchars = { eob = " " } -- Remove the fill character for empty lines which defaults to: "~"
@ -49,7 +46,7 @@ opt.swapfile = false
opt.splitright = true
opt.splitbelow = true
-- Removes the extra command line bar at the bottom, using lualine instead
-- Hide the cmdline bar when not in use; UI2 shows a float when needed
opt.cmdheight = 0
-- Statusline
@ -68,10 +65,6 @@ opt.list = false
-- Sessions
opt.sessionoptions = { "buffers", "curdir", "winsize", "winpos", "tabpages", "skiprtp" }
-- Builtin LSP completion tweaks
-- See comment in lspsetup autocmd for LspAttach
-- opt.completeopt = "menu,menuone,noselect,fuzzy"
opt.fileignorecase = true
-- This makes window sizing more controllable, with this set to true theyre always the same size.
@ -85,7 +78,7 @@ opt.shiftround = true
opt.redrawtime = 150
-- Disable lots of unnecessary warning notifications
opt.shortmess = "acstFOSW"
opt.shortmess = "acstFOSWI"
-- Allows to select one more after EOL
opt.virtualedit = "onemore"

View file

@ -73,7 +73,7 @@ end
local function swap_window(dir_char)
assert(dir_char == "h" or dir_char == "j" or dir_char == "k" or dir_char == "l", "Invalid direction character")
local function can_swap_window(window)
local function should_skip_swap(window)
if not window then
return true
end
@ -95,7 +95,7 @@ local function swap_window(dir_char)
end
local current_window = vim.api.nvim_get_current_win()
if can_swap_window(current_window) then
if should_skip_swap(current_window) then
return
end
@ -106,7 +106,7 @@ local function swap_window(dir_char)
local adjacent_window = get_adjacent_window(dir_char)
assert(adjacent_window ~= nil, "Invalid adjacent window from get_adjacent_window")
if can_swap_window(adjacent_window) then
if should_skip_swap(adjacent_window) then
return
end
@ -218,7 +218,7 @@ local function exit_resizing_mode()
assert(is_in_resizing_mode, "Not in resizing mode")
is_in_resizing_mode = false
utils.broadcast_event(on_resize_mode_exit_event)
vim.api.nvim_exec_autocmds("User", { pattern = on_resize_mode_exit_event, modeline = false })
assert(not is_in_resizing_mode, "Failed to exit resizing mode")
end
@ -240,7 +240,7 @@ local function enter_resizing_mode()
end
is_in_resizing_mode = true
utils.broadcast_event(on_resize_mode_enter_event)
vim.api.nvim_exec_autocmds("User", { pattern = on_resize_mode_enter_event, modeline = false })
assert(is_in_resizing_mode, "Failed to enter resizing mode")
end
@ -297,8 +297,10 @@ function M.setup()
local window_management_augroup = "WindowManagementEvents"
vim.api.nvim_create_augroup(window_management_augroup, { clear = true })
utils.create_user_event_cb(on_resize_mode_enter_event, on_resize_mode_enter, window_management_augroup)
utils.create_user_event_cb(on_resize_mode_exit_event, on_resize_mode_exit, window_management_augroup)
vim.api.nvim_create_autocmd("User",
{ pattern = on_resize_mode_enter_event, callback = on_resize_mode_enter, group = window_management_augroup })
vim.api.nvim_create_autocmd("User",
{ pattern = on_resize_mode_exit_event, callback = on_resize_mode_exit, group = window_management_augroup })
end
return M

131
nvim/nvim-pack-lock.json Normal file
View file

@ -0,0 +1,131 @@
{
"plugins": {
"LuaSnip": {
"rev": "5a1e39223db9a0498024a77b8441169d260c8c25",
"src": "https://github.com/L3MON4D3/LuaSnip",
"version": "2.0.0 - 3.0.0"
},
"blink.cmp": {
"rev": "451168851e8e2466bc97ee3e026c3dcb9141ce07",
"src": "https://github.com/saghen/blink.cmp",
"version": "1.0.0 - 2.0.0"
},
"colorful-menu.nvim": {
"rev": "b51a659459df8d078201aefc995db8175ed55e84",
"src": "https://github.com/xzbdmw/colorful-menu.nvim"
},
"demicolon.nvim": {
"rev": "a9ca137474b3a02e1d6ac48bfdb1985172e2ec9a",
"src": "https://github.com/mawkler/demicolon.nvim"
},
"friendly-snippets": {
"rev": "6cd7280adead7f586db6fccbd15d2cac7e2188b9",
"src": "https://github.com/rafamadriz/friendly-snippets"
},
"goto-preview": {
"rev": "d2d6923c9b9e0e43f0b9b566f261a8b1ae016540",
"src": "https://github.com/rmagatti/goto-preview"
},
"incline.nvim": {
"rev": "8b54c59bcb23366645ae10edca6edfb9d3a0853e",
"src": "https://github.com/b0o/incline.nvim"
},
"live-rename.nvim": {
"rev": "3a3cddf23b89a17992f9ca67afc5858077769462",
"src": "https://github.com/saecki/live-rename.nvim"
},
"logger.nvim": {
"rev": "63dd10c9b9a159fd6cfe08435d9606384ff103c5",
"src": "https://github.com/rmagatti/logger.nvim"
},
"lualine.nvim": {
"rev": "47f91c416daef12db467145e16bed5bbfe00add8",
"src": "https://github.com/nvim-lualine/lualine.nvim"
},
"lush.nvim": {
"rev": "9c60ec2279d62487d942ce095e49006af28eed6e",
"src": "https://github.com/rktjmp/lush.nvim"
},
"markview.nvim": {
"rev": "1861f959599ae03cfd59f56222a542035b0cd947",
"src": "https://github.com/OXY2DEV/markview.nvim"
},
"mini.nvim": {
"rev": "402ee6c6ec8ea44b22330446c8fb4e615fd3953e",
"src": "https://github.com/LarssonMartin1998/mini.nvim"
},
"neogit": {
"rev": "4681c1fdac1b730592ae195576e87406f7255750",
"src": "https://github.com/NeogitOrg/neogit"
},
"nui.nvim": {
"rev": "de740991c12411b663994b2860f1a4fd0937c130",
"src": "https://github.com/MunifTanjim/nui.nvim"
},
"nvim-dap": {
"rev": "2a8799ad91a1495c6bdf753f9b2179b3ff0f5bba",
"src": "https://github.com/mfussenegger/nvim-dap"
},
"nvim-dap-go": {
"rev": "b4421153ead5d726603b02743ea40cf26a51ed5f",
"src": "https://github.com/leoluz/nvim-dap-go"
},
"nvim-dap-repl-highlights": {
"rev": "f31deba47fe3ee6ff8d2f13d9dbd06b2d1ae06b5",
"src": "https://github.com/LiadOz/nvim-dap-repl-highlights"
},
"nvim-dap-ui": {
"rev": "f5b6673f374626515401c5bc51b005f784a4f252",
"src": "https://github.com/rcarriga/nvim-dap-ui"
},
"nvim-dap-virtual-text": {
"rev": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6",
"src": "https://github.com/theHamsta/nvim-dap-virtual-text"
},
"nvim-lightbulb": {
"rev": "aa3a8b0f4305b25cfe368f6c9be9923a7c9d0805",
"src": "https://github.com/kosayoda/nvim-lightbulb"
},
"nvim-nio": {
"rev": "21f5324bfac14e22ba26553caf69ec76ae8a7662",
"src": "https://github.com/nvim-neotest/nvim-nio"
},
"nvim-norrsken": {
"rev": "57e1fa7638e753efbd62e5aa53b82b08a80fed7e",
"src": "https://github.com/LarssonMartin1998/nvim-norrsken"
},
"nvim-treesitter": {
"rev": "7caec274fd19c12b55902a5b795100d21531391f",
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
"version": "'main'"
},
"nvim-treesitter-context": {
"rev": "adf4b6b0420b7be6c717ef0ac7993183d6c201b1",
"src": "https://github.com/nvim-treesitter/nvim-treesitter-context"
},
"nvim-treesitter-textobjects": {
"rev": "93d60a475f0b08a8eceb99255863977d3a25f310",
"src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"
},
"persistent-breakpoints.nvim": {
"rev": "d1656221836207787b8a7969cc2dc72668c4742a",
"src": "https://github.com/Weissle/persistent-breakpoints.nvim"
},
"plenary.nvim": {
"rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
"src": "https://github.com/nvim-lua/plenary.nvim"
},
"tiny-glimmer.nvim": {
"rev": "932e6c2cc4a43ce578f007db1f8f61ad6798f938",
"src": "https://github.com/rachartier/tiny-glimmer.nvim"
},
"tiny-inline-diagnostic.nvim": {
"rev": "ba133b3e932416e4b9507095731a6d7276878fe8",
"src": "https://github.com/rachartier/tiny-inline-diagnostic.nvim"
},
"visual-whitespace.nvim": {
"rev": "49ff2b1c572ed7033a584381fa23aad2bf3bb258",
"src": "https://github.com/mcauley-penney/visual-whitespace.nvim"
}
}
}

59
nvim/plugin/0-pack.lua Normal file
View file

@ -0,0 +1,59 @@
local function gh(repo)
return "https://github.com/" .. repo
end
vim.pack.add({
-- Mini suite
gh("LarssonMartin1998/mini.nvim"),
-- Colorscheme
gh("rktjmp/lush.nvim"),
gh("LarssonMartin1998/nvim-norrsken"),
-- Treesitter
{ src = gh("nvim-treesitter/nvim-treesitter"), version = "main" },
gh("nvim-treesitter/nvim-treesitter-context"),
gh("nvim-treesitter/nvim-treesitter-textobjects"),
-- Completion
gh("rafamadriz/friendly-snippets"),
{ src = gh("L3MON4D3/LuaSnip"), version = vim.version.range("2.x") },
{ src = gh("saghen/blink.cmp"), version = vim.version.range("1.x") },
-- UI
gh("nvim-lualine/lualine.nvim"),
gh("b0o/incline.nvim"),
gh("kosayoda/nvim-lightbulb"),
gh("rachartier/tiny-glimmer.nvim"),
gh("rachartier/tiny-inline-diagnostic.nvim"),
-- DAP
gh("mfussenegger/nvim-dap"),
gh("rcarriga/nvim-dap-ui"),
gh("nvim-neotest/nvim-nio"),
gh("LiadOz/nvim-dap-repl-highlights"),
gh("theHamsta/nvim-dap-virtual-text"),
gh("Weissle/persistent-breakpoints.nvim"),
gh("leoluz/nvim-dap-go"),
-- Misc
gh("OXY2DEV/markview.nvim"),
gh("MunifTanjim/nui.nvim"),
gh("xzbdmw/colorful-menu.nvim"),
})
require("colorful-menu").setup({})
vim.cmd.packadd("nvim.undotree")
vim.api.nvim_create_user_command("VimPackClean", function()
local inactive_plugins = vim.iter(vim.pack.get())
:filter(function(x) return not x.active end)
:map(function(x) return x.spec.name end)
:totable()
vim.notify("Attempting to delete inactive plugins: \n" .. table.concat(inactive_plugins, "\n"))
if not pcall(vim.pack.del, inactive_plugins) then
vim.notify("Failed to delete inactive plugins...")
end
end, {})

11
nvim/plugin/00-hooks.lua Normal file
View file

@ -0,0 +1,11 @@
vim.api.nvim_create_autocmd("PackChanged", {
callback = function(ev)
local name = ev.data.spec.name
local kind = ev.data.kind
if name == "nvim-treesitter" and (kind == "install" or kind == "update") then
if not ev.data.active then vim.cmd.packadd("nvim-treesitter") end
vim.cmd("TSUpdate")
end
end,
})

View file

@ -0,0 +1,10 @@
require("norrsken").setup({
integrations = {
lualine = true,
blink = true,
incline = true,
neogit = true,
mini = true,
tiny_inline_diagnostics = true,
},
})

View file

@ -0,0 +1,110 @@
vim.g.no_plugin_maps = true -- must be set before plugin loads
-- Rewrite API: configs.setup() is gone. Highlighting is handled by Neovim 0.12 builtins.
-- install() skips already-installed parsers automatically.
vim.schedule(function()
require("nvim-treesitter.install").install({
"vim",
"vimdoc",
"bash",
"lua",
"c",
"cpp",
"c_sharp",
"rust",
"cmake",
"make",
"yaml",
"ninja",
"gitignore",
"markdown",
"markdown_inline",
"hyprlang",
"json",
"html",
"hlsl",
"glsl",
"gdshader",
"gdscript",
"dockerfile",
"dart",
"go",
"zig",
"css",
"regex",
"muttrc",
"python",
"latex",
"typst",
"ruby",
"svelte",
"typescript",
"just",
"tsx",
"javascript",
})
end)
require("treesitter-context").setup({
max_lines = 2,
multiline_threshold = 3,
trim_scope = "inner",
})
-- Textobject helpers
local function ts_select(query)
return function()
require("nvim-treesitter-textobjects.select").select_textobject(query, "textobjects")
end
end
local function ts_move_prev(query)
return function()
require("nvim-treesitter-textobjects.move").goto_previous_start(query, "textobjects")
end
end
local function ts_move_next(query)
return function()
require("nvim-treesitter-textobjects.move").goto_next_start(query, "textobjects")
end
end
require("nvim-treesitter-textobjects").setup({
select = { lookahead = true },
move = { set_jumps = true },
})
local utils = require("utils")
-- Textobject select keymaps
for _, mode_maps in ipairs({
{
{ "x", "o" },
{
{ "ic", ts_select("@class.inner") },
{ "ac", ts_select("@class.outer") },
{ "ii", ts_select("@conditional.inner") },
{ "ai", ts_select("@conditional.outer") },
{ "if", ts_select("@function.inner") },
{ "af", ts_select("@function.outer") },
{ "il", ts_select("@loop.inner") },
{ "al", ts_select("@loop.outer") },
{ "ia", ts_select("@parameter.inner") },
{ "aa", ts_select("@parameter.outer") },
},
},
{
{ "n", "x", "o" },
{
{ "[f", ts_move_prev("@function.outer") },
{ "[i", ts_move_prev("@conditional.outer") },
{ "[c", ts_move_prev("@class.outer") },
{ "[l", ts_move_prev("@loop.outer") },
{ "]f", ts_move_next("@function.outer") },
{ "]i", ts_move_next("@conditional.outer") },
{ "]c", ts_move_next("@class.outer") },
{ "]l", ts_move_next("@loop.outer") },
},
},
}) do
utils.set_keymap_list(mode_maps[2], mode_maps[1])
end

43
nvim/plugin/blink.lua Normal file
View file

@ -0,0 +1,43 @@
local ls = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
ls.filetype_extend("typescriptreact", { "html" })
ls.filetype_extend("javascriptreact", { "html" })
ls.config.set_config({
enable_autosnippets = false,
store_selection_keys = false,
})
require("blink.cmp").setup({
keymap = { preset = "super-tab" },
appearance = {
nerd_font_variant = "mono",
},
completion = {
documentation = {
auto_show = false,
},
menu = {
draw = {
columns = { { "kind_icon" }, { "label", gap = 1 } },
components = {
label = {
text = function(ctx)
return require("colorful-menu").blink_components_text(ctx)
end,
highlight = function(ctx)
return require("colorful-menu").blink_components_highlight(ctx)
end,
},
},
},
},
},
snippets = {
preset = "luasnip",
active = function() return false end,
},
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
fuzzy = { implementation = "prefer_rust_with_warning" },
})

View file

@ -0,0 +1,8 @@
vim.schedule(function()
vim.pack.add({ "https://github.com/mawkler/demicolon.nvim" })
require("demicolon").setup({
keymaps = {
repeat_motions = "stateful",
},
})
end)

View file

@ -0,0 +1,21 @@
vim.schedule(function()
vim.pack.add({
"https://github.com/rmagatti/logger.nvim",
"https://github.com/rmagatti/goto-preview",
})
require("goto-preview").setup({
border = { "", "", "", "", "", "", "", "" },
focus_on_open = true,
stack_floating_preview_windows = false,
preview_window_title = { enable = true, position = "left" },
vim_ui_input = false,
})
local utils = require("utils")
utils.set_keymap_list({
{ "gp", function() require("goto-preview").goto_preview_definition() end },
{ "gy", function() require("goto-preview").goto_preview_type_definition() end },
{ "<Leader>q", function() require("goto-preview").close_all_win() end },
})
end)

103
nvim/plugin/incline.lua Normal file
View file

@ -0,0 +1,103 @@
local function setup_incline()
require("incline").setup({
window = {
padding = 0,
},
hide = {
cursorline = true,
},
render = function(props)
local fullpath = vim.api.nvim_buf_get_name(props.buf)
local filename = vim.fn.fnamemodify(fullpath, ":t")
if filename == "" then
filename = "[No Name]"
end
local function get_ft_icon()
local ft_icon, ft_color = require("nvim-web-devicons").get_icon_color(filename)
return { (ft_icon or "") .. " ", guifg = ft_color, guibg = "none" }
end
local function get_file_path()
local path_display = ""
if fullpath == "" then
path_display = filename
else
local parts = {}
for part in string.gmatch(vim.fn.fnamemodify(fullpath, ":.:h"), "[^/]+") do
table.insert(parts, part)
end
local ellipsis = ""
local max_path_parts = 2
if #parts > max_path_parts then
local start_index = #parts - max_path_parts + 1
path_display = ellipsis .. "/" .. table.concat(parts, "/", start_index)
elseif #parts > 0 then
path_display = table.concat(parts, "/")
end
if path_display ~= "" then
path_display = path_display .. "/" .. filename
else
path_display = filename
end
end
return { path_display .. "", gui = vim.bo[props.buf].modified and "bold,italic" or "bold" }
end
local function get_git_diff()
local summary = vim.b[props.buf].minidiff_summary
local labels = {}
if summary == nil then
return labels
end
for name, icon in pairs({ Delete = "-", Change = "~", Add = "+" }) do
if tonumber(summary[name:lower()]) and summary[name:lower()] > 0 then
table.insert(labels, { icon .. " " .. summary[name:lower()] .. " ", group = "MiniDiffSign" .. name })
end
end
if #labels > 0 then
table.insert(labels, { "" })
end
return labels
end
local function get_diagnostic_label()
local sev = vim.diagnostic.severity
local label = {}
for _, entry in ipairs({
{ sev.ERROR, "Error", "DiagnosticError" },
{ sev.WARN, "Warn", "DiagnosticWarn" },
{ sev.INFO, "Info", "DiagnosticInfo" },
{ sev.HINT, "Hint", "DiagnosticHint" },
}) do
local severity, kind, group = entry[1], entry[2], entry[3]
local n = #vim.diagnostic.get(props.buf, { severity = severity })
if n > 0 then
local icon = MiniIcons.get("lsp", kind)
table.insert(label, { icon .. " " .. n .. " ", group = group })
end
end
if #label > 0 then
table.insert(label, { "" })
end
return label
end
return {
{ " " },
{ get_diagnostic_label() },
{ get_git_diff() },
{ get_ft_icon() },
{ get_file_path() },
{ " " }
}
end,
})
end
vim.api.nvim_create_autocmd("User",
{ pattern = "ColorsyncThemeChanged", callback = setup_incline, group = "ColorsyncEvents" })
setup_incline()

View file

@ -0,0 +1,28 @@
vim.schedule(function()
vim.pack.add({ "https://github.com/saecki/live-rename.nvim" })
require("live-rename").setup({
prepare_rename = true,
request_timeout = 1500,
show_other_ocurrences = true,
use_patterns = true,
scratch_register = "l",
keys = {
submit = {
{ "n", "<cr>" },
{ "v", "<cr>" },
{ "i", "<cr>" },
},
cancel = {
{ "n", "<esc>" },
{ "n", "q" },
},
},
hl = {
current = "CurSearch",
others = "Search",
},
})
vim.keymap.set("n", "<leader>r", function()
require("live-rename").rename({ cursorpos = 0 })
end)
end)

58
nvim/plugin/lualine.lua Normal file
View file

@ -0,0 +1,58 @@
local function resize_mode()
if require("window_management").is_in_resizing_mode() then
return "▲ Resizing ▼ "
else
return " "
end
end
local tabs = {
"tabs",
use_mode_colors = true,
tabs_color = { active = "lualine_b_command" },
show_modified_status = false,
component_separators = { left = "", right = "" },
}
local function setup_lualine()
require("lualine").setup({
options = {
theme = require("norrsken.integrations.lualine"),
globalstatus = true,
section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" },
icons_enabled = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
{
"diagnostics",
sources = { "nvim_lsp" },
sections = { "error", "warn", "info", "hint" },
update_in_insert = false,
},
function() return vim.ui.progress_status() end,
resize_mode,
},
lualine_c = { tabs },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
tabline = {},
})
end
vim.api.nvim_create_autocmd("User",
{ pattern = "ColorsyncThemeChanged", callback = setup_lualine, group = "ColorsyncEvents" })
setup_lualine()

101
nvim/plugin/mini.lua Normal file
View file

@ -0,0 +1,101 @@
local utils = require("utils")
require("mini.icons").setup({})
-- mock_nvim_web_devicons() shims the devicons API so plugins that require it continue to work without the real package.
MiniIcons.mock_nvim_web_devicons()
require("mini.notify").setup({})
vim.notify = MiniNotify.make_notify()
require("mini.indentscope").setup({
symbol = "",
options = { try_as_border = true },
draw = {
animation = require("mini.indentscope").gen_animation.none(),
},
})
require("mini.sessions").setup({
autowrite = true,
})
require("mini.surround").setup({
custom_surroundings = {
["("] = { output = { left = "(", right = ")" } },
["{"] = { output = { left = "{", right = "}" } },
["<"] = { output = { left = "<", right = ">" } },
["["] = { output = { left = "[", right = "]" } },
},
mappings = {
add = "ys",
delete = "ds",
replace = "cs",
find = "",
find_left = "",
highlight = "",
update_n_lines = "",
suffix_last = "",
suffix_next = "",
},
search_method = "cover_or_next",
})
utils.del_keymap_list({ { "ys" } }, "x")
utils.set_keymap_list({
{ "S", [[:<C-u>lua MiniSurround.add('visual')<CR>]], { silent = true } },
}, "x")
-- yss, surround current line
utils.set_keymap_list({
{ "yss", "ys_", { remap = true } },
})
local starter = require("mini.starter")
starter.setup({
items = {
starter.sections.recent_files(8, false),
{
{ name = "Find File", action = "lua MiniPick.builtin.files()", section = "Actions" },
{ name = "Live Grep", action = "lua MiniPick.builtin.grep_live()", section = "Actions" },
{ name = "New File", action = "ene | startinsert", section = "Actions" },
{ name = "Sessions", action = "lua MiniSessions.select()", section = "Actions" },
{ name = "Update Plugins", action = "lua vim.pack.update()", section = "Actions" },
{ name = "Quit", action = "qa", section = "Actions" },
},
},
content_hooks = {
starter.gen_hook.adding_bullet(),
starter.gen_hook.aligning("center", "center"),
},
})
require("mini.diff").setup({})
utils.set_keymap_list({
{ "[g", function() MiniDiff.goto_hunk("prev") end },
{ "]g", function() MiniDiff.goto_hunk("next") end },
{ "<leader>d", function() MiniDiff.toggle_overlay(0) end },
})
require("mini.cursorword").setup({})
-- mini modules reset their highlight groups during setup(), so re-apply
-- the norrsken integration after setup and again on ColorScheme change.
local apply_mini_hl = require("norrsken.integrations.mini")
apply_mini_hl()
vim.api.nvim_create_autocmd("ColorScheme", { callback = apply_mini_hl })
require("mini.pick").setup({})
require("mini.extra").setup()
utils.set_keymap_list({
{ "<leader>f", function()
MiniPick.builtin.cli(
{ command = { "fd", "--type", "f", "--hidden", "--follow", "--exclude", ".git" } },
{ source = { name = "Files", show = MiniPick.default_show } }
)
end },
{ "<leader>g", function() MiniPick.builtin.grep_live() end },
{ "<leader>b", function() MiniPick.builtin.buffers() end },
{ "<leader>o", function() MiniExtra.pickers.lsp({ scope = "workspace_symbol" }) end },
{ "<leader>s", function() MiniExtra.pickers.lsp({ scope = "document_symbol" }) end },
{ "<leader>n", function() MiniNotify.show_history() end },
{ "<leader>x", function() MiniExtra.pickers.diagnostic({ win = { preview = { wo = { wrap = true } } } }) end },
})

18
nvim/plugin/neogit.lua Normal file
View file

@ -0,0 +1,18 @@
vim.schedule(function()
vim.pack.add({
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/NeogitOrg/neogit",
})
local p = require("norrsken.palette")
require("neogit").setup({
highlight = {
italic = false,
bold = true,
underline = true,
green = p.green,
red = p.red,
},
})
require("norrsken.integrations.neogit")()
vim.keymap.set("n", "<leader>v", function() require("neogit").open() end)
end)

115
nvim/plugin/nvim-dap.lua Normal file
View file

@ -0,0 +1,115 @@
local utils = require("utils")
local inlay_hints_handler = require("inlay_hints_handler")
local is_debug_mode_active = false
local dap = require("dap")
require("nvim-dap-repl-highlights").setup({})
require("nvim-dap-virtual-text").setup({})
require("persistent-breakpoints").setup({ load_breakpoints_event = { "BufReadPost" } })
require("dapui").setup({
controls = { enabled = false },
layouts = {
{
elements = {
{ id = "watches", size = 0.5 },
{ id = "stacks", size = 0.5 },
},
position = "bottom",
size = 15,
},
},
})
require("dap-go").setup({})
dap.adapters.codelldb = require("dap.codelldb")
local virtual_text = require("nvim-dap-virtual-text/virtual_text")
local breakpoint_api = require("persistent-breakpoints.api")
local stepping_keymaps = {
{ "<F10>", function() dap.step_over() end },
{ "<F11>", function() dap.step_into() end },
{ "<F12>", function() dap.step_out() end },
{
"<leader>dc",
function()
require("dapui").float_element("console", {
enter = true,
title = "output",
border = "rounded",
position = "center",
width = math.floor(vim.o.columns * 0.8),
height = math.floor(vim.o.lines * 0.6),
})
end,
},
}
for _, sign in ipairs({
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
{ "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } },
{ "DapBreakpointCondition", { text = "🟥", texthl = "", linehl = "", numhl = "" } },
}) do
vim.fn.sign_define(unpack(sign))
end
local function enter_debug_mode()
if is_debug_mode_active then return end
utils.set_keymap_list(stepping_keymaps)
is_debug_mode_active = true
inlay_hints_handler.disable()
require("dapui").open()
end
local function exit_debug_mode()
if not is_debug_mode_active then return end
utils.del_keymap_list(stepping_keymaps)
is_debug_mode_active = false
inlay_hints_handler.restore()
virtual_text.clear_virtual_text()
require("dapui").close()
end
for _, request in ipairs({ "attach", "launch" }) do
dap.listeners.before[request]["dapui_config"] = enter_debug_mode
end
for _, event in ipairs({ "event_terminated", "event_exited" }) do
dap.listeners.after[event]["dapui_config"] = exit_debug_mode
end
local function dap_stop()
dap.terminate()
dap.close()
exit_debug_mode()
end
utils.set_keymap_list({
{ "<leader>dr", dap.continue },
{ "<leader>bt", breakpoint_api.toggle_breakpoint },
{ "<leader>bc", breakpoint_api.set_conditional_breakpoint },
{ "<leader>br", breakpoint_api.clear_all_breakpoints },
{ "<leader>ds", dap_stop },
})
vim.api.nvim_create_user_command("LaunchTemplate", function()
vim.api.nvim_buf_set_lines(0, 0, -1, false, {
"{",
' "version": "0.2.0",',
' "configurations": [',
" {",
' "type": "codelldb",',
' "request": "launch",',
' "name": "Launch",',
' "program": "${workspaceFolder}/build/binary",',
' "cwd": "${workspaceFolder}",',
' "args": [],',
' "stopOnEntry": false,',
' "environment": []',
" }",
" ]",
"}",
})
end, {})

View file

@ -0,0 +1,9 @@
require("nvim-lightbulb").setup({
hide_in_unfocused_buffer = true,
code_lenses = false, -- 0.12 shows code lenses as virtual lines natively
sign = { enabled = true },
virtual_text = { enabled = false },
float = { enabled = false },
status_text = { enabled = false },
autocmd = { enabled = true, updatetime = 25 },
})

4
nvim/plugin/rephrase.lua Normal file
View file

@ -0,0 +1,4 @@
vim.opt.runtimepath:append("/Users/larssonmartin/dev/git/nvim-rephrase")
if pcall(require, "rephrase") then
require("rephrase").setup({})
end

View file

@ -1,8 +1,7 @@
return {
"mrcjkb/rustaceanvim",
version = "^5",
ft = { "rust" },
config = function()
vim.api.nvim_create_autocmd("FileType", {
pattern = "rust",
once = true,
callback = function()
vim.g.rustaceanvim = {
inlay_hints = {
highlight = "NonText",
@ -14,7 +13,6 @@ return {
},
},
server = {
on_attach = require("lsplib").configure_generic_client,
default_settings = {
["rust-analyzer"] = {
inlayHints = {
@ -24,13 +22,14 @@ return {
},
diagnostics = {
enable = true,
experimental = {
enable = true,
experimental = { enable = true },
},
},
},
},
}
}
vim.pack.add({
{ src = "https://github.com/mrcjkb/rustaceanvim", version = vim.version.range("5.x") },
})
end,
}
})

View file

@ -0,0 +1,24 @@
require("tiny-glimmer").setup({
refresh_interval_ms = 6,
overwrite = {
auto_map = true,
paste = {
enabled = true,
default_animation = { name = "fade", settings = { from_color = "DiffText" } },
},
undo = {
enabled = true,
default_animation = { name = "fade", settings = { from_color = "DiffDelete" } },
},
redo = {
enabled = true,
default_animation = { name = "fade", settings = { from_color = "DiffAdd" } },
},
},
animations = {
fade = {
chars_for_max_duration = 1,
to_color = "Folded",
},
},
})

View file

@ -0,0 +1,11 @@
require("tiny-inline-diagnostic").setup({
preset = "modern",
transparent_bg = false,
transparent_cursorline = false,
options = {
multilines = {
enabled = true,
always_show = true,
},
},
})

View file

@ -0,0 +1,8 @@
vim.api.nvim_create_autocmd("ModeChanged", {
pattern = "*:[vV\22]",
once = true,
callback = function()
vim.pack.add({ "https://github.com/mcauley-penney/visual-whitespace.nvim" })
require("visual-whitespace").setup({})
end,
})