2023-11-23 18:39:37 +08:00
|
|
|
|
2023-11-22 12:59:44 +08:00
|
|
|
return {
|
|
|
|
{
|
2023-11-23 18:39:37 +08:00
|
|
|
-- lsp的config
|
2023-11-22 12:59:44 +08:00
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
config = function ()
|
2023-11-23 13:19:07 +08:00
|
|
|
require'lspconfig'.lua_ls.setup(require('lsp.lua'))
|
2023-11-22 12:59:44 +08:00
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2023-11-23 18:39:37 +08:00
|
|
|
-- lsp 下载器
|
2023-11-23 13:19:07 +08:00
|
|
|
"williamboman/mason.nvim",
|
|
|
|
config = function()
|
|
|
|
require("mason").setup({})
|
2023-11-22 12:59:44 +08:00
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2023-11-23 18:39:37 +08:00
|
|
|
-- lsp补全
|
2023-11-22 12:59:44 +08:00
|
|
|
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
|
|
|
|
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
|
|
|
|
'hrsh7th/cmp-path', -- { name = 'path' }
|
|
|
|
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
|
2023-11-23 18:39:37 +08:00
|
|
|
'hrsh7th/vim-vsnip',
|
2023-11-23 13:19:07 +08:00
|
|
|
'hrsh7th/cmp-vsnip',
|
|
|
|
{
|
|
|
|
'onsails/lspkind-nvim',
|
|
|
|
config = function()
|
|
|
|
require('lspkind').init({
|
|
|
|
mode = 'symbol_text',
|
|
|
|
preset = 'codicons',
|
|
|
|
symbol_map = {
|
|
|
|
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 = "",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
},
|
2023-11-22 12:59:44 +08:00
|
|
|
{
|
|
|
|
"hrsh7th/nvim-cmp",
|
2023-11-23 13:19:07 +08:00
|
|
|
config = function()
|
|
|
|
local has_words_before = function()
|
|
|
|
unpack = unpack or table.unpack
|
|
|
|
local line, col = unpack(G.api.nvim_win_get_cursor(0))
|
|
|
|
return col ~= 0 and G.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
|
|
|
|
end
|
2023-11-23 18:39:37 +08:00
|
|
|
local feedkey = function(key, mode)
|
|
|
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
|
|
end
|
2023-11-22 12:59:44 +08:00
|
|
|
local cmp = require('cmp')
|
2023-11-23 13:19:07 +08:00
|
|
|
local lspkind = require('lspkind')
|
2023-11-22 12:59:44 +08:00
|
|
|
cmp.setup {
|
2023-11-23 18:39:37 +08:00
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
|
|
|
end,
|
|
|
|
},
|
2023-11-22 12:59:44 +08:00
|
|
|
sources = cmp.config.sources({
|
2023-11-23 18:39:37 +08:00
|
|
|
{ name = 'vnsip'},
|
2023-11-22 12:59:44 +08:00
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'buffer' },
|
|
|
|
{ name = 'path' },
|
|
|
|
{ name = 'cmdline' },
|
|
|
|
}),
|
2023-11-23 13:19:07 +08:00
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
2023-11-23 18:39:37 +08:00
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
elseif vim.fn["vsnip#available"](1) == 1 then
|
|
|
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
|
|
|
elseif has_words_before() then
|
|
|
|
cmp.complete()
|
|
|
|
else
|
|
|
|
fallback()
|
2023-11-23 13:19:07 +08:00
|
|
|
end
|
2023-11-23 18:39:37 +08:00
|
|
|
end, { "i", "s" }),
|
2023-11-22 12:59:44 +08:00
|
|
|
|
2023-11-23 18:39:37 +08:00
|
|
|
["<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)", "")
|
2023-11-23 13:19:07 +08:00
|
|
|
end
|
2023-11-23 18:39:37 +08:00
|
|
|
end, { "i", "s" }),
|
2023-11-23 13:19:07 +08:00
|
|
|
|
|
|
|
}),
|
|
|
|
window = {
|
|
|
|
completion = {
|
|
|
|
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
|
|
|
col_offset = -3,
|
|
|
|
side_padding = 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
fomatting = {
|
|
|
|
format = lspkind.cmp_format({
|
2023-11-23 18:39:37 +08:00
|
|
|
mode = 'symbol',
|
|
|
|
maxwidth = 50,
|
|
|
|
ellipsis_char = '...',
|
2023-11-23 13:19:07 +08:00
|
|
|
before = function (_, vim_item)
|
|
|
|
return vim_item
|
|
|
|
end
|
|
|
|
})
|
|
|
|
},
|
2023-11-22 12:59:44 +08:00
|
|
|
}
|
|
|
|
end,
|
2023-11-23 18:39:37 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
-- 语法高亮
|
|
|
|
'nvim-treesitter/nvim-treesitter',
|
|
|
|
config = function()
|
|
|
|
require'nvim-treesitter.configs'.setup{
|
|
|
|
-- A list of parser names, or "all" (the four listed parsers should always be installed)
|
|
|
|
ensure_installed = {},
|
|
|
|
|
|
|
|
indent = { enable = true },
|
|
|
|
-- Install parsers synchronously (only applied to `ensure_installed`)
|
|
|
|
sync_install = false,
|
|
|
|
|
|
|
|
-- Automatically install missing parsers when entering buffer
|
|
|
|
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
|
|
|
auto_install = true,
|
|
|
|
|
|
|
|
-- List of parsers to ignore installing (for "all")
|
|
|
|
-- ignore_install = { "javascript" },
|
|
|
|
|
|
|
|
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
|
|
|
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
|
|
|
|
|
|
|
highlight = {
|
|
|
|
-- `false` will disable the whole extension
|
|
|
|
enable = true,
|
|
|
|
|
|
|
|
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
|
|
|
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
|
|
|
-- the name of the parser)
|
|
|
|
-- list of language that will be disabled
|
|
|
|
-- disable = { "c", "rust" },
|
|
|
|
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
|
|
|
|
disable = function(lang, 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
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
|
|
|
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
|
|
|
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
|
|
|
-- Instead of true it can also be a list of languages
|
|
|
|
additional_vim_regex_highlighting = false,
|
|
|
|
},
|
|
|
|
parsers = {
|
|
|
|
html = {
|
|
|
|
install_info = {
|
|
|
|
url = "https://github.com/ikatyang/tree-sitter-vue",
|
|
|
|
files = {"src/parser.c"},
|
|
|
|
branch = "main"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
},
|
2023-11-22 12:59:44 +08:00
|
|
|
}
|
|
|
|
}
|
2023-11-23 13:19:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|