completed the move to lazy

This commit is contained in:
2024-04-13 17:46:29 +02:00
parent b0740137d5
commit 1a377d75a9
4 changed files with 214 additions and 200 deletions

View File

@@ -1,120 +0,0 @@
local lspconfig = require("lspconfig")
local default_capabilities = require("cmp_nvim_lsp").default_capabilities()
local lsp_default_capabilities = vim.lsp.protocol.make_client_capabilities()
local capabilities = vim.tbl_deep_extend("force", {}, lsp_default_capabilities, default_capabilities)
require("mason").setup({
ui = {
border = "single",
},
})
require("mason-lspconfig").setup({
ensure_installed = { "tsserver", "rust_analyzer" },
handlers = {
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
})
end,
},
})
lspconfig.yamlls.setup({
on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = true
end,
settings = {
yaml = {
customTags = { "!enemy", "!delay", "!composite" },
validate = false,
format = {
enable = true,
},
},
},
})
lspconfig.tsserver.setup({
settings = {
typescript = {
preferences = {
quoteStype = "single",
},
},
javascript = {
preferences = {
quoteStyle = "single",
},
},
},
})
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local bufnr = args.buf
local opts = { buffer = bufnr, remap = false, nowait = true }
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition()
end, opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, opts)
vim.keymap.set("n", "<leader>vws", function()
vim.lsp.buf.workspace_symbol()
end, opts)
vim.keymap.set("n", "<leader>vd", function()
vim.diagnostic.open_float()
end, opts)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
end, opts)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
end, opts)
vim.keymap.set("n", "<leader>vca", function()
vim.lsp.buf.code_action()
end, opts)
vim.keymap.set("n", "<leader>vrr", function()
vim.lsp.buf.references()
end, opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, opts)
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, opts)
end,
})
vim.diagnostic.config({
virtual_text = true,
update_in_insert = true,
float = {
border = "single",
},
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "single",
})
require("lspconfig.ui.windows").default_options = {
border = "single",
}

View File

@@ -2,7 +2,7 @@
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "be7be2ca7f55bb881a7ffc16b2efa5af034ab06b" },
"barbecue.nvim": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" },
"catppuccin": { "branch": "main", "commit": "02bdd749931a5d739063562e57531c118e081882" },
"catppuccin": { "branch": "main", "commit": "08c6417bdc3b29e5f8c53e2cfe4067f288d49a54" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
@@ -18,19 +18,18 @@
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "44509689b9bf3984d729cc264aacb31cb7f41668" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"mini.diff": { "branch": "main", "commit": "860d6632806a71030aadc8adf8e37aee2daba09d" },
"mini.diff": { "branch": "main", "commit": "46ecb9950864528f594cf2ef88cc29b7681cb028" },
"mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" },
"neogen": { "branch": "main", "commit": "0daffcec249bf42275e322361fe55b89a05ff278" },
"nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },
"nvim-lspconfig": { "branch": "master", "commit": "b3014f2209503944f2714cf27c95591433a0c7d8" },
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
"nvim-tree-docs": { "branch": "master", "commit": "5db023d783da1e55339e5e25caaf72a59597e626" },
"nvim-treesitter": { "branch": "master", "commit": "b0ac1135fe304edd34e18204304906744db0fe63" },
"nvim-treesitter": { "branch": "master", "commit": "ef267f0c285928ea3a0d3362a260a0728fd4a146" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "734ebad31c81c6198dfe102aa23280937c937c42" },
"nvim-web-devicons": { "branch": "master", "commit": "6e355632387a085f15a66ad68cf681c1d7374a04" },
"plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" },
"tailwind-sorter.nvim": { "branch": "main", "commit": "3bde5890457e6272550c8b853c13bfb57457f47f" },
"telescope.nvim": { "branch": "master", "commit": "5a701e99906961218b55d7ad6c2a998f066c6fe0" },
"telescope.nvim": { "branch": "master", "commit": "4d4ade7f2b8f403e8816ca50c05ed16e259b21fb" },
"todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" },
"trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" },
"undotree": { "branch": "master", "commit": "aa93a7e5890dbbebbc064cd22260721a6db1a196" },

View File

