From 58ceb817bb6ba195d1189160878f318f3bcda0ef Mon Sep 17 00:00:00 2001 From: triethyl Date: Sat, 16 Aug 2025 20:20:21 -0400 Subject: neovim: restarted config --- pkgs/custom-neovim/config/lua/lsp.lua | 81 +++++++++++++---------------------- 1 file changed, 30 insertions(+), 51 deletions(-) (limited to 'pkgs/custom-neovim/config/lua/lsp.lua') diff --git a/pkgs/custom-neovim/config/lua/lsp.lua b/pkgs/custom-neovim/config/lua/lsp.lua index a01758c..a4a25bc 100644 --- a/pkgs/custom-neovim/config/lua/lsp.lua +++ b/pkgs/custom-neovim/config/lua/lsp.lua @@ -1,3 +1,23 @@ +-- Lua LS +vim.lsp.config("lua_ls", { + cmd = { 'lua-language-server' }, + filetypes = { 'lua' }, + root_markers = { + '.luarc.json', + '.luarc.jsonc', + '.luacheckrc', + '.stylua.toml', + 'stylua.toml', + 'selene.toml', + 'selene.yml', + '.git', + }, + } +) +vim.lsp.enable("lua_ls") + +-- LSP Autocommands + -- Disable semantic tokens to stop weird highlighting. vim.api.nvim_create_autocmd('LspAttach', { callback = function(ev) @@ -16,22 +36,17 @@ vim.api.nvim_create_autocmd('LspAttach', { -- 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) + local mapkey = function(mode, key, desc, action, plugin) + local keymapper = plugin and require("lz.n").keymap(plugin).set or vim.keymap.set + keymapper(mode, key, action, {noremap = true, silent = true, desc = desc}) + end -- LSP Pickers mapkey('n', "a", "Perform code action", ":lua require('actions-preview').code_actions()") - -- mapkey("n", "I", "Open workspace diagnostic picker", ":Namu diagnostics") - mapkey("n", "i", "Open diagnostic picker", ":Namu diagnostics") - mapkey("n", "s", "Open symbol picker", ":Namu symbols") - mapkey("n", "S", "Open workspace symbol picker", ":Namu workspace") + mapkey("n", "S", "Open workspace symbol picker", [[:Pick lsp scope="workspace_symbol"]], "mini.pick") + mapkey("n", "s", "Open symbol picker", [[:Pick lsp scope="document_symbol"]], "mini.pick") + mapkey("n", "I", "Open workspace diagnostic picker", [[:Pick diagnostic scope="all"]], "mini.pick") + mapkey("n", "i", "Open diagnostic picker", [[:Pick diagnostic scope="current"]], "mini.pick") -- Goto Keys mapkey('n', 'gD', "Go to declaration", vim.lsp.buf.declaration) @@ -41,47 +56,11 @@ vim.api.nvim_create_autocmd('LspAttach', { -- Other LSP Keys mapkey('n', 'gs', "Signature Help", vim.lsp.buf.signature_help) - mapkey('n', 'gr', "Buffer References", vim.lsp.buf.references) + mapkey('n', 'gR', "Buffer References", vim.lsp.buf.references) + mapkey('n', 'gr', "Open ", 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 {} -- cgit v1.2.3