neovim: add nvim-lint, nvim-dap-ui, vimtex

This commit is contained in:
Hoang Nguyen 2021-09-04 02:15:41 +07:00
parent 3cefe864f4
commit 78b6d2bf54
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
9 changed files with 123 additions and 16 deletions

View File

@ -1,2 +1,2 @@
setlocal wrap
setlocal nonumber norelativenumber
" setlocal nonumber norelativenumber

View File

@ -1,2 +1,2 @@
setlocal wrap
setlocal nonumber norelativenumber
" setlocal nonumber norelativenumber

View File

@ -25,8 +25,10 @@ function M.load_autocmds()
plugins = {
-- Wrap lines in preview window
-- {"User TelescopePreviewerLoaded", [[setlocal wrap]]},
-- Re-compile packer on config changed
{"BufWritePost", "*.lua", "lua require('events').packer_compile()"},
-- Register binding for ToggleTerm inside term mode
{"TermEnter", "term://*toggleterm#*", "tnoremap <silent><C-\\> <C-\\><C-n>:ToggleTerm<CR>"}
},
@ -47,6 +49,7 @@ function M.load_autocmds()
-- Auto-spelling in doc files
{"BufNewFile,BufRead", "*.md,*.mkd", "setlocal spell"},
{"BufNewFile,BufRead", "*.tex", "setlocal spell"},
-- Auto-hide numbers, statusline in specific buffers
-- {"BufEnter", "term://*", "setlocal norelativenumber nonumber"},
-- {"BufEnter", "term://*", "set laststatus=0"},
@ -56,8 +59,10 @@ function M.load_autocmds()
wins = {
-- Equalize window dimensions when resizing vim window
{"VimResized", "*", [[tabdo wincmd =]]},
-- Force writing shada on leaving nvim
{"VimLeave", "*", [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread'
{"FocusGained", "* checktime"}
},
@ -66,8 +71,6 @@ function M.load_autocmds()
{"FileType", "dashboard", "set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2"},
{"BufNewFile,BufRead", "*.md,*.mkd", "setfiletype markdown"},
{"BufNewFile,BufRead", "*.toml", "setfiletype toml"},
{"BufNewFile,BufRead", "*.tex", "setfiletype tex"},
{"BufNewFile,BufRead", "*.conf", "setfiletype cfg"},
{"BufNewFile,BufRead", "*.rasi", "setfiletype css"},
{"BufNewFile,BufRead", "vifmrc,*.vifm", "setfiletype vim"},
{"BufNewFile,BufRead", "*.log,*_log,*.LO,G*_LOG", "setfiletype log"}

View File

@ -119,6 +119,19 @@ wk.register({
z = {':ZenMode<CR>', 'Zen mode'}
},
d = {
name = 'DAP',
b = {':lua require("dap").toggle_breakpoint()<CR>', 'Toggle breakpoint'},
c = {':lua require("dapui").close()<CR>', 'Close UI'},
e = {':lua require("dapui").eval()<CR>', 'Evaluate cursorword'},
f = {':lua require("dapui").float_element()<CR>', 'Float elements'},
i = {':lua require("dap").repl.open()<CR>', 'Inspect via REPL'},
n = {':lua require("dap").step_into()<CR>', 'Step through code'},
o = {':lua require("dapui").open()<CR>', 'Open UI'},
s = {':lua require("dap").continue()<CR>', 'Debug session'},
t = {':lua require("dapui").open()<CR>', 'Toggle UI'}
},
-- Telescope
f = {
name = 'Telescope',
@ -225,6 +238,12 @@ wk.register({
-- Visual mode (with leader key) --
-----------------------------------
wk.register({
-- DAP
d = {
name = 'DAP',
e = {':lua require("dapui").eval()<CR>', 'Evaluate highlighted text'}
},
-- GitSigns
g = {
name = 'Git',

View File

@ -163,4 +163,34 @@ function M.outline_conf()
}
end
function M.lint_conf()
require('lint').linters_by_ft = {
markdown = {'vale', 'markdownlint', 'languagetool'},
tex = {'vale', 'languagetool'},
vim = {'vint'},
-- lua = {'luacheck'},
c = {'clangtidy', 'cppcheck'},
cpp = {'clangtidy', 'clazy', 'cppcheck'},
python = {'pylint', 'flake8', 'pycodestyle'},
go = {'revive', 'golangcilint'},
sh = {'shellcheck'},
bash = {'shellcheck'},
zsh = {'shellcheck'},
html = {'tidy', 'stylelint'},
css = {'stylelint'},
scss = {'stylelint'},
sass = {'stylelint'},
javascript = {'eslint', 'stylelint'}
}
-- TODO: custom cmds for linters installed with pip (using virtualenv)
-- vint, pylint, flake8, pycodestyle, codespell
vim.cmd [[ au BufRead,BufWritePost * lua require('lint').try_lint() ]]
end
function M.dap_conf()
end
function M.dapui_conf()
end
return M

View File

@ -143,6 +143,9 @@ function M.orgmode_conf()
})
end
function M.vimtex_conf()
end
function M.translate_conf()
vim.g.trans_join_lines = 1
vim.g.trans_win_height = 15

View File

@ -13,6 +13,13 @@ return require('packer').startup(
function(use)
use {'wbthomason/packer.nvim', opt = true}
---------------------------------
-- Plugins used by many others --
---------------------------------
use {'kyazdani42/nvim-web-devicons', module = 'nvim-web-devicons'}
use {'nvim-lua/plenary.nvim', module = 'plenary'}
use {'nvim-lua/popup.nvim', module = 'popup'}
--------
-- UI --
--------
@ -31,10 +38,10 @@ return require('packer').startup(
},
setup = ui.dashboard_conf
}
use { -- TODO: consider moving to felline.nvim
use { -- TODO: consider moving to feline.nvim
'glepnir/galaxyline.nvim',
branch = 'main',
requires = 'kyazdani42/nvim-web-devicons',
wants = 'nvim-web-devicons',
config = ui.statusline_conf
}
use {
@ -55,7 +62,6 @@ return require('packer').startup(
'lewis6991/gitsigns.nvim',
event = {'BufRead', 'BufNewFile'},
wants = 'plenary.nvim',
requires = {{'nvim-lua/plenary.nvim', opt = true}},
config = ui.gitsigns_conf
}
@ -125,7 +131,7 @@ return require('packer').startup(
-- LSP --
---------
local lsp = require('modules.lsp')
use {
use { -- TODO: scripts to install/update lsp servers
'neovim/nvim-lspconfig',
event = 'BufReadPre',
config = lsp.lsp_conf
@ -136,7 +142,7 @@ return require('packer').startup(
wants = 'nvim-lspconfig',
config = lsp.sqls_conf
}
use {
use { -- TODO: config
'ray-x/lsp_signature.nvim',
after = 'nvim-lspconfig'
}
@ -154,6 +160,18 @@ return require('packer').startup(
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
setup = lsp.outline_conf
}
use { -- TODO: scripts to install/update linters
'mfussenegger/nvim-lint',
event = 'BufRead',
config = lsp.lint_conf
}
use { -- TODO: config
'rcarriga/nvim-dap-ui',
keys = '<Leader>d',
wants = 'nvim-dap',
requires = {{'mfussenegger/nvim-dap', config = lsp.dap_conf, opt = true}},
config = lsp.dapui_conf
}
----------------
-- Completion --
@ -162,7 +180,7 @@ return require('packer').startup(
use {
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
wants = {'LuaSnip'},
wants = 'LuaSnip',
requires = {
{
'L3MON4D3/LuaSnip',
@ -230,8 +248,6 @@ return require('packer').startup(
'telescope-fzf-native.nvim'
},
requires = {
{'nvim-lua/popup.nvim', opt = true},
{'nvim-lua/plenary.nvim', opt = true},
{'nvim-telescope/telescope-symbols.nvim', opt = true},
{'nvim-telescope/telescope-project.nvim', opt = true},
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = true}
@ -257,7 +273,6 @@ return require('packer').startup(
'plenary.nvim'
},
requires = {
{'nvim-lua/plenary.nvim', opt = true},
{
'sindrets/diffview.nvim',
config = function()
@ -293,6 +308,11 @@ return require('packer').startup(
ft = {'org'},
config = tools.orgmode_conf
}
use { -- TODO: config
'lervag/vimtex',
ft = 'tex',
setup = tools.vimtext_conf
}
use {
'echuraev/translate-shell.vim',
cmd = {'Trans', 'TransSelectDirection'},
@ -314,7 +334,7 @@ return require('packer').startup(
event = 'WinScrolled',
config = tools.neoscroll_conf
}
use { -- TODO: colors
use { -- TODO: colors + config
'michaelb/sniprun',
run = 'bash ./install.sh 1',
cmd = 'SnipRun'
@ -325,7 +345,7 @@ return require('packer').startup(
}
use {'tweekmonster/startuptime.vim', cmd = 'StartupTime'} -- Just for benchmarking
-- TODO: nvim-lint, rest.nvim, parinfer.nvim, editorconfig.nvim, conjure,
-- nvim-spectre, nvim-dap-ui, dial.nvim, asynctasks.nvim, hotpot.nvim
-- TODO: rest.nvim, parinfer.nvim, editorconfig.nvim, conjure, nvim-spectre,
-- dial.nvim, asynctasks.nvim, hotpot.nvim, rust-tools.nvim, crates.nvim, go.nvim
end
)

View File

@ -20,4 +20,7 @@ cd 3rd/luamake
cd ../..
./3rd/luamake/luamake rebuild
# The build process automatically exports path to `~/.profile`
rm -rf ~/.profile
cd $current_path

29
home/.local/bin/firefox-sync Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# A modified version compared to the one from the Arch Wiki
# (intended for using with Flatpak Firefox)
static=static-$1
link=$1
volatile=/dev/shm/firefox-$1-$USER
IFS=
set -efu
cd ~/.var/app/org.mozilla.firefox/.mozilla/firefox
if [ ! -r $volatile ]; then
mkdir -m0700 $volatile
fi
if [ "$(readlink $link)" != "$volatile" ]; then
mv $link $static
ln -s $volatile $link
fi
if [ -e $link/.unpacked ]; then
rsync -av --delete --exclude .unpacked ./$link/ ./$static/
else
rsync -av ./$static/ ./$link/
touch $link/.unpacked
fi