@@ -1,76 +1,76 @@
return {
{
"hrsh7th/nvim-cmp",
dependencies = { "onsails/lspkind.nvim" },
opts = function()
local cmp = require("cmp")
local lspkind = require("lspkind")
local border = require('409.ui').border
"onsails/lspkind.nvim",
{
"hrsh7th/nvim-cmp",
dependencies = { "onsails/lspkind.nvim" },
opts = function()
local cmp = require("cmp")
local lspkind = require("lspkind")
local border = require("409.ui").border
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenuBorder,CursorLine:PmenuSel,Search:None"
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenuBorder,CursorLine:PmenuSel,Search:None"
return {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "nvim_lsp_signature_help" },
{ name = "nvim_lua" },
{ name = "luasnip", keyword_length = 2 },
{ name = "buffer", keyword_length = 3 },
},
view = {
entries = "custom",
},
completion = {
completeopt = "menuone,noselect,preview",
docs_initially_visible = true,
},
window = {
documentation = {
border = border,
winhighlight = winhighlight,
},
completion = {
border = border,
winhighlight = winhighlight,
},
},
return {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "nvim_lsp_signature_help" },
{ name = "nvim_lua" },
{ name = "luasnip", keyword_length = 2 },
-- { name = "buffer", keyword_length = 3 },
},
view = {
entries = "custom",
},
completion = {
completeopt = "menuone,noselect,preview",
docs_initially_visible = true,
},
window = {
documentation = {
border = border,
winhighlight = winhighlight,
},
completion = {
border = border,
winhighlight = winhighlight,
},
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
mapping = cmp.mapping.preset.insert({
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<C-k>"] = cmp.mapping.scroll_docs(-4),
["<C-j>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<C-g>"] = cmp.mapping.complete(),
["<Tab>"] = nil,
["<S-Tab>"] = nil,
}),
}
end
},
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lsp-signature-help",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
return kind
end,
},
mapping = cmp.mapping.preset.insert({
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<C-k>"] = cmp.mapping.scroll_docs(-4),
["<C-j>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<C-g>"] = cmp.mapping.complete(),
["<Tab>"] = nil,
["<S-Tab>"] = nil,
}),
}
end,
},
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lsp-signature-help",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
}

View File

@@ -1,6 +1,141 @@
return {
"onsails/lspkind.nvim",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
{
"williamboman/mason-lspconfig.nvim",
opts = function()
local lspconfig = require("lspconfig")
local default_capabilities = require("cmp_nvim_lsp").default_capabilities()
local lsp_default_capabilities = vim.lsp.protocol.make_client_capabilities()
local capabilities = vim.tbl_deep_extend("force", {}, lsp_default_capabilities, default_capabilities)
return {
ensure_installed = { "tsserver", "rust_analyzer" },
handlers = {
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
})
end,
},
}
end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
opts = {
diagnostics = {
virtual_text = true,
update_in_insert = true,
float = {
border = "single",
},
},
inlay_hints = {
enabled = true,
},
servers = {
tsserver = {
settings = {
typescript = {
preferences = {
quoteStyle = "single",
},
},
javascript = {
preferences = {
quoteStyle = "single",
},
},
},
},
},
},
config = function(_, opts)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local buffer = args.buf
local lsp_opts = { buffer = buffer, remap = false, nowait = true }
local client = vim.lsp.get_client_by_id(args.data.client_id)
-- TODO: Make this work once inlay hints are supported in the non-nightly nvim build
if opts.inlay_hints.enabled then
if client.supports_method("textDocument/inlayHint") then
local ih = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
if type(ih) == "function" then
ih(buffer, true)
elseif type(ih) == "table" and ih.enable then
ih.enable(buffer, true)
end
end
end
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition()
end, lsp_opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, lsp_opts)
vim.keymap.set("n", "<leader>vws", function()
vim.lsp.buf.workspace_symbol()
end, lsp_opts)
vim.keymap.set("n", "<leader>vd", function()
vim.diagnostic.open_float()
end, lsp_opts)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
end, lsp_opts)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
end, lsp_opts)
vim.keymap.set("n", "<leader>vca", function()
vim.lsp.buf.code_action()
end, lsp_opts)
vim.keymap.set("n", "<leader>vrr", function()
vim.lsp.buf.references()
end, lsp_opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, lsp_opts)
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, lsp_opts)
end,
})
vim.diagnostic.config(opts.diagnostics)
require("lspconfig.ui.windows").default_options = {
border = "single",
}
end,
},
{
"williamboman/mason.nvim",
dependencies = {},
opts = {
ui = {
border = "single",
},
},
config = function(_, opts)
require("mason").setup(opts)
end,
},
}