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

View File

@ -1,41 +1,41 @@
return { return {
'kyazdani42/nvim-web-devicons', "nvim-tree/nvim-tree.lua",
{ dependencies = {
"nvim-tree/nvim-tree.lua", 'kyazdani42/nvim-web-devicons'
keys = { },
"<c-e>" keys = {
}, "<c-e>"
config = function () },
config = function()
require'nvim-tree'.setup { require 'nvim-web-devicons'.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)
-- override a default require 'nvim-tree'.setup {
G.map({ sort_by = "case_sensitive",
{'n', 'v', api.node.open.vertical, {buffer = bufnr}}, view = {
{'n', 's', api.node.open.horizontal, {buffer = bufnr}}, 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({ -- override a default
{'n', '<C-e>', { buffer = bufnr }}, G.map({
{'n', '<C-v>', { buffer = bufnr }}, { 'n', 'v', api.node.open.vertical, { buffer = bufnr } },
{'n', '<C-x>', { buffer = bufnr }}, { 'n', 's', api.node.open.horizontal, { buffer = bufnr } },
}) })
end G.delmap({
} { 'n', '<C-e>', { buffer = bufnr } },
G.map({ { 'n', '<C-v>', { buffer = bufnr } },
{"n", "<C-e>", ":NvimTreeToggle<CR>", { noremap = true }}, { 'n', '<C-x>', { buffer = bufnr } },
}) })
end end
} }
G.map({
{ "n", "<C-e>", ":NvimTreeToggle<CR>", { noremap = true } },
})
end
} }