Nvim: improve pager mode and other fixes

This commit is contained in:
Marko Korhonen 2021-12-04 11:43:26 +02:00
parent d78c0ae77d
commit 16cde14ddd
6 changed files with 27 additions and 19 deletions

View file

@ -2,6 +2,7 @@ require 'pluginmanager'
require 'autocmd'
require 'keybinds'
require 'settings'
require 'common'
-- Plugin configurations
require 'pluginconf.lualine'

View file

@ -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

View file

@ -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>')

View file

@ -0,0 +1,5 @@
-- Settings for pager mode
require 'common'
MapKey('n', 'q', '<cmd>q<CR>')
--vim.cmd('set nomodifiable')

View file

@ -50,7 +50,7 @@ lsp_installer.on_server_ready(function(server)
local opts = {}
-- Lua specific settings
if server_name == "sumneko_lua" then
if server.name == "sumneko_lua" then
local runtime_path = vim.split(package.path, ';')
opts.settings = {
Lua = {

View file

@ -50,10 +50,11 @@ export DOTREPO="$HOME/git/dotfiles"
# nvim ftw!
export EDITOR=nvim
export PAGER="$EDITOR -R"
export PAGER="$EDITOR -R +\"lua require 'pager'\""
export GIT_PAGER="$EDITOR -R +\"lua require 'pager'\" \"Git log\""
export PARU_PAGER="$PAGER -c 'set ft=PKGBUILD'"
export AUR_PAGER=$PAGER
export MANPAGER="$EDITOR +Man!"
export MANPAGER="$EDITOR +\"lua require 'pager'\" +Man!"
# Use GPG for SSH authentication
export GPG_TTY="$(tty)"