nvim: add nvim configs

This commit is contained in:
inkch
2024-01-14 23:03:03 +09:00
parent 6339cdb490
commit 4446e72a04
19 changed files with 274 additions and 0 deletions

View File

@ -0,0 +1,3 @@
require("utils.zenkaku")
require("utils.trim")
require("utils.setindent")

View File

@ -0,0 +1,10 @@
-- Functions
local setIndentWidth = function(w)
vim.opt.tabstop = w
vim.opt.softtabstop = w
vim.opt.shiftwidth = w
print("Tab width is now set", w)
end
vim.keymap.set('n', '<leader>T2', function() setIndentWidth(2) end)
vim.keymap.set('n', '<leader>T4', function() setIndentWidth(4) end)

View File

@ -0,0 +1,27 @@
-- Trim
vim.cmd([[
command! Trim call TrimSpace()
function! TrimSpace()
let save_cursor = getpos(".")
%s#\ \+$##e
%s#\($\n\s*\)\+\%$##e
call setpos('.', save_cursor)
endfunction
command! TrimDisable call TrimAuto(0)
command! TrimEnable call TrimAuto(1)
function! TrimAuto(enable)
if a:enable == 1
augroup TrimAuto
au!
au BufWritePre * Trim " See: ~/.config/nvim/functions/Trim.vim
augroup END
else
augroup TrimAuto
au!
augroup END
endif
endfunction
call TrimAuto(1)
]])

View File

@ -0,0 +1,15 @@
-- ZenkakuSpace
vim.cmd([[
function! ZenkakuSpace()
highlight ZenkakuSpace cterm=underline guibg=lightred
endfunction
if has('syntax')
augroup ZenkakuSpace
autocmd!
autocmd ColorScheme * call ZenkakuSpace()
autocmd VimEnter,WinEnter,BufRead * let w:m1=matchadd('ZenkakuSpace', ' ')
augroup END
call ZenkakuSpace()
endif
]])