.dotfiles/.config/nvim/lua/nvwynd/plugins/lsp.lua

173 lines
3.5 KiB
Lua

return {
{
"neovim/nvim-lspconfig",
dependencies = {
"saghen/blink.cmp",
{ "j-hui/fidget.nvim", opts = {} },
},
config = function()
-- Markdown
vim.lsp.enable("marksman")
-- Python
vim.lsp.enable("pyright")
-- Rust
vim.lsp.enable("rust_analyzer")
vim.lsp.config("rust_analyzer", {
settings = {
["rust-analyzer"] = {
cargo = {
buildScripts = {
enable = true,
},
},
diagnostics = {
enable = true,
disabled = { "unresolved-proc-macro", "unresolved-macro-call" },
},
procMacro = {
enable = true,
ignored = "*",
},
checkOnSave = {
command = "clippy",
},
hover = {
actions = {
references = { enable = true },
},
},
inlayHints = {
closureReturnTypeHints = { enable = "always" },
lifetimeElisionHints = { enable = "always" },
reborrowHints = { enable = "always" },
},
},
},
})
-- C
vim.lsp.enable("clangd")
-- TOML
vim.lsp.enable("taplo")
-- Lua
local lua_rtp = vim.split(package.path, ";")
table.insert(lua_rtp, "lua/?.lua")
table.insert(lua_rtp, "lua/?/init.lua")
vim.lsp.enable("lua_ls")
vim.lsp.config("lua_ls", {
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = lua_rtp,
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
diagnostics = {
globals = { "vim" },
},
telemetry = {
enable = false,
},
},
},
})
-- GDScript
-- lspconfig.gdscript.setup({
-- capabilities = capabilities,
-- })
-- Zig
-- lspconfig.zls.setup({
-- capabilities = capabilities,
-- })
-- Nim
vim.lsp.enable("nim_langserver")
-- Clojure
-- lspconfig.clojure_lsp.setup({
-- capabilities = capabilities,
-- })
-- Gleam
-- lspconfig.gleam.setup({
-- capabilities = capabilities,
-- })
-- Bash
vim.lsp.enable("bashls")
-- HTML
vim.lsp.enable("html")
vim.lsp.config("html", {
filetypes = { "html", "templ", "htmldjango", "handlebars" },
})
-- HTMX
vim.lsp.enable("htmx")
vim.lsp.config("htmx", {
filetypes = { "html", "templ", "htmldjango" },
})
-- CSS
vim.lsp.enable("cssls")
-- JSON
vim.lsp.enable("jsonls")
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("nvwynd-lsp-attach", { clear = true }),
callback = function(event)
-- does word highlighting (across the entire file) whenever the cursor is on one
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end,
})
vim.api.nvim_create_autocmd("ColorScheme", {
callback = function(event)
for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do
vim.api.nvim_set_hl(0, group, {})
end
end,
})
end,
},
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
{
path = "luvit-meta/library",
words = { "vim%.uv" },
},
},
},
},
{
"Bilal2453/luvit-meta",
lazy = true,
},
}