Fix #1: use tab for selecting item
This commit is contained in:
parent
a04805595e
commit
e68adac7e8
35
init.lua
35
init.lua
@ -38,7 +38,7 @@ require('packer').startup(function(use)
|
||||
-- Treesitter
|
||||
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', }
|
||||
use 'nvim-treesitter/nvim-treesitter-refactor' -- refactoring / renaming
|
||||
use 'romgrk/nvim-treesitter-context'
|
||||
use 'romgrk/nvim-treesitter-context' -- maintient les entêtes des fonctions pour avoir le contexte d'où on se trouve
|
||||
|
||||
-- LSP
|
||||
use {'neovim/nvim-lspconfig'}
|
||||
@ -285,6 +285,7 @@ require('lspconfig').lua_ls.setup({
|
||||
local cmp = require('cmp')
|
||||
-- require('lsp-zero').cmp_action()
|
||||
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
@ -299,6 +300,25 @@ cmp.setup({
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.complete(),
|
||||
@ -428,20 +448,19 @@ require('telescope').load_extension("noice")
|
||||
-- Luasnip {{{
|
||||
-- load friendly snippet
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
local ls = require("luasnip")
|
||||
local snippet = ls.snippet
|
||||
local text = ls.text_node
|
||||
local insert = ls.insert_node
|
||||
local func = ls.function_node
|
||||
local snippet = luasnip.snippet
|
||||
local text = luasnip.text_node
|
||||
local insert = luasnip.insert_node
|
||||
local func = luasnip.function_node
|
||||
|
||||
ls.setup({})
|
||||
luasnip.setup({})
|
||||
|
||||
-- Functions {{{
|
||||
local date = function() return {os.date('%Y-%m-%d')} end
|
||||
local filename = function() return debug.getinfo(1, 'S').source end
|
||||
-- }}}
|
||||
-- Zola {{{
|
||||
ls.add_snippets("markdown", {
|
||||
luasnip.add_snippets("markdown", {
|
||||
snippet("zh", {
|
||||
text("+++"),
|
||||
text("title = \""), func (filename, {}), text("\""),
|
||||
|
Reference in New Issue
Block a user