From d6950258d7733e7effb53c05921240f6b84ba72c Mon Sep 17 00:00:00 2001 From: newbie Date: Tue, 19 Dec 2023 07:13:58 +0800 Subject: [PATCH] update --- lua/plugs/nvim-lspconfig.lua | 58 ++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/lua/plugs/nvim-lspconfig.lua b/lua/plugs/nvim-lspconfig.lua index a93dda3..a6c6681 100644 --- a/lua/plugs/nvim-lspconfig.lua +++ b/lua/plugs/nvim-lspconfig.lua @@ -46,6 +46,7 @@ return { require 'lspconfig'.bashls.setup(require('lsp.bash')) require 'lspconfig'.pyright.setup(require('lsp.pyright')) G.map({ + { 'n', 'rn', 'lua vim.lsp.buf.rename()' }, { 'n', 'gd', 'lua vim.lsp.buf.definition()' }, @@ -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", "o", "SymbolsOutline", { noremap = true } }, - { "v", "", "SymbolsOutline", { 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({ - [''] = cmp.mapping.confirm({ select = false }), - [""] = cmp.mapping(function(fallback) + [""] = 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, + }), + + + + [""] = 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" }), - [""] = cmp.mapping(function() + [""] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item() elseif vim.fn["vsnip#jumpable"](-1) == 1 then feedkey("(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 "") .. ")"