From 7129be044e7ad851deb2eec31106d5c209d4261a Mon Sep 17 00:00:00 2001 From: tiyn Date: Wed, 10 Nov 2021 03:25:28 +0100 Subject: [PATCH] multiple changes for nvim - tex snippets were changed for listed and unlisted sections - nvim autocompletion engine was swapped to nvim-cmp - nvim clears more files when exiting tex files - the compiler uses biber when compiling tex files - sc-im is used for .sc filetypes when using vifm --- .config/nvim/UltiSnips/tex.snippets | 18 +++++------ .config/nvim/init.vim | 47 ++++++++++++++++++----------- .config/vifm/vifmrc | 2 +- .local/bin/tools/nvim/compiler | 5 ++- .local/bin/tools/nvim/texclear | 3 +- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/.config/nvim/UltiSnips/tex.snippets b/.config/nvim/UltiSnips/tex.snippets index 1517343..ec659d7 100644 --- a/.config/nvim/UltiSnips/tex.snippets +++ b/.config/nvim/UltiSnips/tex.snippets @@ -91,37 +91,37 @@ snippet ,sc "Small caps" A endsnippet snippet ,chap "Chapter" A -\chapter {$1} +\chapter{$1} $2 endsnippet -snippet ,sec "Section" A -\section* {$1} +snippet ,usec "Section" A +\section{$1} $2 endsnippet -snippet ,lsec "Section" A -\section {$1} +snippet ,sec "Section" A +\section{$1} $2 endsnippet snippet ,ssec "Subsection" A -\subsection* {$1} +\subsection{$1} $2 endsnippet snippet ,sssec "Subsubsection" A -\subsubsection* {$1} +\subsubsection{$1} $2 endsnippet snippet ,par "Paragraph" A -\paragraph* {$1} +\paragraph{$1} $2 endsnippet snippet ,spar "Subparagraph" A -\subparagraph* {$1} +\subparagraph{$1} $2 endsnippet diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index a5fcfc4..0bf99c5 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -13,13 +13,14 @@ Plug 'airblade/vim-gitgutter' " git upgrades Plug 'alvan/vim-closetag' " auto close HTML tags Plug 'donRaphaco/neotex' , {'for': 'tex'} " asynchronous pdf rendering for pdf Plug 'fatih/vim-go' , {'for': 'go'} " better support for golang +Plug 'hrsh7th/nvim-cmp' " autocompletion +Plug 'hrsh7th/cmp-nvim-lsp' " autocompletion bridge to lsp Plug 'itchyny/lightline.vim' " fancy statusline Plug 'junegunn/fzf.vim' " quickly jump files using fzf Plug 'luochen1990/rainbow' " colorized matching brackets Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " show tags Plug 'mattesgroeger/vim-bookmarks' " Set Bookmarks Plug 'neovim/nvim-lspconfig' " Language server client -Plug 'nvim-lua/completion-nvim' " Automatically open the omni completion window while typing Plug 'qpkorr/vim-renamer' " bulk renamer Plug 'raimondi/delimitmate' " automatic closing of brackets Plug 'rrethy/vim-hexokinase' , {'do': 'make hexokinase'} " color Preview @@ -108,6 +109,33 @@ highlight BookmarkLine ctermbg=194 ctermfg=NONE let g:bookmark_sign = 'B' let g:bookmark_highlight_lines = 1 +" hrsh7th/nvim-cmp +lua << EOF +-- Add additional capabilities supported by nvim-cmp +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- nvim-cmp setup +local cmp = require 'cmp' +cmp.setup { + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }}, + sources = { + { name = 'nvim_lsp' }, + }, +} + +EOF + " neovim/nvim-lspconfig lua << EOF local nvim_lsp = require('lspconfig') @@ -138,6 +166,7 @@ local servers = { "pyright", "bashls", "tsserver", "texlab", "ccls", "gopls", "h for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach=on_attach, + capabilities=capabilities, flags = { debounce_text_changes = 150 } @@ -152,15 +181,7 @@ require'lspconfig'.jdtls.setup{ cmd = { 'jdtls' } } - - EOF -autocmd BufEnter * lua require'completion'.on_attach() - -" nvim-lua/completion-nvim -let g:completion_matching_strategy_list = [ 'exact', 'substring', 'fuzzy' ] -let g:completion_matching_smart_case = 1 -let g:completion_enable_snippet = 'UltiSnips' " rrethy/vim-hexokinase let g:Hexokinase_refreshEvents = ['InsertLeave'] @@ -224,14 +245,6 @@ filetype plugin on " enable syntax highlighting syntax on -" enable specify completion options -set shortmess+=c -set completeopt=menuone,noinsert,noselect -inoremap pumvisible() ? '' : '' -inoremap pumvisible() ? '' : '' -inoremap pumvisible() ? '' : '' -inoremap pumvisible() ? '' : '' - " enable true colors set termguicolors diff --git a/.config/vifm/vifmrc b/.config/vifm/vifmrc index 4bfdb93..437fc61 100644 --- a/.config/vifm/vifmrc +++ b/.config/vifm/vifmrc @@ -177,7 +177,7 @@ fileviewer *.pdf "\ pdftotext -nopgbrk %c - " CSV -filetype *.csv,*.xlsx sc-im %f +filetype *.csv,*.xlsx,*.sc sc-im %f " PostScript filextype *.ps,*.eps,*.ps.gz diff --git a/.local/bin/tools/nvim/compiler b/.local/bin/tools/nvim/compiler index 53f1b05..0c6d404 100755 --- a/.local/bin/tools/nvim/compiler +++ b/.local/bin/tools/nvim/compiler @@ -9,6 +9,7 @@ file=$(readlink -f "$1") dir=$(dirname "$file") base="${file%.*}" +basenodir="${1%.*}" cd "$dir" || exit @@ -19,6 +20,7 @@ textype() { \ grep -i addbibresource "$file" >/dev/null && biber --input-directory "$dir" "$base" && $command --output-directory="$dir" "$base" && + makeglossaries "$basenodir" && $command --output-directory="$dir" "$base" } @@ -27,10 +29,10 @@ case "$file" in *\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;; *\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;; *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;; - *\.tex) textype "$file" ;; *\.m) octave -qW "$file" ;; *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; *config.h) sudo make install ;; + *\.tex) textype "$file" ;; *\.java) java "$file" ;; *\.js) node "$file" ;; *\.c) if [ -f Makefile ]; then make run; else cc "$file" -o "$base" && "$base"; fi ;; @@ -40,3 +42,4 @@ case "$file" in *\.sent) setsid sent "$file" 2>/dev/null & ;; *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; esac + diff --git a/.local/bin/tools/nvim/texclear b/.local/bin/tools/nvim/texclear index 771add6..66eb837 100755 --- a/.local/bin/tools/nvim/texclear +++ b/.local/bin/tools/nvim/texclear @@ -10,7 +10,8 @@ case "$1" in dir=$(dirname "$file") base="${file%.*}" if [ -f "$dir/indent.log" ]; then rm "$dir/indent.log"; fi - find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;; + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl|glg|glo|gls|glsdefs|ilg|ist|acn|acr|alg)" -delete ; + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex ".*\\.aux" -delete ;; *) printf "Give .tex file as argument.\\n" ;; esac