nvim: better tabs
This commit is contained in:
parent
9657585534
commit
fe0166970e
|
@ -1,9 +1,10 @@
|
|||
local indent = require 'config.keymaps.indent'
|
||||
local map = require 'config.helpers.keymap'
|
||||
local n = map 'n'
|
||||
local v = map 'v'
|
||||
local t = map 't'
|
||||
local nv = map {'n', 'v'}
|
||||
local map = require 'config.helpers.keymap'
|
||||
local n = map 'n'
|
||||
local i = map 'i'
|
||||
local v = map 'v'
|
||||
local t = map 't'
|
||||
local nv = map { 'n', 'v' }
|
||||
|
||||
|
||||
|
||||
|
@ -21,13 +22,12 @@ n '<C-j>' '<C-w>j' 'Window: move down'
|
|||
n '<C-k>' '<C-w>k' 'Window: move up'
|
||||
n '<C-l>' '<C-w>l' 'Window: move right'
|
||||
|
||||
|
||||
-- Indentation
|
||||
i '<Tab>' (indent.smart_tab) { 'Indent', expr = true }
|
||||
v '>' '>gv' 'Indent right'
|
||||
v '<' '<gv' 'Indent left'
|
||||
v '|' (indent.normalize) 'Indent normalize'
|
||||
|
||||
|
||||
-- Diagnostics
|
||||
n '<leader>e' (vim.diagnostic.open_float) 'Open error diagnostics'
|
||||
n '[d' (vim.diagnostic.goto_prev) 'Previous diagnostic message'
|
||||
|
|
|
@ -2,6 +2,15 @@ local get_visual = require 'config.helpers.visual'
|
|||
local M = {}
|
||||
|
||||
|
||||
function M.smarttab()
|
||||
local col = vim.fn.col '.'
|
||||
if col == 1 or vim.fn.getline('.'):sub(1, col - 1):match '^%s*$' then
|
||||
return '\t'
|
||||
else
|
||||
return string.rep(' ', vim.bo.tabstop or 2)
|
||||
end
|
||||
end
|
||||
|
||||
function M.normalize()
|
||||
local c = vim.fn.getpos '.'
|
||||
local s = get_visual()
|
||||
|
|
Loading…
Reference in a new issue