-- LSP Configs -- Get more from https://github.com/neovim/nvim-lspconfig/tree/master/lsp -- 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") -- Marksman LS vim.lsp.config("marksman", { cmd = {"marksman", "server"}, filetypes = {"markdown", "markdown.mdx"}, root_markers = {".marksman.toml", ".git"}, }) vim.lsp.enable("marksman") -- Nixd LS vim.lsp.config("nixd", { cmd = { 'nixd' }, filetypes = { 'nix' }, root_markers = { 'flake.nix', '.git' }, }) vim.lsp.enable("nixd") -- CC LS vim.lsp.config("ccls", { cmd = { 'ccls' }, filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' }, offset_encoding = 'utf-32', -- Set workspace root_markers = { 'compile_commands.json', '.ccls', '.git' }, workspace_required = true, }) vim.lsp.enable("ccls") -- LSP Autocommands -- 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() -- Enable completion triggered by -- vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' 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", ":FzfLua lsp_code_actions", "fzf-lua") mapkey("n", "S", "Open workspace symbol picker", ":lua MiniExtra.pickers.lsp({ scope = 'workspace_symbol' })", "mini.pick") mapkey("n", "s", "Open symbol picker", ":lua MiniExtra.pickers.lsp({ scope = 'document_symbol' })", "mini.pick") mapkey("n", "I", "Open workspace diagnostic picker", ":lua MiniExtra.pickers.diagnostic({ scope = 'all' })", "mini.pick") mapkey("n", "i", "Open diagnostic picker", ":lua MiniExtra.pickers.diagnostic({ scope = 'current' })", "mini.pick") -- 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', "Go to signature help", vim.lsp.buf.signature_help) mapkey('n', 'gR', "Go to 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, })