2021-08-04 22:21:44 +02:00
|
|
|
local pid = vim.fn.getpid()
|
|
|
|
|
2022-08-25 22:25:58 +02:00
|
|
|
require("nvim-lightbulb").setup({
|
|
|
|
autocmd = {
|
|
|
|
enabled = true,
|
|
|
|
}
|
2022-05-03 21:48:38 +02:00
|
|
|
})
|
2021-08-04 22:21:44 +02:00
|
|
|
|
2022-08-29 13:14:18 +02:00
|
|
|
local format_augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
2022-05-03 21:48:38 +02:00
|
|
|
local on_attach = function(client, bufnr)
|
2021-08-04 22:21:44 +02:00
|
|
|
-- codelens
|
2022-05-03 21:48:38 +02:00
|
|
|
if client.resolved_capabilities.code_lens then
|
2022-08-29 13:14:18 +02:00
|
|
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "InsertLeave" }, {
|
2022-05-03 21:48:38 +02:00
|
|
|
callback = vim.lsp.codelens.refresh,
|
|
|
|
buffer = bufnr,
|
|
|
|
})
|
|
|
|
end
|
2022-08-29 13:14:18 +02:00
|
|
|
if client.supports_method("textDocument/formatting") then
|
|
|
|
vim.api.nvim_clear_autocmds({ group = format_augroup, buffer = bufnr })
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
|
|
group = format_augroup,
|
|
|
|
buffer = bufnr,
|
|
|
|
callback = function()
|
|
|
|
-- TODO switch to `vim.lsp.buf.format` after updating to nvim 0.8
|
|
|
|
vim.lsp.buf.formatting_seq_sync(nil, nil, { "tsserver", "null-ls" })
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
2020-09-26 23:54:07 +02:00
|
|
|
end
|
|
|
|
|
2022-05-05 17:56:17 +02:00
|
|
|
local config = require("lspconfig")
|
|
|
|
local configs = require("lspconfig.configs")
|
|
|
|
|
|
|
|
if not configs.glslls then
|
|
|
|
configs.glslls = {
|
|
|
|
default_config = {
|
|
|
|
cmd = { "glslls", "--stdin" };
|
|
|
|
filetypes = { "glsl" };
|
|
|
|
root_dir = config.util.root_pattern("*.conf", ".git");
|
|
|
|
settings = {};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
end
|
2021-11-13 04:23:32 +01:00
|
|
|
|
2022-03-30 11:30:29 +02:00
|
|
|
local capabilities_ = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
local capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities_)
|
2021-08-04 22:21:44 +02:00
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
local servers = {
|
|
|
|
"bashls",
|
|
|
|
"jsonls",
|
|
|
|
"yamlls",
|
|
|
|
"html",
|
|
|
|
"cssls",
|
|
|
|
"dockerls",
|
|
|
|
"rnix",
|
|
|
|
"tsserver",
|
2022-03-10 20:34:06 +01:00
|
|
|
"graphql",
|
2021-08-04 22:21:44 +02:00
|
|
|
"pylsp",
|
|
|
|
"terraformls",
|
|
|
|
"hls",
|
2022-03-10 15:03:17 +01:00
|
|
|
"vimls",
|
2022-05-05 17:56:17 +02:00
|
|
|
"glslls",
|
2021-08-04 22:21:44 +02:00
|
|
|
}
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
config[lsp].setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
}
|
|
|
|
end
|
2020-11-28 16:21:07 +01:00
|
|
|
|
2022-08-29 13:14:18 +02:00
|
|
|
config.rust_analyzer.setup {
|
2022-07-30 08:42:20 +02:00
|
|
|
on_attach = on_attach,
|
2022-06-27 01:03:17 +02:00
|
|
|
capabilities = capabilities,
|
|
|
|
root_dir = config.util.root_pattern("Cargo.toml", "rust-project.json", ".git"),
|
2022-07-26 13:05:52 +02:00
|
|
|
settings = {
|
|
|
|
["rust-analyzer"] = {
|
|
|
|
checkOnSave = { command = "clippy" },
|
|
|
|
},
|
|
|
|
},
|
2022-06-27 01:03:17 +02:00
|
|
|
}
|
|
|
|
|
2022-08-29 13:14:18 +02:00
|
|
|
config.omnisharp.setup {
|
2022-07-30 08:42:20 +02:00
|
|
|
on_attach = on_attach,
|
2021-08-04 22:21:44 +02:00
|
|
|
capabilities = capabilities,
|
2022-08-29 13:14:18 +02:00
|
|
|
cmd = { "OmniSharp", "--languageserver", "--hostPID", tostring(pid) },
|
2020-09-26 23:54:07 +02:00
|
|
|
}
|
|
|
|
|
2022-03-10 15:04:02 +01:00
|
|
|
local runtime_path = vim.split(package.path, ';')
|
|
|
|
table.insert(runtime_path, "lua/?.lua")
|
|
|
|
table.insert(runtime_path, "lua/?/init.lua")
|
|
|
|
|
|
|
|
config.sumneko_lua.setup {
|
2022-07-30 08:42:20 +02:00
|
|
|
on_attach = on_attach,
|
2022-03-10 15:04:02 +01:00
|
|
|
capabilities = capabilities,
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
version = "LuaJIT",
|
|
|
|
path = runtime_path,
|
|
|
|
},
|
|
|
|
diagnostics = {
|
2022-08-29 13:14:18 +02:00
|
|
|
globals = { "vim" },
|
2022-03-10 15:04:02 +01:00
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
|
|
},
|
|
|
|
telemetry = {
|
|
|
|
enable = false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-08-29 13:14:18 +02:00
|
|
|
local null_ls = require("null-ls")
|
|
|
|
local null_ls_custom = {
|
|
|
|
diagnostics = {},
|
|
|
|
formatting = {
|
|
|
|
-- TODO this doesn't use the correct formatter for some reason
|
|
|
|
-- likely some kind of directory or direnv issue
|
|
|
|
nix_fmt = {
|
|
|
|
name = "nix fmt",
|
|
|
|
meta = {
|
|
|
|
url = "https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-fmt.html",
|
|
|
|
description = "reformat your code in the standard style",
|
2021-05-05 00:05:37 +02:00
|
|
|
},
|
2022-08-29 13:14:18 +02:00
|
|
|
method = null_ls.methods.FORMATTING,
|
|
|
|
filetypes = { "nix" },
|
|
|
|
generator = require("null-ls.helpers").formatter_factory({
|
2022-05-12 11:57:43 +02:00
|
|
|
command = "nix",
|
2022-08-29 13:14:18 +02:00
|
|
|
args = { "fmt" },
|
|
|
|
-- to_stdin = true,
|
|
|
|
}),
|
2021-05-05 00:05:37 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2021-08-04 22:21:44 +02:00
|
|
|
|
2022-08-29 13:14:18 +02:00
|
|
|
null_ls.setup({
|
|
|
|
sources = {
|
|
|
|
null_ls.builtins.diagnostics.shellcheck,
|
|
|
|
null_ls.builtins.diagnostics.statix, -- nix linter
|
|
|
|
null_ls.builtins.diagnostics.eslint_d,
|
|
|
|
null_ls.builtins.diagnostics.stylelint,
|
|
|
|
null_ls.builtins.formatting.shfmt,
|
|
|
|
null_ls.builtins.formatting.prettier_d_slim.with {
|
|
|
|
filetypes = {
|
|
|
|
"css",
|
|
|
|
"scss",
|
|
|
|
"less",
|
|
|
|
"html",
|
|
|
|
"json",
|
|
|
|
"jsonc",
|
|
|
|
"yaml",
|
|
|
|
"markdown",
|
|
|
|
"graphql",
|
|
|
|
"handlebars",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
-- TODO not properly working yet
|
|
|
|
-- null_ls_custom.formatting.nix_fmt,
|
|
|
|
null_ls.builtins.formatting.nixfmt,
|
|
|
|
null_ls.builtins.formatting.rustfmt,
|
|
|
|
null_ls.builtins.formatting.terraform_fmt,
|
|
|
|
},
|
|
|
|
on_attach = on_attach,
|
|
|
|
})
|
|
|
|
|
2022-03-30 11:30:29 +02:00
|
|
|
require("nvim-autopairs").setup({
|
2021-08-04 22:21:44 +02:00
|
|
|
check_ts = true,
|
|
|
|
})
|