Move Nix files into a nix directory
Move everything from `config` to the root level.
This commit is contained in:
parent
9f47df62b5
commit
69a397e624
124 changed files with 14 additions and 14 deletions
73
nvim/lua/opdavies/lsp/handlers.lua
Normal file
73
nvim/lua/opdavies/lsp/handlers.lua
Normal file
|
@ -0,0 +1,73 @@
|
|||
local M = {}
|
||||
|
||||
local function should_remove_diagnostic(messages_to_filter, message)
|
||||
for _, filter_message in ipairs(messages_to_filter) do
|
||||
if message:match(filter_message) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
M.definition = function()
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
|
||||
vim.lsp.buf_request(0, "textDocument/definition", params, function(err, result, ctx, config)
|
||||
local bufnr = ctx.bufnr
|
||||
local ft = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||
|
||||
local new_result = vim.tbl_filter(function(v)
|
||||
-- Remove any definitions within the nix store via the .direnv directory.
|
||||
if string.find(v.targetUri, ".direnv") then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Remove definitions within vendor-bin directory for PHP files.
|
||||
if ft == "php" then
|
||||
if string.find(v.targetUri, "vendor%-bin") then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end, result)
|
||||
|
||||
if #new_result > 0 then
|
||||
result = new_result
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/definition"](err, result, ctx, config)
|
||||
vim.cmd [[normal! zz]]
|
||||
end)
|
||||
end
|
||||
|
||||
M.on_publish_diagnostics = function(_, result, ctx, config)
|
||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||
|
||||
if client.name == "cssls" then
|
||||
local filtered_diagnostics = {}
|
||||
|
||||
local messages_to_filter = {
|
||||
"Unknown at rule @apply",
|
||||
"Unknown at rule @plugin",
|
||||
"Unknown at rule @tailwind",
|
||||
"Unknown at rule @theme",
|
||||
}
|
||||
|
||||
-- For each diagnostic, ensure its mesages doesn't match one I want to
|
||||
-- ignore before adding it to the result. If it matches, don't add it to the
|
||||
-- result and it won't be shown.
|
||||
for _, diagnostic in ipairs(result.diagnostics) do
|
||||
if not should_remove_diagnostic(messages_to_filter, diagnostic.message) then
|
||||
table.insert(filtered_diagnostics, diagnostic)
|
||||
end
|
||||
end
|
||||
|
||||
result.diagnostics = filtered_diagnostics
|
||||
end
|
||||
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(_, result, ctx, config)
|
||||
end
|
||||
|
||||
return M
|
128
nvim/lua/opdavies/lsp/init.lua
Normal file
128
nvim/lua/opdavies/lsp/init.lua
Normal file
|
@ -0,0 +1,128 @@
|
|||
local cmp_nvim_lsp = require "cmp_nvim_lsp"
|
||||
local handlers = require "opdavies.lsp.handlers"
|
||||
local lspconfig = require "lspconfig"
|
||||
|
||||
require("neodev").setup {}
|
||||
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
lspconfig.bashls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = function(_, _)
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(handlers.on_publish_diagnostics, {})
|
||||
end,
|
||||
}
|
||||
|
||||
lspconfig.gopls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.html.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.intelephense.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
telemetry = {
|
||||
enabled = false,
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
lspconfig.marksman.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.nixd.setup {
|
||||
capabilities = capabilities,
|
||||
cmd = { "nixd" },
|
||||
settings = {
|
||||
nixd = {
|
||||
nixpkgs = {
|
||||
expr = "import <nixpkgs> { }",
|
||||
},
|
||||
formatting = {
|
||||
command = "nix fmt",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
lspconfig.tailwindcss.setup {
|
||||
capabilities = capabilities,
|
||||
filetypes = { "html", "javascript", "twig", "typescript", "vue" },
|
||||
settings = {
|
||||
init_options = {
|
||||
userLanguages = {
|
||||
["html.twig"] = "html",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
lspconfig.terraformls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.ts_ls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.vuels.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.yamlls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
yaml = {
|
||||
keyOrdering = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
vim.diagnostic.config {
|
||||
float = { source = true },
|
||||
signs = true,
|
||||
underline = false,
|
||||
update_in_insert = false,
|
||||
virtual_text = { spacing = 2 },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function()
|
||||
local builtin = require "telescope.builtin"
|
||||
|
||||
vim.keymap.set("n", "gd", builtin.lsp_definitions, { buffer = 0 })
|
||||
vim.keymap.set("n", "gr", builtin.lsp_references, { buffer = 0 })
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = 0 })
|
||||
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, { buffer = 0 })
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
|
||||
|
||||
vim.keymap.set("n", "<space>cr", vim.lsp.buf.rename, { buffer = 0 })
|
||||
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, { buffer = 0 })
|
||||
end,
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue