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
|
-- Treesitter
|
||||||
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', }
|
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', }
|
||||||
use 'nvim-treesitter/nvim-treesitter-refactor' -- refactoring / renaming
|
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
|
-- LSP
|
||||||
use {'neovim/nvim-lspconfig'}
|
use {'neovim/nvim-lspconfig'}
|
||||||
@ -285,6 +285,7 @@ require('lspconfig').lua_ls.setup({
|
|||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
-- require('lsp-zero').cmp_action()
|
-- require('lsp-zero').cmp_action()
|
||||||
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
sources = {
|
sources = {
|
||||||
@ -299,6 +300,25 @@ cmp.setup({
|
|||||||
documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
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-k>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||||
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
|
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
|
||||||
['<C-n>'] = cmp.mapping.complete(),
|
['<C-n>'] = cmp.mapping.complete(),
|
||||||
@ -428,20 +448,19 @@ require('telescope').load_extension("noice")
|
|||||||
-- Luasnip {{{
|
-- Luasnip {{{
|
||||||
-- load friendly snippet
|
-- load friendly snippet
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
local ls = require("luasnip")
|
local snippet = luasnip.snippet
|
||||||
local snippet = ls.snippet
|
local text = luasnip.text_node
|
||||||
local text = ls.text_node
|
local insert = luasnip.insert_node
|
||||||
local insert = ls.insert_node
|
local func = luasnip.function_node
|
||||||
local func = ls.function_node
|
|
||||||
|
|
||||||
ls.setup({})
|
luasnip.setup({})
|
||||||
|
|
||||||
-- Functions {{{
|
-- Functions {{{
|
||||||
local date = function() return {os.date('%Y-%m-%d')} end
|
local date = function() return {os.date('%Y-%m-%d')} end
|
||||||
local filename = function() return debug.getinfo(1, 'S').source end
|
local filename = function() return debug.getinfo(1, 'S').source end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- Zola {{{
|
-- Zola {{{
|
||||||
ls.add_snippets("markdown", {
|
luasnip.add_snippets("markdown", {
|
||||||
snippet("zh", {
|
snippet("zh", {
|
||||||
text("+++"),
|
text("+++"),
|
||||||
text("title = \""), func (filename, {}), text("\""),
|
text("title = \""), func (filename, {}), text("\""),
|
||||||
|
Reference in New Issue
Block a user