From c37d47e19df8559f5b7dcd40aca832623a6fa9b0 Mon Sep 17 00:00:00 2001 From: triethyl Date: Thu, 7 Aug 2025 13:29:18 -0400 Subject: neovim: idek --- pkgs/custom-neovim/config/init.lua | 2 +- pkgs/custom-neovim/config/lua/lsp.lua | 87 ++++++++++++++++++++++ pkgs/custom-neovim/config/lua/options.lua | 2 +- pkgs/custom-neovim/config/lua/plugins/cmp.lua | 1 + .../custom-neovim/config/lua/plugins/lspconfig.lua | 87 ---------------------- pkgs/custom-neovim/default.nix | 12 ++- pkgs/custom-neovim/design.md | 3 + 7 files changed, 102 insertions(+), 92 deletions(-) create mode 100644 pkgs/custom-neovim/config/lua/lsp.lua create mode 100644 pkgs/custom-neovim/config/lua/plugins/cmp.lua delete mode 100644 pkgs/custom-neovim/config/lua/plugins/lspconfig.lua (limited to 'pkgs/custom-neovim') diff --git a/pkgs/custom-neovim/config/init.lua b/pkgs/custom-neovim/config/init.lua index 306a76b..857aa37 100644 --- a/pkgs/custom-neovim/config/init.lua +++ b/pkgs/custom-neovim/config/init.lua @@ -9,6 +9,7 @@ require("colorschemes") require("neovide") require("mappings") require("statusline") +require("lsp") -- Require plugin configs. -- UI Plugins: @@ -23,7 +24,6 @@ require("plugins.auto-session") require("plugins.gitsigns") -- LSP Plugins: -require("plugins.lspconfig") require("plugins.actions-preview") -- Utility Plugins: diff --git a/pkgs/custom-neovim/config/lua/lsp.lua b/pkgs/custom-neovim/config/lua/lsp.lua new file mode 100644 index 0000000..7511004 --- /dev/null +++ b/pkgs/custom-neovim/config/lua/lsp.lua @@ -0,0 +1,87 @@ +-- Disable semantic tokens to stop weird highlighting. +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + if client then + client.server_capabilities.semanticTokensProvider = nil + end + end +}) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + -- vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + local mapkey = Utils.mapkey + + -- Workspace management + mapkey('n', "o", "Manage LSP workspace", "") + mapkey('n', 'oa', "Add Workspace Folder", vim.lsp.buf.add_workspace_folder) + mapkey('n', 'or', "Remove Workspace Folder", vim.lsp.buf.remove_workspace_folder) + mapkey('n', 'ol', "List Workspace Folders", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end) + + -- LSP Pickers + mapkey('n', "a", "Perform code action", ":lua require('actions-preview').code_actions()") + mapkey("n", "I", "Open workspace diagnostic picker", ":lua Snacks.picker.diagnostics()") + mapkey("n", "i", "Open diagnostic picker", [[:lua Snacks.picker.diagnostics_buffer()]]) + mapkey("n", "s", "Open symbol picker", ":lua Snacks.picker.lsp_symbols()") + mapkey("n", "S", "Open workspace symbol picker", ":lua Snacks.picker.lsp_workspace_symbols()") + + -- Goto Keys + mapkey('n', 'gD', "Go to declaration", vim.lsp.buf.declaration) + mapkey('n', 'gd', "Go to definition", vim.lsp.buf.definition) + mapkey('n', 'go', "Go to type definition", vim.lsp.buf.type_definition) + mapkey('n', 'gi', "Go to implementation", vim.lsp.buf.implementation) + + -- Other LSP Keys + mapkey('n', 'gs', "Signature Help", vim.lsp.buf.signature_help) + mapkey('n', 'gr', "Buffer References", vim.lsp.buf.references) + mapkey('n', 'r', "Rename Symbol", vim.lsp.buf.rename) + mapkey('n', 'h', "Format Buffer", function() + vim.lsp.buf.format { async = true } + end) + end, +}) + +local lspconfig = require('lspconfig') + +-- Configure individual lsps +lspconfig.nil_ls.setup {} +lspconfig.lua_ls.setup { + on_init = function(client) + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then + return + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- 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", + } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = {} + } +} +lspconfig.marksman.setup {} diff --git a/pkgs/custom-neovim/config/lua/options.lua b/pkgs/custom-neovim/config/lua/options.lua index ef80186..5698594 100644 --- a/pkgs/custom-neovim/config/lua/options.lua +++ b/pkgs/custom-neovim/config/lua/options.lua @@ -8,7 +8,7 @@ vim.o.icm = 'split' vim.o.cia = 'abbr,kind,menu' vim.o.mouse = "" vim.o.number = true -- set absolute numbered lines -vim.o.relativenumber = true -- set relative numbered lines +-- vim.o.relativenumber = true -- set relative numbered lines vim.o.scrolloff = 4 -- minimal number of screen lines to keep above and below the cursor vim.o.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time vim.o.clipboard = "unnamedplus" -- use system clipboard diff --git a/pkgs/custom-neovim/config/lua/plugins/cmp.lua b/pkgs/custom-neovim/config/lua/plugins/cmp.lua new file mode 100644 index 0000000..2ef2cca --- /dev/null +++ b/pkgs/custom-neovim/config/lua/plugins/cmp.lua @@ -0,0 +1 @@ +require("nvim-cmp").setup() diff --git a/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua b/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua deleted file mode 100644 index fbb35bf..0000000 --- a/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua +++ /dev/null @@ -1,87 +0,0 @@ --- Disable semantic tokens to stop weird highlighting. -vim.api.nvim_create_autocmd('LspAttach', { - callback = function(ev) - local client = vim.lsp.get_client_by_id(ev.data.client_id) - if client then - client.server_capabilities.semanticTokensProvider = nil - end - end -}) - --- Use LspAttach autocommand to only map the following keys --- after the language server attaches to the current buffer -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - -- Enable completion triggered by - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - - local mapkey = Utils.mapkey - - mapkey('n', 'gD', "Go to declaration", vim.lsp.buf.declaration) - mapkey('n', 'gd', "Go to definition", vim.lsp.buf.definition) - mapkey('n', 'gy', "Go to type definition", vim.lsp.buf.type_definition) - mapkey('n', 'gi', "Go to implementation", vim.lsp.buf.implementation) - mapkey('n', '', "Signature Help", vim.lsp.buf.signature_help) - mapkey('i', '', "Signature Help", vim.lsp.buf.signature_help) - mapkey('n', "o", "Manage LSP workspace", "") - mapkey('n', 'oa', "Add Workspace Folder", vim.lsp.buf.add_workspace_folder) - mapkey('n', 'or', "Remove Workspace Folder", vim.lsp.buf.remove_workspace_folder) - mapkey('n', 'ol', "List Workspace Folders", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end) - mapkey('n', 'r', "Rename Symbol", vim.lsp.buf.rename) - mapkey("n", "s", "Open symbol picker", ":lua Snacks.picker.lsp_symbols()") - mapkey("n", "S", "Open workspace symbol picker", ":lua Snacks.picker.lsp_workspace_symbols()") - - -- LSP Pickers - mapkey('n', "a", "Perform code action", ":lua require('actions-preview').code_actions()") - mapkey("n", "I", "Open workspace diagnostic picker", ":lua Snacks.picker.diagnostics()") - mapkey("n", "i", "Open diagnostic picker", [[:lua Snacks.picker.diagnostics_buffer()]]) - - mapkey('n', 'gr', "Buffer References", vim.lsp.buf.references) - mapkey('n', 'f', "Format Buffer", function() - vim.lsp.buf.format { async = true } - end) - end, -}) - -local lspconfig = require('lspconfig') - --- Configure individual lsps -lspconfig.nil_ls.setup {} -lspconfig.lua_ls.setup { - on_init = function(client) - local path = client.workspace_folders[1].name - if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then - return - end - - client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { - runtime = { - -- Tell the language server which version of Lua you're using - -- (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT' - }, - -- 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", - } - -- or pull in all of 'runtimepath'. NOTE: this is a lot slower - -- library = vim.api.nvim_get_runtime_file("", true) - } - }) - end, - settings = { - Lua = {} - } -} -lspconfig.marksman.setup {} diff --git a/pkgs/custom-neovim/default.nix b/pkgs/custom-neovim/default.nix index 60ff001..47633a7 100644 --- a/pkgs/custom-neovim/default.nix +++ b/pkgs/custom-neovim/default.nix @@ -17,15 +17,21 @@ in actions-preview-nvim # Adds a selector for LSP actions. nvim-treesitter.withAllGrammars # All treesitter grammars. tabby-nvim # Tab bar. - # alpha-nvim # Dashboard. - # persisted-nvim # Session manager. snacks-nvim - # oil-nvim dropbar-nvim auto-session nvim-ts-autotag gitsigns-nvim + # Completion Sources + nvim-cmp + cmp-buffer + cmp-path + cmp_luasnip + cmp-nvim-lsp + luasnip + friendly-snippets + # Colorschemes oxocarbon-nvim # IBM Carbon themes. rose-pine # Rose Pine themes. diff --git a/pkgs/custom-neovim/design.md b/pkgs/custom-neovim/design.md index 8e70f15..aa0cfb6 100644 --- a/pkgs/custom-neovim/design.md +++ b/pkgs/custom-neovim/design.md @@ -18,3 +18,6 @@ - find dropbar load autocommand and modify to work on winenter to prevent no dropbar when splitting - make splits automatically equalize when window resized - add arrows to binds +- make lazyvim launch with default shell bash +- make mini.git run commands from cwd instead of git root +- make all gaps in statusbar from a component -- cgit v1.2.3