This commit is contained in:
newbie 2024-01-03 14:50:03 +08:00
parent ca0520cd1e
commit 3d02627fcb
2 changed files with 71 additions and 55 deletions

View File

@ -27,21 +27,18 @@ local kind_icons = {
}
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
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
return {
{
-- lsp的config
"neovim/nvim-lspconfig",
dependencies = {
"folke/neodev.nvim",
},
config = function()
require 'neodev'.setup {}
require 'lspconfig'.lua_ls.setup(require('lsp.lua'))
require 'lspconfig'.clangd.setup(require('lsp.c'))
require 'lspconfig'.bashls.setup(require('lsp.bash'))
@ -49,6 +46,7 @@ return {
require 'lspconfig'.jsonls.setup {}
require 'lspconfig'.yamlls.setup(require('lsp.yaml'))
G.map({
{ 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>' },
@ -61,7 +59,6 @@ return {
{ 'n', '<cs-i>', '<cmd>lua vim.lsp.buf.format()<CR>' },
})
end
},
@ -87,7 +84,7 @@ return {
-- lsp 下载器
"williamboman/mason.nvim",
config = function()
require("mason").setup({})
require "mason".setup {}
end
},
{ --
@ -164,16 +161,36 @@ return {
},
{
-- lsp补全
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
'hrsh7th/cmp-path', -- { name = 'path' }
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
'hrsh7th/vim-vsnip',
'hrsh7th/cmp-vsnip',
'onsails/lspkind-nvim',
{
"hrsh7th/nvim-cmp",
dependencies = {
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
'hrsh7th/cmp-path', -- { name = 'path' }
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
'hrsh7th/vim-vsnip',
'hrsh7th/cmp-vsnip',
'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
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
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 {
@ -183,10 +200,10 @@ return {
end,
},
sources = cmp.config.sources({
{ name = 'vnsip' },
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'vnsip' },
-- { name = 'cmdline' },
}),
mapping = cmp.mapping.preset.insert({
@ -251,7 +268,6 @@ return {
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
}
@ -304,7 +320,7 @@ return {
colors = {
path = '#aaffff', -- 路径的颜色,比如#ababab
file_name = '#bbbbff', -- 文件名称的颜色,比如#acacac
symbols = '#aaffaa', -- 函数颜色
symbols = '#aaffaa', -- 函数颜色
},
-- 图标配置

View File

@ -1,41 +1,41 @@
return {
'kyazdani42/nvim-web-devicons',
{
"nvim-tree/nvim-tree.lua",
keys = {
"<c-e>"
},
config = function ()
"nvim-tree/nvim-tree.lua",
dependencies = {
'kyazdani42/nvim-web-devicons'
},
keys = {
"<c-e>"
},
config = function()
require'nvim-tree'.setup {
sort_by = "case_sensitive",
view = {
width = 30,
},
filters = { dotfiles = true, },
git = { enable = true },
on_attach = function (bufnr)
local api = require'nvim-tree.api'
api.config.mappings.default_on_attach(bufnr)
require 'nvim-web-devicons'.setup{}
-- override a default
G.map({
{'n', 'v', api.node.open.vertical, {buffer = bufnr}},
{'n', 's', api.node.open.horizontal, {buffer = bufnr}},
})
require 'nvim-tree'.setup {
sort_by = "case_sensitive",
view = {
width = 30,
},
filters = { dotfiles = true, },
git = { enable = true },
on_attach = function(bufnr)
local api = require 'nvim-tree.api'
api.config.mappings.default_on_attach(bufnr)
G.delmap({
{'n', '<C-e>', { buffer = bufnr }},
{'n', '<C-v>', { buffer = bufnr }},
{'n', '<C-x>', { buffer = bufnr }},
})
-- override a default
G.map({
{ 'n', 'v', api.node.open.vertical, { buffer = bufnr } },
{ 'n', 's', api.node.open.horizontal, { buffer = bufnr } },
})
end
}
G.map({
{"n", "<C-e>", ":NvimTreeToggle<CR>", { noremap = true }},
})
end
}
G.delmap({
{ 'n', '<C-e>', { buffer = bufnr } },
{ 'n', '<C-v>', { buffer = bufnr } },
{ 'n', '<C-x>', { buffer = bufnr } },
})
end
}
G.map({
{ "n", "<C-e>", ":NvimTreeToggle<CR>", { noremap = true } },
})
end
}