completion: add completion for text in the buffer
- Adds completion capabilities for text (in the current buffer), with the help of `cmp-buffer`). - Set the keyword_length to 4 in order to lighten the buffer completion. - Supports non ASCII chars in text completion (cmp-buffer). - Restore the luasnip configuration inside the nvim-cmp configuration, as it is indeed closely related. I didn't understood it in the first place. - Add a markdown snippet to add a tags line in my incremental notes (journal). - Expand the French dictionnary. Co-Authored-by: iGor milhit <igor@milhit.ch>main
parent
054c4defa5
commit
983dfae04c
16
init.lua
16
init.lua
|
@ -106,6 +106,9 @@ require('lazy').setup({
|
|||
-- Adds LSP completion capabilities
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
|
||||
-- Adds completion capabilities for text in buffers
|
||||
'hrsh7th/cmp-buffer',
|
||||
|
||||
-- Adds path completion capabilities
|
||||
'hrsh7th/cmp-path',
|
||||
|
||||
|
@ -531,7 +534,7 @@ mason_lspconfig.setup_handlers {
|
|||
end,
|
||||
}
|
||||
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
-- [[ Configure nvim-cmp, and LuaSnip ]]
|
||||
-- See `:help cmp`
|
||||
local cmp = require 'cmp'
|
||||
local luasnip = require 'luasnip'
|
||||
|
@ -548,6 +551,10 @@ luasnip.config.setup {
|
|||
-- Load snippets from ~/.config/nvim/LuaSnip/
|
||||
require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"})
|
||||
|
||||
-- Keymap to reload snippets
|
||||
-- https://www.ejmastnak.com/tutorials/vim-latex/luasnip/#refreshing-snippets-from-a-separate-vim-instance
|
||||
vim.keymap.set('n', '<Leader>L', '<Cmd>lua require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"})<CR>', { desc = 'Reload [L]uaSnippets' })
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
@ -585,6 +592,13 @@ cmp.setup {
|
|||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{
|
||||
name = 'buffer',
|
||||
option = {
|
||||
keyword_length = 4,
|
||||
keyword_pattern = [[\k\+]],
|
||||
},
|
||||
},
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
|
|
|
@ -147,5 +147,20 @@ return {
|
|||
},
|
||||
{ repeat_duplicates = true }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{
|
||||
trig = "tags",
|
||||
name = "Tags",
|
||||
dscr = "Insert a one-line tags array, in a text file (markdown)."
|
||||
},
|
||||
fmt(
|
||||
[[
|
||||
tags: [{}]
|
||||
]],
|
||||
{
|
||||
i(1, "tags")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue