completed the move to lazy
This commit is contained in:
@@ -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",
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user