From d79bde7f269a853e40d811a530b7d7f913e74e47 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Mon, 27 Feb 2023 13:33:57 +0200 Subject: [PATCH] Moved lsp configs to seperate files --- lua/user/mason/settings/bashls.lua | 7 ++ lua/user/mason/settings/clangd.lua | 89 +++++++++++++++++++++++ lua/user/mason/settings/emmet_ls.lua | 13 ++++ lua/user/mason/settings/lua_ls.lua | 22 +++++- lua/user/mason/settings/rust_analyzer.lua | 19 +++++ 5 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 lua/user/mason/settings/bashls.lua create mode 100644 lua/user/mason/settings/clangd.lua create mode 100644 lua/user/mason/settings/emmet_ls.lua create mode 100644 lua/user/mason/settings/rust_analyzer.lua diff --git a/lua/user/mason/settings/bashls.lua b/lua/user/mason/settings/bashls.lua new file mode 100644 index 0000000..a949a0f --- /dev/null +++ b/lua/user/mason/settings/bashls.lua @@ -0,0 +1,7 @@ +return { + filetypes = { + "sh", + "bash", + "zsh", + }, +} diff --git a/lua/user/mason/settings/clangd.lua b/lua/user/mason/settings/clangd.lua new file mode 100644 index 0000000..47aefe4 --- /dev/null +++ b/lua/user/mason/settings/clangd.lua @@ -0,0 +1,89 @@ +return { + server = { + capabilities = { + offsetEncoding = { "utf-16" }, + }, + }, + extensions = { + -- defaults: + -- Automatically set inlay hints (type hints) + autoSetHints = true, + -- These apply to the default ClangdSetInlayHints command + inlay_hints = { + -- Only show inlay hints for the current line + only_current_line = false, + -- Event which triggers a refersh of the inlay hints. + -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but + -- not that this may cause higher CPU usage. + -- This option is only respected when only_current_line and + -- autoSetHints both are true. + only_current_line_autocmd = "CursorHold", + -- whether to show parameter hints with the inlay hints or not + show_parameter_hints = true, + -- prefix for parameter hints + parameter_hints_prefix = "<- ", + -- prefix for all the other hints (type, chaining) + other_hints_prefix = "=> ", + -- whether to align to the length of the longest line in the file + max_len_align = false, + -- padding from the left if max_len_align is true + max_len_align_padding = 1, + -- whether to align to the extreme right or not + right_align = false, + -- padding from the right if right_align is true + right_align_padding = 7, + -- The color of the hints + highlight = "Comment", + -- The highlight group priority for extmark + priority = 100, + }, + ast = { + -- -- These are unicode, should be available in any font + -- role_icons = { + -- type = "🄣", + -- declaration = "🄓", + -- expression = "🄔", + -- statement = ";", + -- specifier = "🄱", + -- ["template argument"] = "🆃", + -- }, + -- kind_icons = { + -- Compound = "đŸ„Č", + -- Recovery = "🅁", + -- TranslationUnit = "🅄", + -- PackExpansion = "🄿", + -- TemplateTypeParm = "🅃", + -- TemplateTemplateParm = "🅃", + -- TemplateParamObject = "🅃", + -- }, + -- These require codicons (https://github.com/microsoft/vscode-codicons) + role_icons = { + type = "î­Ł", + declaration = "îȘŒ", + expression = "", + specifier = "", + statement = "îȘ†", + ["template argument"] = "îȘ’", + }, + + kind_icons = { + Compound = "îȘ‹", + Recovery = "îȘ‡", + TranslationUnit = "î«©", + PackExpansion = "", + TemplateTypeParm = "îȘ’", + TemplateTemplateParm = "îȘ’", + TemplateParamObject = "îȘ’", + }, + highlights = { + detail = "Comment", + }, + }, + memory_usage = { + border = "none", + }, + symbol_info = { + border = "none", + }, + }, +} diff --git a/lua/user/mason/settings/emmet_ls.lua b/lua/user/mason/settings/emmet_ls.lua new file mode 100644 index 0000000..f75de8b --- /dev/null +++ b/lua/user/mason/settings/emmet_ls.lua @@ -0,0 +1,13 @@ +return { + filetypes = { + "html", + "htmldjango", + "typescriptreact", + "javascriptreact", + "css", + "sass", + "scss", + "less", + "eruby", + }, +} diff --git a/lua/user/mason/settings/lua_ls.lua b/lua/user/mason/settings/lua_ls.lua index 0f61fe4..b6f7b04 100644 --- a/lua/user/mason/settings/lua_ls.lua +++ b/lua/user/mason/settings/lua_ls.lua @@ -1,18 +1,32 @@ return { settings = { Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, diagnostics = { + -- Get the language server to recognize the `vim` global globals = { "vim" }, }, workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), }, + -- Do not send telemetry data containing a randomized but unique identifier telemetry = { enable = false, }, + root_pattern = { + ".stylua.toml", + ".luarc.json", + ".luarc.jsonc", + ".luacheckrc", + "stylua.toml", + "selene.toml", + "selene.yml", + ".git", + }, }, }, } diff --git a/lua/user/mason/settings/rust_analyzer.lua b/lua/user/mason/settings/rust_analyzer.lua new file mode 100644 index 0000000..58c2b91 --- /dev/null +++ b/lua/user/mason/settings/rust_analyzer.lua @@ -0,0 +1,19 @@ +return { + tools = { + on_initialized = function() + vim.cmd([[ + autocmd BufEnter,CursorHold,InsertLeave,BufWritePost *.rs silent! lua vim.lsp.codelens.refresh() + ]]) + end, + }, + settings = { + ["rust-analyzer"] = { + lens = { + enable = true, + }, + checkOnSave = { + command = "clippy", + }, + }, + }, +}