This commit is contained in:
newbie 2024-01-06 10:53:27 +08:00
parent 1798c57e08
commit 5eaf966f21

View File

@ -1,34 +1,3 @@
local kind_icons = {
Text = "",
Method = "󰆧",
Function = "󰊕",
Constructor = "",
Field = "󰇽",
Variable = "󰂡",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈙",
Reference = "",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "",
Event = "",
Operator = "󰆕",
TypeParameter = "󰅲",
}
return {
{
-- lsp的config
@ -65,7 +34,11 @@ return {
{
-- lsp
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim", -- lsp 下载器
},
config = function()
require "mason".setup {}
require("mason-lspconfig").setup({
ensure_installed = {
"clangd",
@ -80,13 +53,6 @@ return {
})
end
},
{
-- lsp 下载器
"williamboman/mason.nvim",
config = function()
require "mason".setup {}
end
},
{ --
'simrat39/symbols-outline.nvim',
config = function()
@ -173,13 +139,7 @@ return {
'onsails/lspkind-nvim',
},
config = function()
-- require "cmp-nvim-lsp".setup {}
-- require "cmp-buffer".setup {}
-- require "cmp-path".setup {}
-- require "cmp-cmdline".setup {}
-- require "cmp-vsnip".setup {}
-- require "vim-vsnip".setup {}
-- require "lspkind-nvim".setup {}
local has_words_before = function()
unpack = unpack or table.unpack
@ -190,10 +150,8 @@ return {
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local cmp = require('cmp')
-- local lspkind = require('lspkind')
cmp.setup {
local cmp_opt = {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
@ -201,11 +159,11 @@ return {
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'vnsip' },
-- { name = 'cmdline' },
}),
},
{ name = 'buffer' },
{ name = 'path' }
),
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping({
@ -240,6 +198,7 @@ return {
end, { "i", "s" }),
}),
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
@ -255,22 +214,18 @@ return {
},
},
fomatting = {
formatting = {
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 = 5, })(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 "") .. ")"
return kind
end,
},
}
require('cmp').setup(cmp_opt)
end,
},
@ -278,14 +233,14 @@ return {
-- 语法高亮 --
'nvim-treesitter/nvim-treesitter',
config = function()
require 'nvim-treesitter.configs'.setup {
local treesitter_opt = {
ensure_installed = {},
indent = { enable = true },
sync_install = false,
auto_install = true,
highlight = {
enable = true,
disable = function(lang, buf)
disable = function(_, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
@ -303,7 +258,9 @@ return {
}
}
}
}
require 'nvim-treesitter.configs'.setup(treesitter_opt)
end
},
},