vimrc: Add alias, prefer :up to :w, update diagnostics

This commit is contained in:
Rob Watson 2021-09-26 22:24:00 +02:00
parent 9fb1a834d6
commit d2610e77bd
1 changed files with 41 additions and 3 deletions

44
nvimrc
View File

@ -127,7 +127,7 @@ imap <right> <nop>
nmap ]q :cn<cr>
nmap [q :cp<cr>
nnoremap <silent> <leader>w :w<cr>
nnoremap <silent> <leader>w :up<cr>
nnoremap <silent> <leader>/ :nohlsearch<cr>
nnoremap <silent> <leader><space> :nohlsearch<cr>
" Select just-pasted text:
@ -142,6 +142,9 @@ nnoremap <leader>s :split<cr>
nnoremap <leader>rp "_dd<bar>P
nnoremap <leader>dq ggVG"_d:wq<cr>
" abbrevs
iabbrev esdebug debugger; // eslint-disable-line no-debugger
lua <<EOF
function _G.dump(...)
local objects = vim.tbl_map(vim.inspect, {...})
@ -455,6 +458,36 @@ packadd! vim-rhubarb " https://github.com/tpope/vim-rhubarb.git
packadd! editorconfig-vim " https://github.com/editorconfig/editorconfig-vim.git
packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
" formatter.nvim
packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git
lua <<EOF
local prettier = function()
return {
-- TODO: figure out how to pass a relative path based on project root to
-- formatter.nvim.
exe = "/home/rob/dev/clipper/frontend/node_modules/.bin/prettier",
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
stdin = true
}
end
require('formatter').setup({
filetype = {
javascript = { prettier },
typescript = { prettier },
typescriptreact = { prettier },
}
})
vim.api.nvim_exec([[
augroup FormatAutogroup
autocmd!
autocmd BufWritePost *.js,*.ts,*.tsx silent FormatWrite
augroup END
]], true)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>F', '<Cmd>silent Format<CR>', { noremap=true, silent=true })
EOF
" enable inline vim highlighting:
let g:vimsyn_embed= 'lPr'
@ -643,11 +676,16 @@ local filetypes = {
typescript = "eslint",
typescriptreact = "eslint",
}
-- diagnosticls
local linters = {
eslint = {
sourceName = "eslint",
command = "eslint",
rootPatterns = {".eslintrc.js", "package.json"},
-- fallback to global eslint if the local is not found?
-- https://github.com/creativenull/diagnosticls-configs-nvim/blob/e7d6f7e99f6b416d2aeee89314bc46fc36df7b22/lua/diagnosticls-configs/fs.lua#L20
command = "./node_modules/.bin/eslint",
rootPatterns = {".eslintrc", ".eslintrc.js"},
debounce = 100,
args = {"--stdin", "--stdin-filename", "%filepath", "--format", "json"},
parseJson = {