132 lines
4 KiB
VimL
132 lines
4 KiB
VimL
" Happy yaml configuration
|
|
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml
|
|
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
|
|
|
au BufRead,BufNewFile *.age set filetype=age
|
|
autocmd FileType age setlocal noeol nofixeol
|
|
|
|
function AddTemplate(tmpl_file)
|
|
exe "0read " . a:tmpl_file
|
|
set nomodified
|
|
6
|
|
endfunction
|
|
|
|
autocmd BufNewFile shell.nix call AddTemplate("$XDG_DATA_HOME/nvim/templates/shell.nix.tmpl")
|
|
|
|
let g:gutentags_file_list_command = 'git ls-files'
|
|
|
|
" https://github.com/unblevable/quick-scope
|
|
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
|
|
|
" Caddyfile indentation
|
|
autocmd FileType caddyfile setlocal noexpandtab shiftwidth=8 tabstop=8 softtabstop=8 nolist
|
|
|
|
" GitGutter and vim Magit
|
|
" inspired by: https://jakobgm.com/posts/vim/git-integration/
|
|
" Don't map gitgutter keys automatically, set them ourselves
|
|
let g:gitgutter_map_keys = 0
|
|
|
|
" Jump between hunks
|
|
nmap <Leader>gn <Plug>(GitGutterNextHunk) " git next
|
|
nmap <Leader>gp <Plug>(GitGutterPrevHunk) " git previous
|
|
|
|
" Hunk-add and hunk-revert for chunk staging
|
|
nmap <Leader>ga <Plug>(GitGutterStageHunk) " git add (chunk)
|
|
nmap <Leader>gu <Plug>(GitGutterUndoHunk) " git undo (chunk)
|
|
|
|
" Open vimagit pane
|
|
nnoremap <leader>gs :Magit<CR> " git status
|
|
|
|
" Push to remote
|
|
nnoremap <leader>gP :! git push<CR> " git Push
|
|
|
|
" Quick conflict resolution in git mergetool nvim
|
|
" http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/
|
|
nmap <Leader>[ :diffget //2<CR>
|
|
nmap <Leader>] :diffget //3<CR>
|
|
|
|
" Auto-FMT rust code on save
|
|
let g:rustfmt_autosave = 1
|
|
|
|
" Indenting in html template tags
|
|
let g:html_indent_style1 = "inc"
|
|
|
|
" yank highlight duration
|
|
let g:highlightedyank_highlight_duration = 200
|
|
|
|
" Markdown options
|
|
let g:vim_markdown_folding_disabled = 1
|
|
|
|
" nnn
|
|
let g:nnn#command = 'nnn -d -e -H -r'
|
|
|
|
nmap - :NnnPicker %<CR>
|
|
nmap <leader>n :NnnPicker %<CR>
|
|
nmap <leader>N :NnnPicker<CR>
|
|
|
|
lua <<EOF
|
|
local multiopen = function(prompt_bufnr)
|
|
local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr)
|
|
local multi = picker:get_multi_selection()
|
|
|
|
if vim.tbl_isempty(multi) then
|
|
require('telescope.actions').select_default(prompt_bufnr)
|
|
return
|
|
end
|
|
|
|
require('telescope.actions').close(prompt_bufnr)
|
|
for _, entry in pairs(multi) do
|
|
local filename = entry.filename or entry.value
|
|
local lnum = entry.lnum or 1
|
|
local lcol = entry.col or 1
|
|
if filename then
|
|
vim.cmd(string.format("tabnew +%d %s", lnum, filename))
|
|
vim.cmd(string.format("normal! %dG%d|", lnum, lcol))
|
|
end
|
|
end
|
|
end
|
|
local actions = require("telescope.actions")
|
|
local telescope = require("telescope")
|
|
telescope.setup{
|
|
defaults = {
|
|
mappings = {
|
|
n = {
|
|
["k"] = actions.move_selection_next,
|
|
["i"] = actions.move_selection_previous,
|
|
["I"] = actions.move_to_top,
|
|
["K"] = actions.move_to_bottom,
|
|
["<C-c>"] = actions.close,
|
|
},
|
|
i = {
|
|
['<CR>'] = multiopen,
|
|
}
|
|
},
|
|
},
|
|
pickers = {
|
|
find_files = {
|
|
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
|
|
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
|
},
|
|
},
|
|
extensions = {
|
|
fzf = {
|
|
fuzzy = true, -- false will only do exact matching
|
|
override_generic_sorter = true, -- override the generic sorter
|
|
override_file_sorter = true, -- override the file sorter
|
|
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
|
}
|
|
}
|
|
}
|
|
|
|
telescope.load_extension('fzf')
|
|
|
|
local builtin = require('telescope.builtin')
|
|
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
|
vim.keymap.set('n', '<leader>f/', builtin.live_grep, {})
|
|
vim.keymap.set('n', '<leader>f?', builtin.builtin, {})
|
|
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
|
vim.keymap.set('n', '<leader>fr', builtin.command_history, {})
|
|
vim.keymap.set('n', '<leader>fc', builtin.commands, {})
|
|
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
|
|
EOF
|