Better lsp configs

This commit is contained in:
Miguel Palhas
2024-10-16 15:10:47 +01:00
parent c4334c6842
commit 1d123e7a49
11 changed files with 168 additions and 110 deletions
+1
View File
@@ -0,0 +1 @@
{ "diagnostics": { "globals": ["vim"] } }
-17
View File
@@ -1,17 +0,0 @@
local bufnr = vim.api.nvim_get_current_buf()
local opts = { buffer = bufnr }
vim.keymap.set("n", "ga", function()
vim.cmd.RustLsp "codeAction"
end, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>t", function()
vim.cmd.RustLsp { "testables" }
end, opts)
+1
View File
@@ -0,0 +1 @@
{}
+15 -21
View File
@@ -1,47 +1,41 @@
{
"LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" },
"NvChad": { "branch": "v2.5", "commit": "95d6dbe49b6645ec20ee32e4af31d5a277e6646f" },
"NvChad": { "branch": "v2.5", "commit": "f6025f0788880989484733c90deff07dff01ef02" },
"base46": { "branch": "v2.5", "commit": "177af7c0e492f6332bf78675a47b8983b1a32291" },
"catppuccin": { "branch": "main", "commit": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "40d4e98fcc3e6f485f0e8924c63734bc7e305967" },
"blink.cmp": { "branch": "main", "commit": "af68874f1b2e628e0c72ec27f5225d0c6b2d6820" },
"conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" },
"fzf-lua": { "branch": "main", "commit": "1e03541de4d8a169defe83bb4d7abfba450c63a1" },
"fzf-lua": { "branch": "main", "commit": "5dec364c9dedec00dcd6d06e323d7bc7f8d6b596" },
"gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" },
"hardtime.nvim": { "branch": "main", "commit": "6513bf42cd9261669d1ee41ff8b4065dfdc53a09" },
"hardtime.nvim": { "branch": "main", "commit": "027d6f991927a71bd510a7673ae5bb404ca2a1c7" },
"hop.nvim": { "branch": "master", "commit": "8f51ef02700bb3cdcce94e92eff16170a6343c4f" },
"indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" },
"lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" },
"local-highlight.nvim": { "branch": "master", "commit": "ae3ada3a332128b1036c84c8587b9069891c63da" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"menu": { "branch": "main", "commit": "349930b98590f10784e66340963aad2b4bf862c7" },
"menu": { "branch": "main", "commit": "ee85b2e394fde354bd24e35ff7a688d10c9212fa" },
"mini.pick": { "branch": "main", "commit": "6d66ae9eb0b75261f1842788dda611285b6f065f" },
"minty": { "branch": "main", "commit": "7c2a6452922313e10ff46aea49a4bb5e50e1ac68" },
"neogit": { "branch": "master", "commit": "946e86a599c32ed1fc76f9910b406f30d869c6a4" },
"neogit": { "branch": "master", "commit": "eda716c44d3b5a424ea8604b10756c7fd8bed93a" },
"nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" },
"nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "ff69ecca55d83ffc70657f260a799f79a5637831" },
"nvim-lsp-endhints": { "branch": "main", "commit": "391ef40521b631a8a2fb7aef78db6967ead6b39d" },
"nvim-lspconfig": { "branch": "master", "commit": "541f3a2781de481bb84883889e4d9f0904250a56" },
"nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" },
"nvim-tree.lua": { "branch": "master", "commit": "50e919426a4a2053f78b2f8ab001c8ad8eb47ef6" },
"nvim-treesitter": { "branch": "master", "commit": "9b1e607298dd5fc2ee6549488324cc92dafb99c0" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "b91c98afa6c42819aea6cbc1ba38272f5456a5cf" },
"nvim-tree.lua": { "branch": "master", "commit": "f5f67892996b280ae78b1b0a2d07c4fa29ae0905" },
"nvim-treesitter": { "branch": "master", "commit": "92725df6222614307c4712eb9982e5287f21aa11" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" },
"nvim-web-devicons": { "branch": "master", "commit": "56f17def81478e406e3a8ec4aa727558e79786f3" },
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"rustaceanvim": { "branch": "master", "commit": "29f42cc149f915d771c550b6dfe7c788d856cf04" },
"rustaceanvim": { "branch": "master", "commit": "819c3197bc308d81ea9c8cf75b01f34eb3f0e03b" },
"statuscol.nvim": { "branch": "main", "commit": "ecc04176e364dd7f614edfc4325e3a8521905ad6" },
"telescope.nvim": { "branch": "master", "commit": "df534c3042572fb958586facd02841e10186707c" },
"tint.nvim": { "branch": "master", "commit": "02bd0527a315a80e4e25bb2dd7b6994fb0daae01" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"trouble.nvim": { "branch": "main", "commit": "254145ffd528b98eb20be894338e2d5c93fa02c2" },
"typescript-tools.nvim": { "branch": "master", "commit": "f8c2e0b36b651c85f52ad5c5373ff8b07adc15a7" },
"ui": { "branch": "v3.0", "commit": "f2a10cd525a0a26579e500b1710ffd861b7a49e8" },
"ui": { "branch": "v3.0", "commit": "e0891549ec3ccff7d68a57915e7af97c9608ffad" },
"vim-kitty": { "branch": "main", "commit": "9cc594a634308aa3bfaf3da5b5e741da1c0144c1" },
"volt": { "branch": "main", "commit": "43f72b49037c191eb3cfe26ba7a5574b4bfce226" },
"which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }
+14 -10
View File
@@ -1,17 +1,21 @@
-- This file needs to have same structure as nvconfig.lua
-- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua
-- Please read that file to know all available options :(
-- Please read that file to know all available options :(
---@type ChadrcConfig
local M = {}
local M = {
ui = {
tabufline = {
enabled = false,
},
},
base46 = {
theme = "jabuti",
},
M.base46 = {
theme = "catppuccin",
-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
nvdash = {
load_on_startup = true,
},
}
return M
+82 -12
View File
@@ -1,18 +1,88 @@
-- load defaults i.e lua_lsp
require("nvchad.configs.lspconfig").defaults()
local M = {}
local lspconfig = require "lspconfig"
local servers = { "html", "cssls", "lua_ls", "biome" }
local nvlsp = require "nvchad.configs.lspconfig"
local map = vim.keymap.set
vim.lsp.inlay_hint.enable()
M.defaults = function()
-- load defaults i.e lua_lsp
require("nvchad.configs.lspconfig").defaults()
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = nvlsp.on_attach,
local lspconfig = require "lspconfig"
local servers = { "html", "cssls", "lua_ls", "biome" }
vim.lsp.inlay_hint.enable()
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = M.on_attach,
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
inlay_hints = { enable = true },
}
end
end
M.on_attach = function(client, bufnr)
nvlsp.on_attach(client, bufnr)
local function opts(desc)
return { buffer = bufnr, desc = "LSP " .. desc }
end
map("n", "<leader>rn", require "nvchad.lsp.renamer", opts "NvRenamer")
map("n", "gd", function()
require("telescope.builtin").lsp_definitions()
end, opts "LSP Definitions")
map("n", "gv", function()
require("telescope.builtin").lsp_definitions { jump_type = "vsplit" }
end, opts "LSP Definitions (vertical split)")
map("n", "gr", function()
require("telescope.builtin").lsp_references()
end, opts "LSP References")
map("n", "ga", vim.lsp.buf.code_action, opts "Code Actions")
end
M.rustacean = {
server = {
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
inlay_hints = { enable = true },
}
end
on_attach = function(client, bufnr)
M.on_attach(client, bufnr)
local function opts(desc)
return { buffer = bufnr, desc = "LSP " .. desc }
end
map("n", "ga", function()
vim.cmd.RustLsp "codeAction"
end, opts "Rust Code Actions")
end,
},
tools = {
float_win_config = {
border = "rounded",
borderchars = { "", "", "", "", "", "", "", "" },
relative = "cursor",
borderhighlight = "RenamerBorder",
titlehighlight = "RenamerTitle",
focusable = true,
},
},
}
M.typescript = {
code_lens = "on",
expose_as_code_action = "all",
server = {
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
on_attach = function(client, bufnr)
M.on_attach(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
end,
},
}
return M
-22
View File
@@ -1,22 +0,0 @@
local nvlsp = require "nvchad.configs.lspconfig"
local options = {
code_lens = "on",
expose_as_code_action = {
"fix_all",
"add_missing_imports",
-- "remove_unused",
-- "remove_unused_imports",
"organize_imports",
},
server = {
on_attach = function(client, buffer)
client.server_capabilities.documentFormattingProvider = false
nvlsp.on_attach(client, buffer)
end,
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
},
}
require("typescript-tools").setup(options)
+6
View File
@@ -17,3 +17,9 @@ map("i", "jk", "<Esc>")
--save file
map("n", "<C-s>", ":update<CR>")
map("i", "<C-s>", "<C-o>:update<CR><Esc>")
-- switch between last two files
-- map("n", "<tab>", ":b#<cr>", { desc = "switch between last two files" })
-- remove search highlight
map("n", "<leader>,", ":noh<cr>")
@@ -1,6 +1,7 @@
return {
{
"hrsh7th/nvim-cmp",
enabled = false,
opts = function()
require "configs.cmp"
end,
+13 -2
View File
@@ -1,8 +1,12 @@
local configs = require "configs.lspconfig"
vim.g.rustaceanvim = configs.rustacean
return {
{
"neovim/nvim-lspconfig",
config = function()
require "configs.lspconfig"
configs.defaults()
end,
},
@@ -17,7 +21,14 @@ return {
ft = { "typescript", "typescriptreact" },
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
config = function()
require "configs.typescript-tools"
require("typescript-tools").setup(configs.typescript)
end,
},
-- lazy.nvim
{
"chrisgrieser/nvim-lsp-endhints",
event = "LspAttach",
opts = {}, -- required, even if empty
},
}
+35 -26
View File
@@ -1,28 +1,37 @@
return {
{
"catppuccin/nvim",
name = "catppuccin",
enabled = false,
lazy = false,
init = function()
vim.cmd.colorscheme "catppuccin-mocha"
require("catppuccin").setup {
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
},
},
}
end,
},
-- { "nvchad/base46", enabled = false },
-- {
-- "folke/tokyonight.nvim",
-- lazy = false,
-- priority = 1000,
-- opts = {},
-- },
-- {
-- "catppuccin/nvim",
-- name = "catppuccin",
-- enabled = false,
-- lazy = false,
-- init = function()
-- vim.cmd.colorscheme "catppuccin-mocha"
-- require("catppuccin").setup {
-- native_lsp = {
-- enabled = true,
-- virtual_text = {
-- errors = { "italic" },
-- hints = { "italic" },
-- warnings = { "italic" },
-- information = { "italic" },
-- },
-- underlines = {
-- errors = { "underline" },
-- hints = { "underline" },
-- warnings = { "underline" },
-- information = { "underline" },
-- },
-- },
-- }
-- end,
-- },
}