update
This commit is contained in:
parent
1798c57e08
commit
5eaf966f21
@ -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 {
|
return {
|
||||||
{
|
{
|
||||||
-- lsp的config
|
-- lsp的config
|
||||||
@ -65,7 +34,11 @@ return {
|
|||||||
{
|
{
|
||||||
-- lsp
|
-- lsp
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
dependencies = {
|
||||||
|
"williamboman/mason.nvim", -- lsp 下载器
|
||||||
|
},
|
||||||
config = function()
|
config = function()
|
||||||
|
require "mason".setup {}
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"clangd",
|
"clangd",
|
||||||
@ -80,13 +53,6 @@ return {
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
|
||||||
-- lsp 下载器
|
|
||||||
"williamboman/mason.nvim",
|
|
||||||
config = function()
|
|
||||||
require "mason".setup {}
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{ --
|
{ --
|
||||||
'simrat39/symbols-outline.nvim',
|
'simrat39/symbols-outline.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
@ -165,21 +131,15 @@ return {
|
|||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
|
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
|
||||||
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
|
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
|
||||||
'hrsh7th/cmp-path', -- { name = 'path' }
|
'hrsh7th/cmp-path', -- { name = 'path' }
|
||||||
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
|
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
|
||||||
'hrsh7th/vim-vsnip',
|
'hrsh7th/vim-vsnip',
|
||||||
'hrsh7th/cmp-vsnip',
|
'hrsh7th/cmp-vsnip',
|
||||||
'onsails/lspkind-nvim',
|
'onsails/lspkind-nvim',
|
||||||
},
|
},
|
||||||
config = function()
|
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()
|
local has_words_before = function()
|
||||||
unpack = unpack or table.unpack
|
unpack = unpack or table.unpack
|
||||||
@ -190,22 +150,20 @@ return {
|
|||||||
local feedkey = function(key, mode)
|
local feedkey = function(key, mode)
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
-- local lspkind = require('lspkind')
|
local cmp_opt = {
|
||||||
cmp.setup {
|
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'vnsip' },
|
||||||
|
},
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
{ name = 'path' },
|
{ name = 'path' }
|
||||||
{ name = 'vnsip' },
|
),
|
||||||
-- { name = 'cmdline' },
|
|
||||||
}),
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
|
||||||
["<CR>"] = cmp.mapping({
|
["<CR>"] = cmp.mapping({
|
||||||
@ -240,6 +198,7 @@ return {
|
|||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
window = {
|
window = {
|
||||||
completion = {
|
completion = {
|
||||||
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
||||||
@ -255,22 +214,18 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
fomatting = {
|
formatting = {
|
||||||
fields = { "kind", "abbr", "menu" },
|
fields = { "kind", "abbr", "menu" },
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
local kind = require("lspkind").cmp_format({
|
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 5, })(entry, vim_item)
|
||||||
mode = "symbol_text",
|
|
||||||
maxwidth = 50,
|
|
||||||
})(entry, vim_item)
|
|
||||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||||
kind.kind = kind_icons[vim_item.kind]
|
|
||||||
kind.kind = " " .. (strings[1] or "") .. " "
|
kind.kind = " " .. (strings[1] or "") .. " "
|
||||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||||
|
|
||||||
return kind
|
return kind
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
require('cmp').setup(cmp_opt)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -278,14 +233,14 @@ return {
|
|||||||
-- 语法高亮 --
|
-- 语法高亮 --
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
config = function()
|
config = function()
|
||||||
require 'nvim-treesitter.configs'.setup {
|
local treesitter_opt = {
|
||||||
ensure_installed = {},
|
ensure_installed = {},
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
disable = function(lang, buf)
|
disable = function(_, buf)
|
||||||
local max_filesize = 100 * 1024 -- 100 KB
|
local max_filesize = 100 * 1024 -- 100 KB
|
||||||
local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf))
|
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
|
if ok and stats and stats.size > max_filesize then
|
||||||
@ -303,7 +258,9 @@ return {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
require 'nvim-treesitter.configs'.setup(treesitter_opt)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user