if vim.g.vscode then return end local Remap = require("halfdan.keymap") local nnoremap = Remap.nnoremap local inoremap = Remap.inoremap vim.diagnostic.config({ signs = { text = { [vim.diagnostic.severity.ERROR] = "", [vim.diagnostic.severity.WARN] = "", [vim.diagnostic.severity.INFO] = "", }, }, }) -- Set Default Prefix. -- Note: You can set a prefix per lsp server in the lv-globals.lua file vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { signs = true, underline = true, } ) -- Setup for nvim-notify vim.lsp.set_log_level(2) local convert_lsp_log_level_to_neovim_log_level = function(lsp_log_level) if lsp_log_level == 1 then return 4 elseif lsp_log_level == 2 then return 3 elseif lsp_log_level == 3 then return 2 elseif lsp_log_level == 4 then return 1 end end local levels = { "ERROR", "WARN", "INFO", "DEBUG", [0] = "TRACE", } ---@diagnostic disable-next-line: unused-vararg vim.lsp.handlers["window/showMessage"] = function(_, result, ...) if require("vim.lsp.log").should_log(convert_lsp_log_level_to_neovim_log_level(result.type)) then vim.notify(result.message, levels[result.type]) end end -- symbols for autocomplete vim.lsp.protocol.CompletionItemKind = { "  (Text) ", "  (Method)", "  (Function)", "  (Constructor)", " ﴲ (Field)", "[] (Variable)", "  (Class)", " ﰮ (Interface)", "  (Module)", " 襁 (Property)", "  (Unit)", "  (Value)", " 練 (Enum)", "  (Keyword)", "  (Snippet)", "  (Color)", "  (File)", "  (Reference)", "  (Folder)", "  (EnumMember)", " ﲀ (Constant)", " ﳤ (Struct)", "  (Event)", "  (Operator)", "  (TypeParameter)" } -- Diagnostic keymaps -- Show Lspsaga line diagnostics vim.keymap.set('n', 'e', 'Lspsaga show_line_diagnostics', { noremap = true, silent = true }) -- Send diagnostics to location list vim.keymap.set('n', 'q', function() vim.diagnostic.setloclist() end, { noremap = true, silent = true }) -- Global mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions vim.keymap.set('n', 'e', vim.diagnostic.open_float) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- 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 opts = { buffer = ev.buf } vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) vim.keymap.set('n', 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, opts) end, }) vim.lsp.config("lua_ls", { settings = { Lua = { runtime = { -- Tell the language server which version of Lua you're using version = "LuaJIT", }, diagnostics = { -- Get the language server to recognize the `vim` global globals = { "vim" }, }, workspace = { -- Make the server aware of Neovim runtime files library = vim.api.nvim_get_runtime_file("", true), }, telemetry = { -- Do not send telemetry data containing a randomized but unique identifier enable = false, }, }, }, }) -- Enable it vim.lsp.enable("lua_ls") vim.lsp.config('gopls', { cmd = { "gopls" }, filetypes = { "go", "gomod", "gowork", "gotmpl" }, root_markers = { "go.work", "go.mod", ".git" }, settings = { gopls = { analyses = { unusedparams = true, shadow = true, }, staticcheck = true, }, }, }) vim.lsp.enable 'gopls' vim.lsp.config('expert', { cmd = { 'expert' }, root_markers = { 'mix.exs', '.git' }, filetypes = { 'elixir', 'eelixir', 'heex' }, }) vim.lsp.enable 'expert'