nvim: luasnip, ...
This commit is contained in:
parent
e6b3ac25dd
commit
a0ffbd58b3
9 changed files with 61 additions and 32 deletions
|
@ -15,11 +15,11 @@ vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
vim.g.loaded_netrwPlugin = true
|
vim.g.loaded_netrwPlugin = true
|
||||||
|
|
||||||
|
require('configs.options').setup()
|
||||||
require('lazy').setup('configs.packages', {
|
require('lazy').setup('configs.packages', {
|
||||||
install = { colorscheme = { 'gruvbox' }, },
|
install = { colorscheme = { 'gruvbox' }, },
|
||||||
-- rtp = { disabled_plugins = { 'netrwPlugin' } },
|
-- rtp = { disabled_plugins = { 'netrwPlugin' } },
|
||||||
})
|
})
|
||||||
|
|
||||||
require('configs.options').setup()
|
|
||||||
require('configs.misc').setup()
|
require('configs.misc').setup()
|
||||||
require('configs.keys').setup()
|
require('configs.keys').setup()
|
||||||
|
|
|
@ -37,11 +37,19 @@ vim.api.nvim_create_autocmd('TermOpen', {
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
-- Buffer {{{
|
-- Buffer {{{
|
||||||
vim.cmd([[
|
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { command = "checktime" })
|
||||||
augroup forceRecheck
|
|
||||||
au FocusGained,BufEnter * :silent! !
|
-- go to last loc when opening a buffer
|
||||||
augroup END
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||||
]])
|
callback = function()
|
||||||
|
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
||||||
|
local lcount = vim.api.nvim_buf_line_count(0)
|
||||||
|
if mark[1] > 0 and mark[1] <= lcount then
|
||||||
|
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- qf {{{
|
-- qf {{{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
return {
|
return {
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
config = {
|
opts = {
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
local gs = package.loaded.gitsigns
|
local gs = package.loaded.gitsigns
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ local M = {
|
||||||
'b0o/schemastore.nvim',
|
'b0o/schemastore.nvim',
|
||||||
'SmiteshP/nvim-navic',
|
'SmiteshP/nvim-navic',
|
||||||
{ 'j-hui/fidget.nvim', config = true },
|
{ 'j-hui/fidget.nvim', config = true },
|
||||||
{ 'ray-x/lsp_signature.nvim' },
|
'ray-x/lsp_signature.nvim',
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{ '<Space>li', '<Cmd>LspInfo<CR>', desc = 'Lsp info' },
|
{ '<Space>li', '<Cmd>LspInfo<CR>', desc = 'Lsp info' },
|
||||||
|
@ -172,9 +173,10 @@ function M.config()
|
||||||
}
|
}
|
||||||
|
|
||||||
require 'lspconfig'.omnisharp.setup {
|
require 'lspconfig'.omnisharp.setup {
|
||||||
cmd = { '/usr/bin/omnisharp', '--languageserver', '--hostPID', tostring(pid) },
|
cmd = { '/usr/bin/omnisharp' },
|
||||||
-- on_attach = M.on_attach,
|
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
enable_roslyn_analyzers = true,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require 'lspconfig'.powershell_es.setup {
|
require 'lspconfig'.powershell_es.setup {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
local M = {
|
local M = {
|
||||||
'hoob3rt/lualine.nvim',
|
'hoob3rt/lualine.nvim',
|
||||||
|
event = 'VeryLazy',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'kyazdani42/nvim-web-devicons'
|
'kyazdani42/nvim-web-devicons'
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
|
|
22
dot_config/nvim/lua/configs/packages/luasnip.lua
Normal file
22
dot_config/nvim/lua/configs/packages/luasnip.lua
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
return {
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
config = function() require('luasnip.loaders.from_vscode').lazy_load() end,
|
||||||
|
dependencies = {
|
||||||
|
'rafamadriz/friendly-snippets'
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
'<tab>',
|
||||||
|
function()
|
||||||
|
return require('luasnip').jumpable(1) and '<Plug>luasnip-jump-next' or '<tab>'
|
||||||
|
end,
|
||||||
|
expr = true, remap = true, silent = true, mode = 'i',
|
||||||
|
},
|
||||||
|
{ '<tab>', function() require('luasnip').jump(1) end, mode = 's' },
|
||||||
|
{ '<s-tab>', function() require('luasnip').jump(-1) end, mode = { 'i', 's' } },
|
||||||
|
-- { '<C-E>',
|
||||||
|
-- function() return require('luasnip').choice_active() and '<Plug>luasnip-next-choice' or '<C-E>' end,
|
||||||
|
-- mode = 'i', remap = true, expr = true,
|
||||||
|
-- },
|
||||||
|
},
|
||||||
|
}
|
|
@ -10,18 +10,6 @@ return {
|
||||||
config = true,
|
config = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
'hrsh7th/vim-vsnip',
|
|
||||||
config = function()
|
|
||||||
vim.api.nvim_exec([[
|
|
||||||
imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
|
|
||||||
smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
|
|
||||||
imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
|
|
||||||
smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
|
|
||||||
]], false)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
'editorconfig/editorconfig-vim',
|
'editorconfig/editorconfig-vim',
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@ function M.config()
|
||||||
sources = {
|
sources = {
|
||||||
nls.builtins.formatting.xmllint,
|
nls.builtins.formatting.xmllint,
|
||||||
nls.builtins.formatting.jq,
|
nls.builtins.formatting.jq,
|
||||||
|
nls.builtins.formatting.clang_format,
|
||||||
nls.builtins.diagnostics.sqlfluff,
|
nls.builtins.diagnostics.sqlfluff,
|
||||||
nls.builtins.diagnostics.phpstan.with({
|
nls.builtins.diagnostics.phpstan.with({
|
||||||
cwd = function(params)
|
cwd = function(params)
|
||||||
|
|
|
@ -5,13 +5,14 @@ local M = {
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
'hrsh7th/cmp-buffer',
|
'hrsh7th/cmp-buffer',
|
||||||
'hrsh7th/cmp-path',
|
'hrsh7th/cmp-path',
|
||||||
'hrsh7th/cmp-vsnip',
|
|
||||||
'onsails/lspkind.nvim',
|
'onsails/lspkind.nvim',
|
||||||
|
'saadparwaiz1/cmp_luasnip',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
function M.opts()
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
|
local kind_func = require('lspkind').cmp_format({})
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
-- documentation = true,
|
-- documentation = true,
|
||||||
|
@ -20,25 +21,31 @@ function M.config()
|
||||||
{ name = 'nvim_lua' },
|
{ name = 'nvim_lua' },
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
{ name = 'vsnip' },
|
{ name = 'luasnip' },
|
||||||
-- { name = 'nvim_lsp_signature_help' },
|
-- { name = 'nvim_lsp_signature_help' },
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
format = require('lspkind').cmp_format({
|
format = function(entry, vim_item)
|
||||||
-- mode = 'symbol',
|
local modif = kind_func(entry, vim_item)
|
||||||
}),
|
-- folders don't exist on UNIX!
|
||||||
|
modif.kind = string.gsub(modif.kind, 'Folder', 'Directory')
|
||||||
|
return modif
|
||||||
|
end
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
-- completion = cmp.config.window.bordered(),
|
-- completion = cmp.config.window.bordered(),
|
||||||
-- documentation = cmp.config.window.bordered(),
|
-- documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete({}),
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = false })
|
['<CR>'] = cmp.mapping.confirm({ select = false })
|
||||||
}),
|
}),
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
-- For `vsnip` user.
|
require('luasnip').lsp_expand(args.body)
|
||||||
vim.fn['vsnip#anonymous'](args.body) -- For `vsnip` user.
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue