added bach nvim-cmp
This commit is contained in:
@@ -11,8 +11,8 @@ vim.opt.hlsearch = false
|
|||||||
vim.opt.incsearch = true
|
vim.opt.incsearch = true
|
||||||
vim.opt.scrolloff = 8
|
vim.opt.scrolloff = 8
|
||||||
|
|
||||||
vim.o.exrc = true -- Enable local project configuration files
|
vim.o.exrc = true -- Enable local project configuration files
|
||||||
vim.o.secure = true -- Disable potentially unsafe commands in .nvimrc
|
vim.o.secure = true -- Disable potentially unsafe commands in .nvimrc
|
||||||
|
|
||||||
vim.cmd [[
|
vim.cmd [[
|
||||||
set clipboard=unnamedplus
|
set clipboard=unnamedplus
|
||||||
@@ -227,112 +227,141 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
require'lazy'.setup(
|
require'lazy'.setup{
|
||||||
{
|
{ 'justinmk/vim-sneak', },
|
||||||
{ 'justinmk/vim-sneak', },
|
{ 'michaeljsmith/vim-indent-object', },
|
||||||
{ 'michaeljsmith/vim-indent-object', },
|
{ 'kylechui/nvim-surround',
|
||||||
{ 'kylechui/nvim-surround',
|
version = '*', -- Use for stability; omit to use `main` branch for the latest features
|
||||||
version = '*', -- Use for stability; omit to use `main` branch for the latest features
|
event = 'VeryLazy',
|
||||||
event = 'VeryLazy',
|
config = function()
|
||||||
config = function()
|
require('nvim-surround').setup{}
|
||||||
require('nvim-surround').setup{}
|
end
|
||||||
end
|
},
|
||||||
},
|
{ 'sainnhe/everforest',
|
||||||
{ 'sainnhe/everforest',
|
lazy = false,
|
||||||
lazy = false,
|
priority = 1000,
|
||||||
priority = 1000,
|
config = function()
|
||||||
config = function()
|
vim.o.termguicolors = true
|
||||||
vim.o.termguicolors = true
|
vim.g.everforest_enable_italic = true
|
||||||
vim.g.everforest_enable_italic = true
|
vim.cmd.colorscheme('everforest')
|
||||||
vim.cmd.colorscheme('everforest')
|
end,
|
||||||
end,
|
},
|
||||||
},
|
{ 'folke/zen-mode.nvim',
|
||||||
{ 'folke/zen-mode.nvim',
|
config = function ()
|
||||||
config = function ()
|
vim.keymap.set(
|
||||||
vim.keymap.set(
|
'n',
|
||||||
'n',
|
",z",
|
||||||
",z",
|
vim.cmd.ZenMode,
|
||||||
vim.cmd.ZenMode,
|
{ silent = true }
|
||||||
{ silent = true }
|
)
|
||||||
)
|
end
|
||||||
end
|
},
|
||||||
},
|
{ 'stevearc/oil.nvim',
|
||||||
{ 'stevearc/oil.nvim',
|
dependencies = { 'nvim-tree/nvim-web-devicons', },
|
||||||
dependencies = { 'nvim-tree/nvim-web-devicons', },
|
config = function ()
|
||||||
config = function ()
|
local oil = require('oil')
|
||||||
local oil = require('oil')
|
oil.setup{
|
||||||
oil.setup{
|
default_file_explorer = true,
|
||||||
default_file_explorer = true,
|
columns = {'icon'},
|
||||||
columns = {'icon'},
|
view_options = {
|
||||||
view_options = {
|
show_hidden = true,
|
||||||
show_hidden = true,
|
},
|
||||||
},
|
}
|
||||||
}
|
vim.keymap.set("n", "-", vim.cmd.Oil, { desc = "Open parent directory" })
|
||||||
vim.keymap.set("n", "-", vim.cmd.Oil, { desc = "Open parent directory" })
|
end,
|
||||||
end,
|
},
|
||||||
},
|
{ 'nvim-telescope/telescope.nvim',
|
||||||
{ 'nvim-telescope/telescope.nvim',
|
tag = '0.1.8',
|
||||||
tag = '0.1.8',
|
dependencies = { 'nvim-lua/plenary.nvim', },
|
||||||
dependencies = { 'nvim-lua/plenary.nvim', },
|
config = function()
|
||||||
config = function()
|
vim.cmd [[
|
||||||
vim.cmd [[
|
noremap ,ff :lua require'telescope.builtin'.find_files()<CR>
|
||||||
noremap ,ff :lua require'telescope.builtin'.find_files()<CR>
|
noremap ,fo :lua require'telescope.builtin'.oldfiles()<CR>
|
||||||
noremap ,fo :lua require'telescope.builtin'.oldfiles()<CR>
|
noremap ,fg :lua require'telescope.builtin'.live_grep()<CR>
|
||||||
noremap ,fg :lua require'telescope.builtin'.live_grep()<CR>
|
noremap ,fz :lua require'telescope.builtin'.current_buffer_fuzzy_find()<CR>
|
||||||
noremap ,fz :lua require'telescope.builtin'.current_buffer_fuzzy_find()<CR>
|
noremap ,fh :lua require'telescope.builtin'.help_tags()<CR>
|
||||||
noremap ,fh :lua require'telescope.builtin'.help_tags()<CR>
|
noremap ,fm :lua require'telescope.builtin'.man_pages()<CR>
|
||||||
noremap ,fm :lua require'telescope.builtin'.man_pages()<CR>
|
]]
|
||||||
]]
|
end,
|
||||||
end,
|
},
|
||||||
},
|
{ 'neovim/nvim-lspconfig',
|
||||||
{ 'neovim/nvim-lspconfig',
|
config = function()
|
||||||
config = function()
|
require'lspconfig'.gopls.setup{}
|
||||||
require'lspconfig'.gopls.setup{}
|
require'lspconfig'.rust_analyzer.setup{}
|
||||||
require'lspconfig'.rust_analyzer.setup{}
|
vim.cmd [[
|
||||||
vim.cmd [[
|
noremap ,rn :lua vim.lsp.buf.rename()<CR>
|
||||||
noremap ,rn :lua vim.lsp.buf.rename()<CR>
|
noremap ,fd :lua vim.lsp.buf.definition()<CR>
|
||||||
noremap ,fd :lua vim.lsp.buf.definition()<CR>
|
noremap ,ft :lua vim.lsp.buf.type_definition()<CR>
|
||||||
noremap ,ft :lua vim.lsp.buf.type_definition()<CR>
|
noremap ,fr :lua vim.lsp.buf.references()<CR>
|
||||||
noremap ,fr :lua vim.lsp.buf.references()<CR>
|
noremap ,ca :lua vim.lsp.buf.code_action()<CR>
|
||||||
noremap ,ca :lua vim.lsp.buf.code_action()<CR>
|
noremap ,oe :lua vim.diagnostic.open_float()<CR>
|
||||||
noremap ,oe :lua vim.diagnostic.open_float()<CR>
|
noremap ,fe :lua vim.diagnostic.setqflist()<CR>
|
||||||
noremap ,fe :lua vim.diagnostic.setqflist()<CR>
|
]]
|
||||||
]]
|
end
|
||||||
end
|
},
|
||||||
},
|
{ 'dcampos/nvim-snippy',
|
||||||
{ 'dcampos/nvim-snippy',
|
config = function()
|
||||||
config = function()
|
require'snippy'.setup{ enable_auto = true, }
|
||||||
require'snippy'.setup{ enable_auto = true, }
|
vim.cmd [[
|
||||||
vim.cmd [[
|
imap <expr> <c-l> '<Plug>(snippy-next)'
|
||||||
imap <expr> <c-l> '<Plug>(snippy-expand-or-advance)'
|
imap <expr> <c-k> '<Plug>(snippy-previous)'
|
||||||
imap <expr> <c-k> '<Plug>(snippy-previous)'
|
smap <expr> <c-l> '<Plug>(snippy-next)'
|
||||||
smap <expr> <c-l> '<Plug>(snippy-next)'
|
smap <expr> <c-k> '<Plug>(snippy-previous)'
|
||||||
smap <expr> <c-k> '<Plug>(snippy-previous)'
|
xmap <Tab> <Plug>(snippy-cut-text)
|
||||||
xmap <Tab> <Plug>(snippy-cut-text)
|
]]
|
||||||
]]
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
'S',
|
'S',
|
||||||
function ()
|
function ()
|
||||||
---@type string
|
---@type string
|
||||||
local snippets_path = vim.fn.stdpath('config') .. '/snippets/' .. vim.api.nvim_buf_get_option(0, "filetype") .. '.snippets'
|
local snippets_path = vim.fn.stdpath('config') .. '/snippets/' .. vim.api.nvim_buf_get_option(0, "filetype") .. '.snippets'
|
||||||
|
|
||||||
if not file_exists(snippets_path) then
|
if not file_exists(snippets_path) then
|
||||||
local file = io.open( snippets_path, 'w' )
|
local file = io.open( snippets_path, 'w' )
|
||||||
assert(
|
assert(
|
||||||
file ~= nil,
|
file ~= nil,
|
||||||
("io.open('%s', 'w') returned nil.\n"):format(snippets_path) ..
|
("io.open('%s', 'w') returned nil.\n"):format(snippets_path) ..
|
||||||
"Make sure the snippets folder in the above path exists."
|
"Make sure the snippets folder in the above path exists."
|
||||||
)
|
)
|
||||||
file:close()
|
file:close()
|
||||||
print('created file: ', snippets_path)
|
print('created file: ', snippets_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_command(('SnippyEdit %s'):format(snippets_path))
|
vim.api.nvim_command(('SnippyEdit %s'):format(snippets_path))
|
||||||
|
end,
|
||||||
|
{ nargs = 0 }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{ 'hrsh7th/nvim-cmp',
|
||||||
|
dependencies = {
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
'hrsh7th/cmp-buffer',
|
||||||
|
'hrsh7th/cmp-path',
|
||||||
|
'dcampos/nvim-snippy',
|
||||||
|
'dcampos/cmp-snippy',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require'cmp'
|
||||||
|
cmp.setup{
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require'snippy'.expand_snippet(args.body)
|
||||||
end,
|
end,
|
||||||
{ nargs = 0 }
|
},
|
||||||
)
|
mapping = {
|
||||||
end
|
['<C-y>'] = cmp.mapping.confirm{ select = true },
|
||||||
},
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
}
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
)
|
},
|
||||||
|
sources = cmp.config.sources{
|
||||||
|
{ name = 'snippy' },
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
{ name = 'path' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user