setup luasnip better

This commit is contained in:
Citlali del Rey 2023-11-29 16:16:03 -08:00
parent e6896269f8
commit 6d3c813c2b
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
3 changed files with 65 additions and 12 deletions

View File

@ -1,4 +1,5 @@
let g:mapleader = "," let g:mapleader = ","
let g:maplocalleader = ","
lua require('plugins') lua require('plugins')
lua require('lsp') lua require('lsp')
@ -21,9 +22,9 @@ tnoremap <silent> <C-A-l> <Cmd>wincmd l<CR>
" Terminal " Terminal
command Terminal below 15sp term://$SHELL |startinsert command Terminal below 15sp term://$SHELL |startinsert
autocmd TermOpen * set nonu
autocmd BufEnter term://* startinsert autocmd BufEnter term://* startinsert
autocmd BufLeave term://* stopinsert autocmd BufLeave term://* stopinsert
autocmd TermOpen * setlocal nonumber norelativenumber signcolumn=no
nnoremap <silent> <C-A-t> <Cmd>Terminal<CR> nnoremap <silent> <C-A-t> <Cmd>Terminal<CR>
@ -56,7 +57,7 @@ set background=light
set completeopt=menu,menuone,noselect set completeopt=menu,menuone,noselect
set tabstop=4 set tabstop=4
set shiftwidth=0 set shiftwidth=0
set number relativenumber set number relativenumber signcolumn=yes
set mouse=a set mouse=a
set cursorline set cursorline
set noexpandtab set noexpandtab
@ -89,12 +90,12 @@ let g:neovide_floating_blur_amount_x = 2.0
let g:neovide_floating_blur_amount_y = 2.0 let g:neovide_floating_blur_amount_y = 2.0
let g:neovide_floating_opacity = 60 let g:neovide_floating_opacity = 60
set guifont=SFMono\ Nerd\ Font set guifont=0xProto\ Nerd\ Font,Symbols\ Nerd\ Font\ Mono
sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=DiagnosticSignError sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=DiagnosticSignError
sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=DiagnosticSignWarn sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=DiagnosticSignWarn
sign define DiagnosticSignInfo text=texthl=DiagnosticSignInfo linehl= numhl=DiagnosticSignInfo sign define DiagnosticSignInfo text=texthl=DiagnosticSignInfo linehl= numhl=DiagnosticSignInfo
sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl=DiagnosticSignHint sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl=DiagnosticSignHint
" Trouble " Trouble
nnoremap <leader>xx <cmd>TroubleToggle<cr> nnoremap <leader>xx <cmd>TroubleToggle<cr>
@ -109,3 +110,6 @@ nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr> nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr> nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr> nnoremap <leader>fh <cmd>Telescope help_tags<cr>
filetype plugin on
filetype indent on

View File

@ -31,7 +31,7 @@ local on_attach = function(client, bufnr)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<leader>f', function() vim.keymap.set('n', '<leader>fm', function()
vim.lsp.buf.format({ async = true }) vim.lsp.buf.format({ async = true })
end, bufopts) end, bufopts)
@ -61,7 +61,12 @@ local cmp = require('cmp')
local luasnip = require('luasnip') local luasnip = require('luasnip')
local lspkind = require('lspkind') local lspkind = require('lspkind')
cmp.setup({ luasnip.config.set_config {
region_check_events = {'CursorMoved', 'InsertEnter'},
delete_check_events = {'TextChanged', 'InsertLeave'},
}
cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
@ -69,7 +74,7 @@ cmp.setup({
}, },
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-b>'] = cmp.mapping.scroll_docs(-4),
@ -77,6 +82,30 @@ cmp.setup({
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(), ['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<Tab>'] = cmp.mapping(function(fallback)
if luasnip.expandable() then
luasnip.expand()
elseif cmp.visible() then
if #cmp.get_entries() == 1 then
cmp.confirm({ select = true})
else
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
end
elseif luasnip.locally_jumpable() then
luasnip.jump()
else
fallback()
end
end, {"i", "s", "c"}),
['<S-Tab>'] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {"i", "s", "c"}),
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
@ -92,7 +121,7 @@ cmp.setup({
maxwidth = 50, maxwidth = 50,
}), }),
}, },
}) }
cmp.setup.cmdline('/', { cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
@ -133,3 +162,8 @@ mason_lspconfig.setup_handlers {
lspconfig[server_name].setup {} lspconfig[server_name].setup {}
end, end,
} }
-- Load all snippets from the nvim/LuaSnip directory at startup
require("luasnip.loaders.from_lua").load()

View File

@ -151,6 +151,10 @@ require('lualine').setup {
}, },
winbar = { winbar = {
"help", "help",
"terminal",
"TERMINAL",
"fish",
"term",
"startify", "startify",
"dashboard", "dashboard",
"packer", "packer",
@ -176,7 +180,18 @@ require('lualine').setup {
}, },
sections = { sections = {
lualine_a = { 'mode' }, lualine_a = { 'mode' },
lualine_b = { 'diff', 'diagnostics' }, lualine_b = {
'diff',
{
'diagnostics',
symbols = {
error = '',
warn = '',
info = '',
hint = '',
},
},
},
lualine_c = { 'filename' }, lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' }, lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' }, lualine_y = { 'progress' },
@ -203,7 +218,7 @@ require('lualine').setup {
lualine_c = { 'hostname' }, lualine_c = { 'hostname' },
lualine_x = {}, lualine_x = {},
lualine_y = {}, lualine_y = {},
lualine_z = { 'tabs', 'datetime' }, lualine_z = { 'tabs', { 'datetime', style = 'iso' } },
}, },
winbar = { winbar = {
lualine_a = { 'searchcount' }, lualine_a = { 'searchcount' },