nvim: better tabs
This commit is contained in:
parent
9657585534
commit
fe0166970e
|
@ -1,6 +1,7 @@
|
||||||
local indent = require 'config.keymaps.indent'
|
local indent = require 'config.keymaps.indent'
|
||||||
local map = require 'config.helpers.keymap'
|
local map = require 'config.helpers.keymap'
|
||||||
local n = map 'n'
|
local n = map 'n'
|
||||||
|
local i = map 'i'
|
||||||
local v = map 'v'
|
local v = map 'v'
|
||||||
local t = map 't'
|
local t = map 't'
|
||||||
local nv = map { 'n', 'v' }
|
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-k>' '<C-w>k' 'Window: move up'
|
||||||
n '<C-l>' '<C-w>l' 'Window: move right'
|
n '<C-l>' '<C-w>l' 'Window: move right'
|
||||||
|
|
||||||
|
|
||||||
-- Indentation
|
-- Indentation
|
||||||
|
i '<Tab>' (indent.smart_tab) { 'Indent', expr = true }
|
||||||
v '>' '>gv' 'Indent right'
|
v '>' '>gv' 'Indent right'
|
||||||
v '<' '<gv' 'Indent left'
|
v '<' '<gv' 'Indent left'
|
||||||
v '|' (indent.normalize) 'Indent normalize'
|
v '|' (indent.normalize) 'Indent normalize'
|
||||||
|
|
||||||
|
|
||||||
-- Diagnostics
|
-- Diagnostics
|
||||||
n '<leader>e' (vim.diagnostic.open_float) 'Open error diagnostics'
|
n '<leader>e' (vim.diagnostic.open_float) 'Open error diagnostics'
|
||||||
n '[d' (vim.diagnostic.goto_prev) 'Previous diagnostic message'
|
n '[d' (vim.diagnostic.goto_prev) 'Previous diagnostic message'
|
||||||
|
|
|
@ -2,6 +2,15 @@ local get_visual = require 'config.helpers.visual'
|
||||||
local M = {}
|
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()
|
function M.normalize()
|
||||||
local c = vim.fn.getpos '.'
|
local c = vim.fn.getpos '.'
|
||||||
local s = get_visual()
|
local s = get_visual()
|
||||||
|
|
Loading…
Reference in a new issue