summaryrefslogtreecommitdiff
path: root/lua/config/lsp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/config/lsp.lua')
-rw-r--r--lua/config/lsp.lua91
1 files changed, 91 insertions, 0 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
new file mode 100644
index 0000000..2e7cf05
--- /dev/null
+++ b/lua/config/lsp.lua
@@ -0,0 +1,91 @@
+vim.lsp.inlay_hint.enable(true)
+vim.lsp.enable({
+ "clangd",
+ "lua_ls",
+ "nixd",
+ "nil_ls",
+ "zls",
+ "pyrefly",
+ "marksman",
+ "harper",
+ "tinymist",
+ "gopls",
+ "tombi",
+})
+
+vim.lsp.config("nil_ls", {
+ settings = {
+ formatting = {
+ command = { "nixfmt" },
+ },
+ },
+})
+
+vim.lsp.config("lua_ls", {
+ settings = {
+ Lua = {
+ codeLens = { enable = true },
+ hint = {
+ enable = true,
+ semicolon = "Disable",
+ },
+ workspace = {
+ checkThirdParty = false,
+ -- IMPORTANT: Leave library empty here.
+ -- lazydev will inject the correct Nix store paths dynamically.
+ library = {},
+ },
+ runtime = {
+ version = "LuaJIT",
+ -- Setting this to false allows lazydev to find files
+ -- outside your immediate workspace (like Nix store plugins)
+ pathStrict = false,
+ },
+ },
+ },
+})
+
+vim.lsp.config("*", {
+ capabilities = { textDocument = { semanticTokens = { multilineTokenSupport = true } } },
+ root_markers = { ".git", ".editorconfig", "flake.nix", "shell.nix" },
+})
+
+vim.diagnostic.config({
+ severity_sort = true,
+ severity_sort_priority = {
+ Error = 100,
+ Warn = 90,
+ Hint = 50,
+ Info = 10,
+ },
+})
+
+local RustLsp = function(mode, keymap, action, bufnr)
+ vim.keymap.set(mode, keymap, function()
+ vim.cmd.RustLsp(action)
+ end, { silent = true, buffer = bufnr })
+end
+
+vim.g.rustaceanvim = {
+ tools = {},
+ server = {
+ on_attach = function(client, bufnr)
+ RustLsp({ "n", "x" }, "gra", "codeAction", bufnr)
+ RustLsp("n", "<leader>ee", "explainError", bufnr)
+ RustLsp("n", "K", { "hover", "actions" }, bufnr)
+ RustLsp("n", "L", { "hover", "range" }, bufnr)
+ end,
+ default_settings = {
+ ["rust-analyzer"] = {
+ checkOnSave = {
+ enable = false,
+ command = "clippy",
+ },
+ procMacro = {
+ enable = true,
+ },
+ },
+ },
+ },
+ dap = {},
+}