Nvim: improve pager mode and other fixes
parent
d78c0ae77d
commit
16cde14ddd
@ -0,0 +1,5 @@
|
||||
function MapKey(mode, keybind, command, opts)
|
||||
local options = {noremap = true}
|
||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||
vim.api.nvim_set_keymap(mode, keybind, command, options)
|
||||
end
|
@ -1,27 +1,23 @@
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
local options = {noremap = true}
|
||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
end
|
||||
require 'common'
|
||||
|
||||
-- Open/close tree browser
|
||||
map('n', '<C-Tab>', '<cmd>NvimTreeToggle<CR>')
|
||||
MapKey('n', '<C-Tab>', '<cmd>NvimTreeToggle<CR>')
|
||||
|
||||
-- Telescope
|
||||
map('n', '<C-f>', '<cmd>Telescope find_files find_command=fd,-Ht,f<CR>')
|
||||
map('n', '<C-g>', '<cmd>Telescope live_grep<CR>')
|
||||
MapKey('n', '<C-f>', '<cmd>Telescope find_files find_command=fd,-Ht,f<CR>')
|
||||
MapKey('n', '<C-g>', '<cmd>Telescope live_grep<CR>')
|
||||
|
||||
-- Completion
|
||||
-- Navigate completions with tab and shift tab
|
||||
map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
|
||||
map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
|
||||
MapKey('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
|
||||
MapKey('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
|
||||
|
||||
-- Navigate between buffers
|
||||
map('n', '<C-N>', ':bn<CR>', {silent = true})
|
||||
map('n', '<C-B>', ':bp<CR>', {silent = true})
|
||||
MapKey('n', '<C-N>', ':bn<CR>', {silent = true})
|
||||
MapKey('n', '<C-B>', ':bp<CR>', {silent = true})
|
||||
|
||||
-- Navigate between splits
|
||||
map('n', '<C-H>', '<C-W><C-H>')
|
||||
map('n', '<C-J>', '<C-W><C-J>')
|
||||
map('n', '<C-K>', '<C-W><C-K>')
|
||||
map('n', '<C-L>', '<C-W><C-L>')
|
||||
MapKey('n', '<C-H>', '<C-W><C-H>')
|
||||
MapKey('n', '<C-J>', '<C-W><C-J>')
|
||||
MapKey('n', '<C-K>', '<C-W><C-K>')
|
||||
MapKey('n', '<C-L>', '<C-W><C-L>')
|
||||
|
@ -0,0 +1,5 @@
|
||||
-- Settings for pager mode
|
||||
require 'common'
|
||||
|
||||
MapKey('n', 'q', '<cmd>q<CR>')
|
||||
--vim.cmd('set nomodifiable')
|
Loading…
Reference in New Issue