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

182 lines
3.6 KiB
Lua
Raw Permalink Normal View History

2024-05-24 16:07:28 +03:00
return {
{
"neovim/nvim-lspconfig",
dependencies = {
{ "j-hui/fidget.nvim", opts = {} },
},
config = function()
local lsp_zero = require("lsp-zero")
lsp_zero.extend_lspconfig()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Python
lspconfig.pyright.setup({
capabilities = capabilities,
})
-- Rust
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
settings = {
["rust-analyzer"] = {
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true,
},
2024-05-24 16:07:28 +03:00
checkOnSave = {
command = "clippy",
},
hover = {
actions = {
references = { enable = true },
},
},
inlayHints = {
closureReturnTypeHints = { enable = "always" },
lifetimeElisionHints = { enable = "always" },
reborrowHints = { enable = "always" },
},
},
},
})
lspconfig.taplo.setup({
capabilities = capabilities,
})
2024-05-24 16:07:28 +03:00
-- HTMX
-- lspconfig.htmx.setup({
-- capabilities = capabilities,
-- filetypes = { "html", "templ", "htmldjango" },
-- })
-- Lua
local lua_rtp = vim.split(package.path, ";")
table.insert(lua_rtp, "lua/?.lua")
table.insert(lua_rtp, "lua/?/init.lua")
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = lua_rtp,
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
diagnostics = {
globals = { "vim" },
},
telemetry = {
enable = false,
},
},
},
})
-- Zig
lspconfig.zls.setup({
capabilities = capabilities,
})
2024-09-01 00:44:34 +03:00
-- Nim
lspconfig.nim_langserver.setup({
capabilities = capabilities,
})
-- C3
lspconfig.c3_lsp.setup({
capabilities = capabilities,
})
-- Bash
lspconfig.bashls.setup({
capabilities = capabilities,
})
2024-05-24 16:07:28 +03:00
-- HTML
lspconfig.html.setup({
capabilities = capabilities,
filetypes = { "html", "templ", "htmldjango", "handlebars" },
2024-05-24 16:07:28 +03:00
})
-- CSS
lspconfig.cssls.setup({
capabilities = capabilities,
})
-- JSON
lspconfig.jsonls.setup({
capabilities = capabilities,
})
2024-05-24 16:07:28 +03:00
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,
})
end,
},
{
"VonHeikemen/lsp-zero.nvim",
opts = {},
lazy = true,
dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/nvim-cmp", "L3MON4D3/LuaSnip" },
config = function()
local lsp_zero = require("lsp-zero")
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({
buffer = bufnr,
preserve_mappings = false,
})
end)
end,
},
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
{
path = "luvit-meta/library",
words = { "vim%.uv" },
},
},
},
2024-05-24 16:07:28 +03:00
},
{
"Bilal2453/luvit-meta",
lazy = true,
},
-- {
-- "folke/neodev.nvim",
-- opts = {},
-- },
2024-05-24 16:07:28 +03:00
}