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,6 +161,9 @@ return {
}, },
{ {
-- lsp补全 -- lsp补全
{
"hrsh7th/nvim-cmp",
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' }
@ -171,9 +171,26 @@ return {
'hrsh7th/vim-vsnip', 'hrsh7th/vim-vsnip',
'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-vsnip',
'onsails/lspkind-nvim', 'onsails/lspkind-nvim',
{ },
"hrsh7th/nvim-cmp",
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,
}, },
} }

View File

@ -1,12 +1,15 @@
return { return {
'kyazdani42/nvim-web-devicons',
{
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
dependencies = {
'kyazdani42/nvim-web-devicons'
},
keys = { keys = {
"<c-e>" "<c-e>"
}, },
config = function() config = function()
require 'nvim-web-devicons'.setup{}
require 'nvim-tree'.setup { require 'nvim-tree'.setup {
sort_by = "case_sensitive", sort_by = "case_sensitive",
view = { view = {
@ -29,7 +32,6 @@ return {
{ 'n', '<C-v>', { buffer = bufnr } }, { 'n', '<C-v>', { buffer = bufnr } },
{ 'n', '<C-x>', { buffer = bufnr } }, { 'n', '<C-x>', { buffer = bufnr } },
}) })
end end
} }
G.map({ G.map({
@ -37,5 +39,3 @@ return {
}) })
end end
} }
}