This commit is contained in:
newbie 2023-12-19 07:13:58 +08:00
parent f67a85dfb1
commit d6950258d7

View File

@ -46,6 +46,7 @@ return {
require 'lspconfig'.bashls.setup(require('lsp.bash'))
require 'lspconfig'.pyright.setup(require('lsp.pyright'))
G.map({
{ 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>' },
@ -59,6 +60,21 @@ return {
end
},
{
-- lsp
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
"clangd",
"bashls",
"pyright",
"lua_ls"
}
})
end
},
{
-- lsp 下载器
"williamboman/mason.nvim",
@ -135,7 +151,6 @@ return {
require("symbols-outline").setup(opts)
G.map({
{ "n", "<leader>o", "<cmd>SymbolsOutline<cr>", { noremap = true } },
{ "v", "<cs-o>", "<cmd>SymbolsOutline<cr>", { noremap = true } },
})
end
},
@ -151,8 +166,8 @@ return {
{
"hrsh7th/nvim-cmp",
config = function()
local cmp = require('cmp')
local lspkind = require('lspkind')
local cmp = require('cmp')
-- local lspkind = require('lspkind')
cmp.setup {
snippet = {
expand = function(args)
@ -167,8 +182,20 @@ return {
{ name = 'cmdline' },
}),
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({ select = false }),
["<c-n>"] = cmp.mapping(function(fallback)
["<CR>"] = cmp.mapping({
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
c = function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
else
fallback()
end
end,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
@ -180,13 +207,14 @@ return {
end
end, { "i", "s" }),
["<n-p>"] = cmp.mapping(function()
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
}),
window = {
completion = {
@ -194,20 +222,32 @@ return {
col_offset = -3,
side_padding = 0,
border = "rounded",
scrollbar = true,
scrollbar = false,
},
documentation = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
border = "rounded",
scrollbar = true,
scrollbar = false,
},
},
fomatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local kind = require("lspkind").cmp_format({
mode = "symbol_text",
maxwidth = 50,
-- before = function(entry, vim_item)
-- vim_item.kind = kind_icons[vim_item.kind]
-- vim_item.menu = ({
-- buffer = "[Buffer]",
-- nvim_lsp = "[LSP]",
-- })[entry.source.name]
-- return vim_item
-- end,
})(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = kind_icons[vim_item.kind]
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"