From b592afd9605ca8a9cdaac66ab6b73447a6365453 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 15 Jul 2020 10:24:15 +0200 Subject: [PATCH 001/108] Initial empty From 6f7161c4035bc13c33c2f4385a074c2fde631d4d Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 15 Jul 2020 10:24:30 +0200 Subject: [PATCH 002/108] Neovim config --- init.vim | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 init.vim diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..795adee --- /dev/null +++ b/init.vim @@ -0,0 +1,114 @@ +call plug#begin('~/.local/share/nvim/plugged') + +Plug 'davidhalter/jedi-vim' +Plug 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'} +Plug 'zchee/deoplete-jedi' +Plug 'sbdchd/neoformat' +Plug 'dense-analysis/ale' +Plug 'jacoborus/tender.vim' +Plug 'jacoborus/tender.vim' +Plug 'vim-airline/vim-airline' +Plug 'airblade/vim-gitgutter' +Plug 'scrooloose/nerdtree' + +call plug#end() + +let g:deoplete#enable_at_startup=1 +autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif +inoremap pumvisible() ? "\" : "\" + +" Enable alignment +let g:neoformat_basic_format_align=1 +" Enable tab to spaces conversion +let g:neoformat_basic_format_retab=1 +" Enable trimmming of trailing whitespace +let g:neoformat_basic_format_trim=1 +let g:neoformat_try_formatprg=0 + +" disable autocompletion, cause we use deoplete for completion +let g:jedi#completions_enabled=0 +" open the go-to function in split, not another buffer +let g:jedi#use_splits_not_buffers="right" + + +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set textwidth=79 +set expandtab +set autoindent +set fileformat=unix +set number + +" Enable folding on indent +set foldmethod=indent +set foldlevel=79 + +" Lint and check types +let b:ale_linters=['mypy', 'pyls', 'pylint'] +let g:ale_lint_on_save=1 +let g:ale_list_window_size=20 +" Fix syntax with autopep8. +" let b:ale_fixers=['autopep8'] +" let g:ale_fix_on_save=1 +" Use .venv as a global default +let g:ale_virtualenv_dir_names=['.venv'] + +let g:ale_completion_enabled=1 +let g:ale_sign_error="✗" +let g:ale_sign_warning="⚠" + +" Enable warnings about trailing whitespace for all files. +let b:ale_warn_about_trailing_whitespace=1 + +nmap e: ALEDetail + +" ALE colors +highlight ALEWarning ctermbg=Yellow +highlight ALEWarning ctermfg=Black +highlight ALEError ctermbg=DarkRed +highlight ALEError ctermfg=White + +" Use TAB to switch between buffers +noremap < tab > : bn < CR > +noremap < S-tab > : bp < CR > + +" Highlight trailing whitespace (darker red) and remove all with Ctrl+k +highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d +match WhitespaceEOL /\s\+\%#\@ :let _s=@/:%s/\s\+$//e:let @/=_s + +" Much better with Tomorrow Night Bright color theme set in alacritty +set background=dark +highlight Search ctermfg=Black +highlight Comment ctermfg=Grey +highlight SignColumn ctermbg=236 +highlight LineNr ctermfg=244 +highlight LineNr ctermbg=232 +highlight Folded ctermbg=DarkGreen +highlight Folded ctermfg=Black + +highlight GitGutterAdd guibg=#22ff22 guifg=#000000 ctermfg=Green +highlight GitGutterChange guibg=#bbbb00 guifg=#000000 ctermfg=Yellow +highlight GitGutterDelete guibg=#ff2222 guifg=#000000 ctermfg=DarkRed + +let g:gitgutter_sign_added='+' +let g:gitgutter_sign_modified='-+' +let g:gitgutter_sign_removed='-' +let g:gitgutter_sign_removed_first_line='^^' +let g:gitgutter_sign_modified_removed='--' +let g:gitgutter_map_keys=0 + +" Toggles on different plugins/modes +noremap : ToggleMouse +inoremap : ToggleMouse a +nmap : set nonumber! +nmap : NERDTreeToggle +set pastetoggle= + +" Maintain undo history between sessions +if !isdirectory("/tmp/.vim-undo-dir") +call mkdir("/tmp/.vim-undo-dir", "", 0700) +endif +set undodir=/tmp/.vim-undo-dir +set undofile From 4d5032564d4b073eb9ea1a037a99c85f9fbd61ec Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Fri, 24 Jul 2020 10:46:44 +0200 Subject: [PATCH 003/108] Fix autoformat caused errors --- init.vim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/init.vim b/init.vim index 795adee..3f7c2d1 100644 --- a/init.vim +++ b/init.vim @@ -61,7 +61,7 @@ let g:ale_sign_warning="⚠" " Enable warnings about trailing whitespace for all files. let b:ale_warn_about_trailing_whitespace=1 -nmap e: ALEDetail +nmap e: ALEDetail " ALE colors highlight ALEWarning ctermbg=Yellow @@ -70,8 +70,8 @@ highlight ALEError ctermbg=DarkRed highlight ALEError ctermfg=White " Use TAB to switch between buffers -noremap < tab > : bn < CR > -noremap < S-tab > : bp < CR > +noremap :bn +noremap :bp " Highlight trailing whitespace (darker red) and remove all with Ctrl+k highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d @@ -100,10 +100,11 @@ let g:gitgutter_sign_modified_removed='--' let g:gitgutter_map_keys=0 " Toggles on different plugins/modes -noremap : ToggleMouse -inoremap : ToggleMouse a -nmap : set nonumber! -nmap : NERDTreeToggle +noremap :ToggleMouse +inoremap :ToggleMousea +nmap :set nonumber! +nmap :GitGutterBufferToggle +nmap :NERDTreeToggle set pastetoggle= " Maintain undo history between sessions From 8f8b3507e223d19d4eb00ea90d041a41da976ebf Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Fri, 4 Sep 2020 10:37:26 +0200 Subject: [PATCH 004/108] Remove duplicate plugin entry --- init.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/init.vim b/init.vim index 3f7c2d1..8b7a8c5 100644 --- a/init.vim +++ b/init.vim @@ -6,7 +6,6 @@ Plug 'zchee/deoplete-jedi' Plug 'sbdchd/neoformat' Plug 'dense-analysis/ale' Plug 'jacoborus/tender.vim' -Plug 'jacoborus/tender.vim' Plug 'vim-airline/vim-airline' Plug 'airblade/vim-gitgutter' Plug 'scrooloose/nerdtree' From 4c959246188d1231b450ba3713ec1bc6dce64bc6 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 24 Dec 2020 17:25:37 +0100 Subject: [PATCH 005/108] Light background and preview config --- init.vim | 92 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/init.vim b/init.vim index 8b7a8c5..833c71c 100644 --- a/init.vim +++ b/init.vim @@ -3,32 +3,34 @@ call plug#begin('~/.local/share/nvim/plugged') Plug 'davidhalter/jedi-vim' Plug 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'} Plug 'zchee/deoplete-jedi' -Plug 'sbdchd/neoformat' +Plug 'ncm2/float-preview.nvim' Plug 'dense-analysis/ale' Plug 'jacoborus/tender.vim' Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' Plug 'airblade/vim-gitgutter' Plug 'scrooloose/nerdtree' +Plug 'gleam-lang/gleam.vim' call plug#end() -let g:deoplete#enable_at_startup=1 -autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif -inoremap pumvisible() ? "\" : "\" +let g:airline_theme='base16_atelierlakeside' +let g:airline#extensions#ale#enabled=1 -" Enable alignment -let g:neoformat_basic_format_align=1 -" Enable tab to spaces conversion -let g:neoformat_basic_format_retab=1 -" Enable trimmming of trailing whitespace -let g:neoformat_basic_format_trim=1 -let g:neoformat_try_formatprg=0 +let g:deoplete#enable_at_startup=1 +" autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif +inoremap pumvisible() ? "\" : "\" " disable autocompletion, cause we use deoplete for completion let g:jedi#completions_enabled=0 " open the go-to function in split, not another buffer let g:jedi#use_splits_not_buffers="right" +" Preview window is floating +let g:float_preview#docked=0 +let g:float_preview#max_width=100 +let g:float_preview#max_height=150 +let g:float_preview#auto_close=0 set tabstop=4 set softtabstop=4 @@ -38,35 +40,46 @@ set expandtab set autoindent set fileformat=unix set number - +" Hide top preview window, use float_preview instead +set completeopt-=preview " Enable folding on indent set foldmethod=indent set foldlevel=79 " Lint and check types -let b:ale_linters=['mypy', 'pyls', 'pylint'] +let b:ale_linters={ +\ 'python': ['mypy', 'pyls', 'pylint'], +\ 'ocaml': ['merlin'], +\ 'rust': ['rls'] +\ } +let b:ale_fixers = { +\ 'rust': ['rustfmt'], +\ 'python': ['autopep8'], +\ 'ocaml': ['ocamlformat'] +\} + +let g:ale_rust_rls_executable = 'rust-analyzer' +let g:ale_fix_on_save=1 let g:ale_lint_on_save=1 let g:ale_list_window_size=20 -" Fix syntax with autopep8. -" let b:ale_fixers=['autopep8'] -" let g:ale_fix_on_save=1 " Use .venv as a global default let g:ale_virtualenv_dir_names=['.venv'] - let g:ale_completion_enabled=1 let g:ale_sign_error="✗" let g:ale_sign_warning="⚠" +let g:ale_echo_msg_error_str = 'E' +let g:ale_echo_msg_warning_str = 'W' +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' " Enable warnings about trailing whitespace for all files. let b:ale_warn_about_trailing_whitespace=1 -nmap e: ALEDetail +nmap e :ALEDetail +noremap d :ALEGoToDefinition " ALE colors -highlight ALEWarning ctermbg=Yellow -highlight ALEWarning ctermfg=Black -highlight ALEError ctermbg=DarkRed -highlight ALEError ctermfg=White +highlight ALEError ctermbg=DarkRed ctermfg=Black +highlight ALEWarning ctermbg=Yellow ctermfg=White " Use TAB to switch between buffers noremap :bn @@ -78,24 +91,23 @@ match WhitespaceEOL /\s\+\%#\@ :let _s=@/:%s/\s\+$//e:let @/=_s " Much better with Tomorrow Night Bright color theme set in alacritty -set background=dark +" set background=dark highlight Search ctermfg=Black highlight Comment ctermfg=Grey -highlight SignColumn ctermbg=236 -highlight LineNr ctermfg=244 -highlight LineNr ctermbg=232 -highlight Folded ctermbg=DarkGreen -highlight Folded ctermfg=Black +highlight SignColumn ctermbg=0 +highlight LineNr ctermbg=0 ctermfg=248 +highlight Folded ctermbg=Green ctermfg=Black +highlight Pmenu ctermbg=gray guibg=gray -highlight GitGutterAdd guibg=#22ff22 guifg=#000000 ctermfg=Green -highlight GitGutterChange guibg=#bbbb00 guifg=#000000 ctermfg=Yellow -highlight GitGutterDelete guibg=#ff2222 guifg=#000000 ctermfg=DarkRed +highlight GitGutterAdd ctermfg=Green +highlight GitGutterChange ctermfg=Yellow +highlight GitGutterDelete ctermfg=DarkRed let g:gitgutter_sign_added='+' -let g:gitgutter_sign_modified='-+' +let g:gitgutter_sign_modified='±' let g:gitgutter_sign_removed='-' -let g:gitgutter_sign_removed_first_line='^^' -let g:gitgutter_sign_modified_removed='--' +let g:gitgutter_sign_removed_first_line='^' +let g:gitgutter_sign_modified_removed='-' let g:gitgutter_map_keys=0 " Toggles on different plugins/modes @@ -106,9 +118,15 @@ nmap :GitGutterBufferToggle nmap :NERDTreeToggle set pastetoggle= +autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab + " Maintain undo history between sessions -if !isdirectory("/tmp/.vim-undo-dir") -call mkdir("/tmp/.vim-undo-dir", "", 0700) +if !isdirectory("/tmp/.vim-undo-dir-vladan") + call mkdir("/tmp/.vim-undo-dir-vladan", "", 0700) endif -set undodir=/tmp/.vim-undo-dir +set undodir=/tmp/.vim-undo-dir-vladan set undofile +" Enable vimrc files per project +set exrc +" Disable unsafe commands in project vimrc +set secure From 8017c2ac2291cfa03b7d8df406800c2646ee41a6 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 5 Jan 2021 20:46:52 +0100 Subject: [PATCH 006/108] Better rust support and changes all over --- init.vim | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/init.vim b/init.vim index 833c71c..919f6ce 100644 --- a/init.vim +++ b/init.vim @@ -1,8 +1,6 @@ call plug#begin('~/.local/share/nvim/plugged') Plug 'davidhalter/jedi-vim' -Plug 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'} -Plug 'zchee/deoplete-jedi' Plug 'ncm2/float-preview.nvim' Plug 'dense-analysis/ale' Plug 'jacoborus/tender.vim' @@ -11,19 +9,19 @@ Plug 'vim-airline/vim-airline-themes' Plug 'airblade/vim-gitgutter' Plug 'scrooloose/nerdtree' Plug 'gleam-lang/gleam.vim' +Plug 'cespare/vim-toml' +Plug 'rust-lang/rust.vim' +Plug 'vim-scripts/DrawIt' call plug#end() -let g:airline_theme='base16_atelierlakeside' +let g:airline_theme='papercolor' let g:airline#extensions#ale#enabled=1 -let g:deoplete#enable_at_startup=1 -" autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif -inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" -" disable autocompletion, cause we use deoplete for completion let g:jedi#completions_enabled=0 -" open the go-to function in split, not another buffer let g:jedi#use_splits_not_buffers="right" " Preview window is floating @@ -45,12 +43,13 @@ set completeopt-=preview " Enable folding on indent set foldmethod=indent set foldlevel=79 +set omnifunc=ale#completion#OmniFunc " Lint and check types let b:ale_linters={ \ 'python': ['mypy', 'pyls', 'pylint'], \ 'ocaml': ['merlin'], -\ 'rust': ['rls'] +\ 'rust': ['analyzer', 'cargo'] \ } let b:ale_fixers = { \ 'rust': ['rustfmt'], @@ -58,9 +57,11 @@ let b:ale_fixers = { \ 'ocaml': ['ocamlformat'] \} -let g:ale_rust_rls_executable = 'rust-analyzer' +let g:ale_rust_rustfmt_options='--edition 2018' + let g:ale_fix_on_save=1 let g:ale_lint_on_save=1 +let g:ale_lint_on_enter=0 let g:ale_list_window_size=20 " Use .venv as a global default let g:ale_virtualenv_dir_names=['.venv'] @@ -76,6 +77,8 @@ let b:ale_warn_about_trailing_whitespace=1 nmap e :ALEDetail noremap d :ALEGoToDefinition +noremap g] :ALEGoToDefinition +noremap h :ALEHover " ALE colors highlight ALEError ctermbg=DarkRed ctermfg=Black @@ -100,8 +103,15 @@ highlight Folded ctermbg=Green ctermfg=Black highlight Pmenu ctermbg=gray guibg=gray highlight GitGutterAdd ctermfg=Green -highlight GitGutterChange ctermfg=Yellow +highlight GitGutterChange ctermfg=Red highlight GitGutterDelete ctermfg=DarkRed +highlight GitGutterAddLine ctermbg=LightGreen +highlight GitGutterChangeLine ctermbg=Yellow +highlight GitGutterDeleteLine ctermbg=LightRed +highlight GitGutterChangeDeleteLine ctermbg=LightRed + +nmap ]h (GitGutterNextHunk) +nmap [h (GitGutterPrevHunk) let g:gitgutter_sign_added='+' let g:gitgutter_sign_modified='±' @@ -109,14 +119,15 @@ let g:gitgutter_sign_removed='-' let g:gitgutter_sign_removed_first_line='^' let g:gitgutter_sign_modified_removed='-' let g:gitgutter_map_keys=0 +let g:gitgutter_set_sign_backgrounds=1 " Toggles on different plugins/modes -noremap :ToggleMouse -inoremap :ToggleMousea +nmap :ToggleMouse +set pastetoggle= nmap :set nonumber! nmap :GitGutterBufferToggle nmap :NERDTreeToggle -set pastetoggle= +nmap :GitGutterLineHighlightsToggle autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab From f551318edc32b88eba8e3c5410de79b4343342af Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 25 Nov 2021 22:10:31 +0100 Subject: [PATCH 007/108] move to lua and make a poor man's ide --- .gitignore | 1 + _init.vim | 0 init.lua | 79 ++++++++++++++++++++++++ init.vim | 143 ------------------------------------------- lua/completion.lua | 7 +++ lua/config/compe.lua | 78 +++++++++++++++++++++++ lua/config/init.lua | 2 + lua/keymappings.lua | 2 + lua/lang.lua | 133 ++++++++++++++++++++++++++++++++++++++++ lua/lsp_lua.lua | 27 ++++++++ lua/plugins.lua | 44 +++++++++++++ lua/settings.lua | 24 ++++++++ lua/utils/init.lua | 16 +++++ plugin/compe.vim | 5 ++ 14 files changed, 418 insertions(+), 143 deletions(-) create mode 100644 .gitignore create mode 100644 _init.vim create mode 100644 init.lua delete mode 100644 init.vim create mode 100644 lua/completion.lua create mode 100644 lua/config/compe.lua create mode 100644 lua/config/init.lua create mode 100644 lua/keymappings.lua create mode 100644 lua/lang.lua create mode 100644 lua/lsp_lua.lua create mode 100644 lua/plugins.lua create mode 100644 lua/settings.lua create mode 100644 lua/utils/init.lua create mode 100644 plugin/compe.vim diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c84aa4a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugin/packer_compiled.lua diff --git a/_init.vim b/_init.vim new file mode 100644 index 0000000..e69de29 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c9b6111 --- /dev/null +++ b/init.lua @@ -0,0 +1,79 @@ +-- LSP +-- Map leader to space +vim.g.mapleader = ' ' + +local fn = vim.fn +local execute = vim.api.nvim_command + +-- Sensible defaults +require('settings') + +-- Auto install packer.nvim if not exists +local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' +if fn.empty(fn.glob(install_path)) > 0 then + execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path) +end +vim.cmd [[packadd packer.nvim]] +vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua + +vim.opt.autoindent = true +vim.opt.background = 'light' +vim.opt.errorformat:prepend('%f|%l col %c|%m') +vim.opt.expandtab = true +vim.opt.fileformat = 'unix' +vim.opt.number = true +vim.opt.pastetoggle = '' +vim.opt.shiftwidth = 4 +vim.opt.softtabstop = 4 +vim.opt.tabstop = 4 +vim.opt.textwidth = 125 +vim.opt.undofile = true +-- Enable vimrc files per project and disable unsafe commands in project vimrc +vim.opt.exrc = true +vim.opt.secure = true + +vim.cmd 'noremap :bn' +vim.cmd 'noremap :bp' + +-- Toggles on different plugins/modes +vim.cmd 'nmap :ToggleMouse' +vim.cmd 'nmap :set nonumber!' +vim.cmd 'nmap :NERDTreeToggle' +-- +-- Highlight trailing whitespace (darker red) and remove all with Ctrl+k +vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' +vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ :let _s=@/:%s/\\s\\+$//e:let @/=_s' + +vim.cmd 'highlight Visual cterm=bold ctermbg=Grey ctermfg=NONE' +vim.cmd 'highlight Search ctermfg=Black' +vim.cmd 'highlight Comment ctermfg=DarkGrey' +vim.cmd 'highlight SignColumn ctermbg=0' +vim.cmd 'highlight LineNr ctermbg=0 ctermfg=248' +vim.cmd 'highlight Folded ctermbg=Green ctermfg=Black' +vim.cmd 'highlight Pmenu ctermbg=gray guibg=gray' +vim.cmd 'let g:airline_theme=\'papercolor\'' + +-- Find files using Telescope command-line sugar. +vim.cmd 'nnoremap ff Telescope find_files' +vim.cmd 'nnoremap fg Telescope live_grep' +vim.cmd 'nnoremap fb Telescope buffers' +vim.cmd 'nnoremap fh Telescope help_tags' +vim.cmd 'nnoremap fl Telescope git_files' + + +-- Install plugins +require('plugins') + +-- Key mappings +require('keymappings') + +-- Setup Lua language server using submodule +require('lsp_lua') + +-- OR you can invoke them individually here +--require('colorscheme') -- color scheme +require('config.compe') -- completion +--require('fugitive') -- fugitive + +require('lang') diff --git a/init.vim b/init.vim deleted file mode 100644 index 919f6ce..0000000 --- a/init.vim +++ /dev/null @@ -1,143 +0,0 @@ -call plug#begin('~/.local/share/nvim/plugged') - -Plug 'davidhalter/jedi-vim' -Plug 'ncm2/float-preview.nvim' -Plug 'dense-analysis/ale' -Plug 'jacoborus/tender.vim' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'airblade/vim-gitgutter' -Plug 'scrooloose/nerdtree' -Plug 'gleam-lang/gleam.vim' -Plug 'cespare/vim-toml' -Plug 'rust-lang/rust.vim' -Plug 'vim-scripts/DrawIt' - -call plug#end() - -let g:airline_theme='papercolor' -let g:airline#extensions#ale#enabled=1 - -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" - -let g:jedi#completions_enabled=0 -let g:jedi#use_splits_not_buffers="right" - -" Preview window is floating -let g:float_preview#docked=0 -let g:float_preview#max_width=100 -let g:float_preview#max_height=150 -let g:float_preview#auto_close=0 - -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 -set textwidth=79 -set expandtab -set autoindent -set fileformat=unix -set number -" Hide top preview window, use float_preview instead -set completeopt-=preview -" Enable folding on indent -set foldmethod=indent -set foldlevel=79 -set omnifunc=ale#completion#OmniFunc - -" Lint and check types -let b:ale_linters={ -\ 'python': ['mypy', 'pyls', 'pylint'], -\ 'ocaml': ['merlin'], -\ 'rust': ['analyzer', 'cargo'] -\ } -let b:ale_fixers = { -\ 'rust': ['rustfmt'], -\ 'python': ['autopep8'], -\ 'ocaml': ['ocamlformat'] -\} - -let g:ale_rust_rustfmt_options='--edition 2018' - -let g:ale_fix_on_save=1 -let g:ale_lint_on_save=1 -let g:ale_lint_on_enter=0 -let g:ale_list_window_size=20 -" Use .venv as a global default -let g:ale_virtualenv_dir_names=['.venv'] -let g:ale_completion_enabled=1 -let g:ale_sign_error="✗" -let g:ale_sign_warning="⚠" -let g:ale_echo_msg_error_str = 'E' -let g:ale_echo_msg_warning_str = 'W' -let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' - -" Enable warnings about trailing whitespace for all files. -let b:ale_warn_about_trailing_whitespace=1 - -nmap e :ALEDetail -noremap d :ALEGoToDefinition -noremap g] :ALEGoToDefinition -noremap h :ALEHover - -" ALE colors -highlight ALEError ctermbg=DarkRed ctermfg=Black -highlight ALEWarning ctermbg=Yellow ctermfg=White - -" Use TAB to switch between buffers -noremap :bn -noremap :bp - -" Highlight trailing whitespace (darker red) and remove all with Ctrl+k -highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d -match WhitespaceEOL /\s\+\%#\@ :let _s=@/:%s/\s\+$//e:let @/=_s - -" Much better with Tomorrow Night Bright color theme set in alacritty -" set background=dark -highlight Search ctermfg=Black -highlight Comment ctermfg=Grey -highlight SignColumn ctermbg=0 -highlight LineNr ctermbg=0 ctermfg=248 -highlight Folded ctermbg=Green ctermfg=Black -highlight Pmenu ctermbg=gray guibg=gray - -highlight GitGutterAdd ctermfg=Green -highlight GitGutterChange ctermfg=Red -highlight GitGutterDelete ctermfg=DarkRed -highlight GitGutterAddLine ctermbg=LightGreen -highlight GitGutterChangeLine ctermbg=Yellow -highlight GitGutterDeleteLine ctermbg=LightRed -highlight GitGutterChangeDeleteLine ctermbg=LightRed - -nmap ]h (GitGutterNextHunk) -nmap [h (GitGutterPrevHunk) - -let g:gitgutter_sign_added='+' -let g:gitgutter_sign_modified='±' -let g:gitgutter_sign_removed='-' -let g:gitgutter_sign_removed_first_line='^' -let g:gitgutter_sign_modified_removed='-' -let g:gitgutter_map_keys=0 -let g:gitgutter_set_sign_backgrounds=1 - -" Toggles on different plugins/modes -nmap :ToggleMouse -set pastetoggle= -nmap :set nonumber! -nmap :GitGutterBufferToggle -nmap :NERDTreeToggle -nmap :GitGutterLineHighlightsToggle - -autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab - -" Maintain undo history between sessions -if !isdirectory("/tmp/.vim-undo-dir-vladan") - call mkdir("/tmp/.vim-undo-dir-vladan", "", 0700) -endif -set undodir=/tmp/.vim-undo-dir-vladan -set undofile -" Enable vimrc files per project -set exrc -" Disable unsafe commands in project vimrc -set secure diff --git a/lua/completion.lua b/lua/completion.lua new file mode 100644 index 0000000..e93ee93 --- /dev/null +++ b/lua/completion.lua @@ -0,0 +1,7 @@ +local utils = require('utils') +utils.opt('o', 'completeopt', 'menuone,noinsert,noselect') +vim.cmd [[set shortmess+=c]] +vim.g.completion_confirm_key = "" +vim.g.completion_matching_strategy_list = {'exact', 'substring', 'fuzzy'}-- to navigate the completion menu +utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) +utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) diff --git a/lua/config/compe.lua b/lua/config/compe.lua new file mode 100644 index 0000000..3d01a95 --- /dev/null +++ b/lua/config/compe.lua @@ -0,0 +1,78 @@ +-- Configuration for nvim-compe + +local utils = require('utils') + +vim.cmd [[set shortmess+=c]] +utils.opt('o', 'completeopt', 'menuone,noselect') + +require'compe'.setup { + enabled = true; + autocomplete = true; + debug = false; + min_length = 1; + preselect = 'enable'; + throttle_time = 80; + source_timeout = 200; + incomplete_delay = 400; + allow_prefix_unmatch = false; + max_abbr_width = 1000; + max_kind_width = 1000; + max_menu_width = 1000000; + documentation = true; + + + source = { + path = true; + buffer = true; + calc = true; + vsnip = true; + nvim_lsp = true; + nvim_lua = true; + spell = true; + tags = true; + snippets_nvim = true; + treesitter = true; + }; +} + +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local check_back_space = function() + local col = vim.fn.col('.') - 1 + if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end +end + +-- Use (s-)tab to: +--- move to prev/next item in completion menuone +--- jump to prev/next snippet's placeholder +-- _G.tab_complete = function() +-- if vim.fn.pumvisible() == 1 then +-- return t "" +-- elseif vim.fn.call("vsnip#available", {1}) == 1 then +-- return t "(vsnip-expand-or-jump)" +-- elseif check_back_space() then +-- return t "" +-- else +-- return vim.fn['compe#complete']() +-- end +-- end +-- _G.s_tab_complete = function() +-- if vim.fn.pumvisible() == 1 then +-- return t "" +-- elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then +-- return t "(vsnip-jump-prev)" +-- else +-- return t "" +-- end +-- end + +-- utils.map("i", "", "v:lua.tab_complete()", {expr = true}) +-- utils.map("s", "", "v:lua.tab_complete()", {expr = true}) +-- utils.map("i", "", "v:lua.s_tab_complete()", {expr = true}) +-- utils.map("s", "", "v:lua.s_tab_complete()", {expr = true}) diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..97bca80 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,2 @@ +-- nvim-compe +require('config.compe') diff --git a/lua/keymappings.lua b/lua/keymappings.lua new file mode 100644 index 0000000..958a746 --- /dev/null +++ b/lua/keymappings.lua @@ -0,0 +1,2 @@ +local utils = require('utils') +utils.map('n', '', 'noh') -- Clear highlights diff --git a/lua/lang.lua b/lua/lang.lua new file mode 100644 index 0000000..e2d8f4e --- /dev/null +++ b/lua/lang.lua @@ -0,0 +1,133 @@ +USER = vim.fn.expand('$USER') + +-- Language specific key mappings +--require('lang.keymappings') + +local on_attach = function(client, bufnr) + + require'lsp_signature'.on_attach(client) + + local function buf_set_keymap(...) + vim.api.nvim_buf_set_keymap(bufnr, ...) + end + local function buf_set_option(...) + vim.api.nvim_buf_set_option(bufnr, ...) + end + + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = {noremap = true, silent = true} + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', '[l', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', ']l', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'law', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'lrw', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'llw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'lt', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'lrn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'lca', 'lua vim.lsp.buf.code_action()', opts) + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + buf_set_keymap("n", "lf", + "lua vim.lsp.buf.formatting()", opts) + elseif client.resolved_capabilities.document_range_formatting then + buf_set_keymap("n", "lf", + "lua vim.lsp.buf.range_formatting()", opts) + end + + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec([[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow + hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow + hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], false) + end +end + +local nvim_lsp = require('lspconfig') +local capabilities = vim.lsp.protocol.make_client_capabilities() + +-- Code actions +capabilities.textDocument.codeAction = { + dynamicRegistration = true, + codeActionLiteralSupport = { + codeActionKind = { + valueSet = (function() + local res = vim.tbl_values(vim.lsp.protocol.CodeActionKind) + table.sort(res) + return res + end)() + } + } +} + +capabilities.textDocument.completion.completionItem.snippetSupport = true; + +-- LSPs +local servers = {"pylsp", "rust_analyzer", "vimls"} +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} +end + +-- symbols-outline.nvim +vim.g.symbols_outline = { + highlight_hovered_item = true, + show_guides = true, + auto_preview = false, -- experimental + position = 'right', + keymaps = { + close = "", + goto_location = "", + focus_location = "o", + hover_symbol = "", + rename_symbol = "r", + code_actions = "a" + }, + lsp_blacklist = {} +} + +-- LSP Enable diagnostics +vim.lsp.handlers["textDocument/publishDiagnostics"] = + vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = false, + underline = true, + signs = true, + update_in_insert = false + }) + +-- Send diagnostics to quickfix list +do + local method = "textDocument/publishDiagnostics" + local default_handler = vim.lsp.handlers[method] + vim.lsp.handlers[method] = function(err, method, result, client_id, bufnr, + config) + default_handler(err, method, result, client_id, bufnr, config) + local diagnostics = vim.lsp.diagnostic.get_all() + local qflist = {} + for bufnr, diagnostic in pairs(diagnostics) do + for _, d in ipairs(diagnostic) do + d.bufnr = bufnr + d.lnum = d.range.start.line + 1 + d.col = d.range.start.character + 1 + d.text = d.message + table.insert(qflist, d) + end + end + vim.lsp.util.set_qflist(qflist) + end +end diff --git a/lua/lsp_lua.lua b/lua/lsp_lua.lua new file mode 100644 index 0000000..c825708 --- /dev/null +++ b/lua/lsp_lua.lua @@ -0,0 +1,27 @@ +-- Your custom attach function for nvim-lspconfig goes here. +local on_attach = function(client, bufnr) + require('completion').on_attach() + + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings + local opts = { noremap=true, silent=true } + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'H', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + +end + +-- To get builtin LSP running, do something like: +-- NOTE: This replaces the calls where you would have before done `require('nvim_lsp').sumneko_lua.setup()` +--require('nlua.lsp.nvim').setup(require('lspconfig'), { +-- on_attach = on_attach, +--}) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..32397a0 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,44 @@ +return require('packer').startup(function() + + -- Packer can manage itself as an optional plugin + use {'wbthomason/packer.nvim', opt = true} + + -- Fuzzy finder + use { + 'nvim-telescope/telescope.nvim', + requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} + } + + -- LSP and completion + use { 'neovim/nvim-lspconfig' } + use { 'nvim-lua/completion-nvim' } + + -- Lua development + use { 'tjdevries/nlua.nvim' } + + + -- Vim dispatch + use { 'tpope/vim-dispatch' } + + -- Fugitive for Git + use { 'tpope/vim-fugitive' } + + -- Fugitive for Git + use { 'ray-x/lsp_signature.nvim' } + + -- Airline status bar + use { 'vim-airline/vim-airline' } + use { 'vim-airline/vim-airline-themes' } + + use { 'cespare/vim-toml' } + use { 'folke/trouble.nvim' } + use { 'glepnir/lspsaga.nvim' } + use { 'hrsh7th/nvim-compe' } + use { 'jacoborus/tender.vim' } + use { 'kyazdani42/nvim-web-devicons' } + use { 'RRethy/vim-illuminate' } + use { 'rust-lang/rust.vim' } + use { 'scrooloose/nerdtree' } + use { 'vim-scripts/DrawIt' } + +end) diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 0000000..d67e471 --- /dev/null +++ b/lua/settings.lua @@ -0,0 +1,24 @@ +local utils = require('utils') + +local cmd = vim.cmd +local indent = 4 + +cmd 'syntax enable' +cmd 'filetype plugin indent on' +utils.opt('b', 'expandtab', true) +utils.opt('b', 'shiftwidth', indent) +utils.opt('b', 'smartindent', true) +utils.opt('b', 'tabstop', indent) +utils.opt('o', 'hidden', true) +utils.opt('o', 'ignorecase', true) +utils.opt('o', 'scrolloff', 4 ) +utils.opt('o', 'shiftround', true) +utils.opt('o', 'smartcase', true) +utils.opt('o', 'splitbelow', true) +utils.opt('o', 'splitright', true) +utils.opt('o', 'wildmode', 'list:longest') +utils.opt('w', 'number', true) +utils.opt('o', 'clipboard','unnamed,unnamedplus') + +-- Highlight on yank +vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' diff --git a/lua/utils/init.lua b/lua/utils/init.lua new file mode 100644 index 0000000..bd53235 --- /dev/null +++ b/lua/utils/init.lua @@ -0,0 +1,16 @@ +local utils = { } + +local scopes = {o = vim.o, b = vim.bo, w = vim.wo} + +function utils.opt(scope, key, value) + scopes[scope][key] = value + if scope ~= 'o' then scopes['o'][key] = value end +end + +function utils.map(mode, lhs, rhs, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +return utils diff --git a/plugin/compe.vim b/plugin/compe.vim new file mode 100644 index 0000000..2503d85 --- /dev/null +++ b/plugin/compe.vim @@ -0,0 +1,5 @@ +inoremap compe#complete() +inoremap compe#confirm('') +inoremap compe#close('') +inoremap compe#scroll({ 'delta': +4 }) +inoremap compe#scroll({ 'delta': -4 }) From a6b46bb2c097ac6c3442f37cd36cdaa5e5e51a2b Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Fri, 26 Nov 2021 01:27:00 +0100 Subject: [PATCH 008/108] modern nerdtree with icons and fancy --- init.lua | 2 +- lua/nvim-tree-config.vim | 71 ++++++++++++++++++++++++++++++++++++++++ lua/plugins.lua | 57 ++++++++++++++++++++++++++++++-- 3 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 lua/nvim-tree-config.vim diff --git a/init.lua b/init.lua index c9b6111..64e547c 100644 --- a/init.lua +++ b/init.lua @@ -38,7 +38,7 @@ vim.cmd 'noremap :bp' -- Toggles on different plugins/modes vim.cmd 'nmap :ToggleMouse' vim.cmd 'nmap :set nonumber!' -vim.cmd 'nmap :NERDTreeToggle' +vim.cmd 'nmap :NvimTreeToggle' -- -- Highlight trailing whitespace (darker red) and remove all with Ctrl+k vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' diff --git a/lua/nvim-tree-config.vim b/lua/nvim-tree-config.vim new file mode 100644 index 0000000..68658b9 --- /dev/null +++ b/lua/nvim-tree-config.vim @@ -0,0 +1,71 @@ +let g:nvim_tree_gitignore = 1 "0 by default +let g:nvim_tree_quit_on_open = 0 "0 by default, closes the tree when you open a file +let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open +let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). +let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories. +let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options +let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names +let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree +let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker. +let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font. +let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target. +let g:nvim_tree_respect_buf_cwd = 1 "0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree. +let g:nvim_tree_create_in_closed_folder = 0 "1 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1. +let g:nvim_tree_refresh_wait = 500 "1000 by default, control how often the tree can be refreshed, 1000 means the tree can be refresh once per 1000ms. +let g:nvim_tree_window_picker_exclude = { + \ 'filetype': [ + \ 'notify', + \ 'packer', + \ 'qf' + \ ], + \ 'buftype': [ + \ 'terminal' + \ ] + \ } +" Dictionary of buffer option names mapped to a list of option values that +" indicates to the window picker that the buffer's window should not be +" selectable. +let g:nvim_tree_special_files = { 'README.md': 1, 'Makefile': 1, 'MAKEFILE': 1 } " List of filenames that gets highlighted with NvimTreeSpecialFile +let g:nvim_tree_show_icons = { + \ 'git': 1, + \ 'folders': 1, + \ 'files': 1, + \ 'folder_arrows': 1, + \ } +"If 0, do not show the icons for one of 'git' 'folder' and 'files' +"1 by default, notice that if 'files' is 1, it will only display +"if nvim-web-devicons is installed and on your runtimepath. +"if folder is 1, you can also tell folder_arrows 1 to show small arrows next to the folder icons. +"but this will not work when you set indent_markers (because of UI conflict) + +" default will show icon by default if no icon is provided +" default shows no icon by default +let g:nvim_tree_icons = { + \ 'default': '', + \ 'symlink': '', + \ 'git': { + \ 'unstaged': "✗", + \ 'staged': "✓", + \ 'unmerged': "", + \ 'renamed': "➜", + \ 'untracked': "★", + \ 'deleted': "", + \ 'ignored': "◌" + \ }, + \ 'folder': { + \ 'arrow_open': "", + \ 'arrow_closed': "", + \ 'default': "", + \ 'open': "", + \ 'empty': "", + \ 'empty_open': "", + \ 'symlink': "", + \ 'symlink_open': "", + \ } + \ } + + +" set termguicolors " this variable must be enabled for colors to be applied properly + +highlight NvimTreeFolderIcon guibg=blue +set encoding=UTF-8 diff --git a/lua/plugins.lua b/lua/plugins.lua index 32397a0..e899c3a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,5 +1,5 @@ return require('packer').startup(function() - + -- Packer can manage itself as an optional plugin use {'wbthomason/packer.nvim', opt = true} @@ -9,6 +9,60 @@ return require('packer').startup(function() requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} } + vim.cmd('source ~/.config/nvim/lua/nvim-tree-config.vim') + + use { + 'kyazdani42/nvim-tree.lua', + requires = 'kyazdani42/nvim-web-devicons', + config = function() require'nvim-tree'.setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = {}, + auto_close = false, + open_on_tab = false, + hijack_cursor = false, + update_cwd = false, + update_to_buf_dir = { + enable = true, + auto_open = true, + }, + diagnostics = { + enable = false, + icons = { + hint = "", + info = "", + warning = "", + error = "", + } + }, + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {} + }, + system_open = { + cmd = nil, + args = {} + }, + filters = { + dotfiles = false, + custom = {} + }, + view = { + width = 30, + height = 30, + hide_root_folder = false, + side = 'left', + auto_resize = false, + mappings = { + custom_only = false, + list = {} + } + } + } end + } + -- LSP and completion use { 'neovim/nvim-lspconfig' } use { 'nvim-lua/completion-nvim' } @@ -35,7 +89,6 @@ return require('packer').startup(function() use { 'glepnir/lspsaga.nvim' } use { 'hrsh7th/nvim-compe' } use { 'jacoborus/tender.vim' } - use { 'kyazdani42/nvim-web-devicons' } use { 'RRethy/vim-illuminate' } use { 'rust-lang/rust.vim' } use { 'scrooloose/nerdtree' } From 446b6ea0bda9356c6d7363440deb1a19f056d6ad Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 12 Dec 2021 20:06:48 +0100 Subject: [PATCH 009/108] disable autocomplete and documentation while typing --- lua/config/compe.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/config/compe.lua b/lua/config/compe.lua index 3d01a95..1f711a3 100644 --- a/lua/config/compe.lua +++ b/lua/config/compe.lua @@ -7,7 +7,7 @@ utils.opt('o', 'completeopt', 'menuone,noselect') require'compe'.setup { enabled = true; - autocomplete = true; + autocomplete = false; debug = false; min_length = 1; preselect = 'enable'; @@ -18,7 +18,7 @@ require'compe'.setup { max_abbr_width = 1000; max_kind_width = 1000; max_menu_width = 1000000; - documentation = true; + documentation = false; source = { From ad462255b2fa2b1c39323eb3794aeaed06d61c16 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 12 Dec 2021 20:07:55 +0100 Subject: [PATCH 010/108] add poor mans filetype autocmd --- init.lua | 1 + lua/filetypes.lua | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 lua/filetypes.lua diff --git a/init.lua b/init.lua index 64e547c..91ccd29 100644 --- a/init.lua +++ b/init.lua @@ -77,3 +77,4 @@ require('config.compe') -- completion --require('fugitive') -- fugitive require('lang') +require('filetypes') diff --git a/lua/filetypes.lua b/lua/filetypes.lua new file mode 100644 index 0000000..d29f858 --- /dev/null +++ b/lua/filetypes.lua @@ -0,0 +1,4 @@ +vim.cmd([[ + autocmd BufRead,BufNewFile *.bu set filetype=yaml + autocmd BufRead,BufNewFile *.ign set filetype=json +]]) From dbc39e9daad736adb482dc989d60426402826bdb Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 12 Dec 2021 20:08:54 +0100 Subject: [PATCH 011/108] (typo fix) format the comment properly --- lua/completion.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/completion.lua b/lua/completion.lua index e93ee93..4b4809f 100644 --- a/lua/completion.lua +++ b/lua/completion.lua @@ -2,6 +2,7 @@ local utils = require('utils') utils.opt('o', 'completeopt', 'menuone,noinsert,noselect') vim.cmd [[set shortmess+=c]] vim.g.completion_confirm_key = "" -vim.g.completion_matching_strategy_list = {'exact', 'substring', 'fuzzy'}-- to navigate the completion menu +vim.g.completion_matching_strategy_list = {'exact', 'substring', 'fuzzy'} +-- to navigate the completion menu utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) From d80dd17b486cfa976e856f2a8a114c8b65104f5e Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 26 Dec 2021 12:08:52 +0100 Subject: [PATCH 012/108] move nvim_tree config to setup() --- lua/nvim-tree-config.vim | 1 - lua/plugins.lua | 91 +++++++++++++++++++++------------------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/lua/nvim-tree-config.vim b/lua/nvim-tree-config.vim index 68658b9..ce653ce 100644 --- a/lua/nvim-tree-config.vim +++ b/lua/nvim-tree-config.vim @@ -1,4 +1,3 @@ -let g:nvim_tree_gitignore = 1 "0 by default let g:nvim_tree_quit_on_open = 0 "0 by default, closes the tree when you open a file let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). diff --git a/lua/plugins.lua b/lua/plugins.lua index e899c3a..6605fc9 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -15,51 +15,54 @@ return require('packer').startup(function() 'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons', config = function() require'nvim-tree'.setup { - disable_netrw = true, - hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = {}, - auto_close = false, - open_on_tab = false, - hijack_cursor = false, - update_cwd = false, - update_to_buf_dir = { - enable = true, - auto_open = true, - }, - diagnostics = { - enable = false, - icons = { - hint = "", - info = "", - warning = "", - error = "", + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = {}, + auto_close = false, + open_on_tab = false, + hijack_cursor = false, + update_cwd = false, + git = { + ignore = true + }, + update_to_buf_dir = { + enable = true, + auto_open = true, + }, + diagnostics = { + enable = false, + icons = { + hint = "", + info = "", + warning = "", + error = "", + } + }, + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {} + }, + system_open = { + cmd = nil, + args = {} + }, + filters = { + dotfiles = false, + custom = {} + }, + view = { + width = 30, + height = 30, + hide_root_folder = false, + side = 'left', + auto_resize = false, + mappings = { + custom_only = false, + list = {} + } } - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {} - }, - system_open = { - cmd = nil, - args = {} - }, - filters = { - dotfiles = false, - custom = {} - }, - view = { - width = 30, - height = 30, - hide_root_folder = false, - side = 'left', - auto_resize = false, - mappings = { - custom_only = false, - list = {} - } - } } end } From 39ad5f038152800d02497e8d3af98f6b122536c4 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sat, 11 Jun 2022 16:39:13 +0200 Subject: [PATCH 013/108] add gleam --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 6605fc9..e71b911 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -96,5 +96,6 @@ return require('packer').startup(function() use { 'rust-lang/rust.vim' } use { 'scrooloose/nerdtree' } use { 'vim-scripts/DrawIt' } + use { 'gleam-lang/gleam.vim' } end) From e541136af75e9945bf8195d2a63db07d6244bafa Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sat, 11 Jun 2022 16:39:33 +0200 Subject: [PATCH 014/108] fix deprecated vim call --- lua/lang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lang.lua b/lua/lang.lua index e2d8f4e..5ae86c1 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -128,6 +128,6 @@ do table.insert(qflist, d) end end - vim.lsp.util.set_qflist(qflist) + setqflist(qflist) end end From 178d46f664ffe763a9316d2a48822315b34abd50 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 23 Oct 2022 01:48:10 +0200 Subject: [PATCH 015/108] fixes for neovim v0.8.0 --- init.lua | 3 ++- lua/lang.lua | 22 +++++++++++----------- lua/lsp_lua.lua | 9 --------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/init.lua b/init.lua index 91ccd29..248a0b3 100644 --- a/init.lua +++ b/init.lua @@ -51,7 +51,8 @@ vim.cmd 'highlight Comment ctermfg=DarkGrey' vim.cmd 'highlight SignColumn ctermbg=0' vim.cmd 'highlight LineNr ctermbg=0 ctermfg=248' vim.cmd 'highlight Folded ctermbg=Green ctermfg=Black' -vim.cmd 'highlight Pmenu ctermbg=gray guibg=gray' +vim.cmd 'highlight Pmenu ctermbg=253 guibg=253' +vim.cmd 'highlight Pmenu ctermfg=232 guifg=232' vim.cmd 'let g:airline_theme=\'papercolor\'' -- Find files using Telescope command-line sugar. diff --git a/lua/lang.lua b/lua/lang.lua index 5ae86c1..0341cde 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -20,14 +20,14 @@ local on_attach = function(client, bufnr) local opts = {noremap = true, silent = true} buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', '[l', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', ']l', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) + buf_set_keymap('n', '[l', 'lua vim.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', ']l', 'lua vim.diagnostic.set_loclist()', opts) buf_set_keymap('n', 'law', 'lua vim.lsp.buf.add_workspace_folder()', opts) buf_set_keymap('n', 'lrw', 'lua vim.lsp.buf.remove_workspace_folder()', opts) buf_set_keymap('n', 'llw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) @@ -36,16 +36,16 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'lca', 'lua vim.lsp.buf.code_action()', opts) -- Set some keybinds conditional on server capabilities - if client.resolved_capabilities.document_formatting then + if client.server_capabilities.document_formatting then buf_set_keymap("n", "lf", "lua vim.lsp.buf.formatting()", opts) - elseif client.resolved_capabilities.document_range_formatting then + elseif client.server_capabilities.document_range_formatting then buf_set_keymap("n", "lf", "lua vim.lsp.buf.range_formatting()", opts) end -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then + if client.server_capabilities.document_highlight then vim.api.nvim_exec([[ hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow @@ -117,7 +117,7 @@ do vim.lsp.handlers[method] = function(err, method, result, client_id, bufnr, config) default_handler(err, method, result, client_id, bufnr, config) - local diagnostics = vim.lsp.diagnostic.get_all() + local diagnostics = vim.diagnostic.get() local qflist = {} for bufnr, diagnostic in pairs(diagnostics) do for _, d in ipairs(diagnostic) do @@ -128,6 +128,6 @@ do table.insert(qflist, d) end end - setqflist(qflist) + -- setqflist(qflist) end end diff --git a/lua/lsp_lua.lua b/lua/lsp_lua.lua index c825708..43c873e 100644 --- a/lua/lsp_lua.lua +++ b/lua/lsp_lua.lua @@ -9,15 +9,6 @@ local on_attach = function(client, bufnr) -- Mappings local opts = { noremap=true, silent=true } - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'H', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - end -- To get builtin LSP running, do something like: From c8d6c028e823f8dbcd81e004519cd0d9473eeac1 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 16 Nov 2022 01:11:34 +0100 Subject: [PATCH 016/108] finish nvim-tree config migration --- lua/nvim-tree-config.vim | 68 ---------------------------------------- lua/plugins.lua | 68 +++++++++++++++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 76 deletions(-) diff --git a/lua/nvim-tree-config.vim b/lua/nvim-tree-config.vim index ce653ce..7f3996e 100644 --- a/lua/nvim-tree-config.vim +++ b/lua/nvim-tree-config.vim @@ -1,70 +1,2 @@ -let g:nvim_tree_quit_on_open = 0 "0 by default, closes the tree when you open a file -let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open -let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). -let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories. -let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options -let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names -let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree -let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker. -let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font. -let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target. -let g:nvim_tree_respect_buf_cwd = 1 "0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree. -let g:nvim_tree_create_in_closed_folder = 0 "1 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1. -let g:nvim_tree_refresh_wait = 500 "1000 by default, control how often the tree can be refreshed, 1000 means the tree can be refresh once per 1000ms. -let g:nvim_tree_window_picker_exclude = { - \ 'filetype': [ - \ 'notify', - \ 'packer', - \ 'qf' - \ ], - \ 'buftype': [ - \ 'terminal' - \ ] - \ } -" Dictionary of buffer option names mapped to a list of option values that -" indicates to the window picker that the buffer's window should not be -" selectable. -let g:nvim_tree_special_files = { 'README.md': 1, 'Makefile': 1, 'MAKEFILE': 1 } " List of filenames that gets highlighted with NvimTreeSpecialFile -let g:nvim_tree_show_icons = { - \ 'git': 1, - \ 'folders': 1, - \ 'files': 1, - \ 'folder_arrows': 1, - \ } -"If 0, do not show the icons for one of 'git' 'folder' and 'files' -"1 by default, notice that if 'files' is 1, it will only display -"if nvim-web-devicons is installed and on your runtimepath. -"if folder is 1, you can also tell folder_arrows 1 to show small arrows next to the folder icons. -"but this will not work when you set indent_markers (because of UI conflict) - -" default will show icon by default if no icon is provided -" default shows no icon by default -let g:nvim_tree_icons = { - \ 'default': '', - \ 'symlink': '', - \ 'git': { - \ 'unstaged': "✗", - \ 'staged': "✓", - \ 'unmerged': "", - \ 'renamed': "➜", - \ 'untracked': "★", - \ 'deleted': "", - \ 'ignored': "◌" - \ }, - \ 'folder': { - \ 'arrow_open': "", - \ 'arrow_closed': "", - \ 'default': "", - \ 'open': "", - \ 'empty': "", - \ 'empty_open': "", - \ 'symlink': "", - \ 'symlink_open': "", - \ } - \ } - - -" set termguicolors " this variable must be enabled for colors to be applied properly - highlight NvimTreeFolderIcon guibg=blue set encoding=UTF-8 diff --git a/lua/plugins.lua b/lua/plugins.lua index e71b911..0f034b4 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -15,21 +15,18 @@ return require('packer').startup(function() 'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons', config = function() require'nvim-tree'.setup { + create_in_closed_folder = false, disable_netrw = true, hijack_netrw = true, open_on_setup = false, ignore_ft_on_setup = {}, - auto_close = false, + respect_buf_cwd = true, open_on_tab = false, hijack_cursor = false, update_cwd = false, git = { ignore = true }, - update_to_buf_dir = { - enable = true, - auto_open = true, - }, diagnostics = { enable = false, icons = { @@ -52,19 +49,74 @@ return require('packer').startup(function() dotfiles = false, custom = {} }, + actions = { + open_file = { + window_picker = { + enable = false, + exclude = { + filetype = { 'notify', 'packer', 'qf' }, + buftype = { 'terminal' } + } + }, + quit_on_open = false, + resize_window = false + } + }, + renderer = { + indent_markers = { + enable = true + }, + add_trailing = true, + group_empty = true, + highlight_opened_files = "all", + highlight_git = true, + root_folder_modifier = ':~', + special_files = { 'README.md', 'Makefile', 'MAKEFILE' }, + icons = { + padding = ' ', + symlink_arrow = ' >> ', + show = { + git = true, + file = true, + folder = true, + folder_arrow = true + }, + glyphs = { + default = '', + symlink = '', + git = { + unstaged = "✗", + staged = "✓", + unmerged = "-", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌" + }, + folder = { + arrow_open = "-", + arrow_closed = "|", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + } + } + } + }, view = { width = 30, - height = 30, hide_root_folder = false, side = 'left', - auto_resize = false, mappings = { custom_only = false, list = {} } } } end - } +} -- LSP and completion use { 'neovim/nvim-lspconfig' } From 2b9088acbfaa467b42bd0cccc9e90fea72efbed6 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 1 Dec 2022 23:31:12 +0100 Subject: [PATCH 017/108] add ocamllsp --- lua/lang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lang.lua b/lua/lang.lua index 0341cde..4f558b8 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -79,7 +79,7 @@ capabilities.textDocument.codeAction = { capabilities.textDocument.completion.completionItem.snippetSupport = true; -- LSPs -local servers = {"pylsp", "rust_analyzer", "vimls"} +local servers = {"pylsp", "rust_analyzer", "vimls", "ocamllsp"} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end From 896451558b4d21fdf37d95219c870f33fa32ca87 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Fri, 24 Feb 2023 22:45:49 +0100 Subject: [PATCH 018/108] sort out nvim-tree --- lua/plugins.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 0f034b4..759c5d8 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -12,8 +12,8 @@ return require('packer').startup(function() vim.cmd('source ~/.config/nvim/lua/nvim-tree-config.vim') use { - 'kyazdani42/nvim-tree.lua', - requires = 'kyazdani42/nvim-web-devicons', + 'nvim-tree/nvim-tree.lua', + requires = 'nvim-tree/nvim-web-devicons', config = function() require'nvim-tree'.setup { create_in_closed_folder = false, disable_netrw = true, @@ -28,7 +28,7 @@ return require('packer').startup(function() ignore = true }, diagnostics = { - enable = false, + enable = true, icons = { hint = "", info = "", @@ -107,12 +107,22 @@ return require('packer').startup(function() } }, view = { - width = 30, hide_root_folder = false, - side = 'left', mappings = { custom_only = false, list = {} + }, + float = { + enable = true, + quit_on_focus_loss = true, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, + } } } } end @@ -141,12 +151,10 @@ return require('packer').startup(function() use { 'cespare/vim-toml' } use { 'folke/trouble.nvim' } - use { 'glepnir/lspsaga.nvim' } use { 'hrsh7th/nvim-compe' } use { 'jacoborus/tender.vim' } use { 'RRethy/vim-illuminate' } use { 'rust-lang/rust.vim' } - use { 'scrooloose/nerdtree' } use { 'vim-scripts/DrawIt' } use { 'gleam-lang/gleam.vim' } From ceddfe4e8faab8a0349b07705b76dffc8f679350 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Fri, 24 Feb 2023 22:46:07 +0100 Subject: [PATCH 019/108] remove toggle mouse since i never use it --- init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/init.lua b/init.lua index 248a0b3..55f054a 100644 --- a/init.lua +++ b/init.lua @@ -36,7 +36,6 @@ vim.cmd 'noremap :bn' vim.cmd 'noremap :bp' -- Toggles on different plugins/modes -vim.cmd 'nmap :ToggleMouse' vim.cmd 'nmap :set nonumber!' vim.cmd 'nmap :NvimTreeToggle' -- From 319356d0a0326bc2f6a9f79f9491077afc512b57 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Fri, 24 Feb 2023 22:46:53 +0100 Subject: [PATCH 020/108] add settings to rust-analyzer procMacro specifically --- lua/lang.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/lang.lua b/lua/lang.lua index 4f558b8..b484254 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -79,11 +79,34 @@ capabilities.textDocument.codeAction = { capabilities.textDocument.completion.completionItem.snippetSupport = true; -- LSPs -local servers = {"pylsp", "rust_analyzer", "vimls", "ocamllsp"} +local servers = {"pylsp", "vimls", "ocamllsp"} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end +nvim_lsp.rust_analyzer.setup({ + on_attach = on_attach, + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + imports = { + granularity = { + group = "module", + }, + prefix = "self", + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true + }, + } + } +}) + -- symbols-outline.nvim vim.g.symbols_outline = { highlight_hovered_item = true, From 7b9ca1d26cffd7bfa9aea8693082715208c003c1 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 14 May 2023 00:26:04 +0200 Subject: [PATCH 021/108] python lsp is now all rust --- lua/lang.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/lang.lua b/lua/lang.lua index b484254..ba217e3 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -79,11 +79,22 @@ capabilities.textDocument.codeAction = { capabilities.textDocument.completion.completionItem.snippetSupport = true; -- LSPs -local servers = {"pylsp", "vimls", "ocamllsp"} +local servers = {"pylyzer", "vimls", "ocamllsp",} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end +nvim_lsp.ruff_lsp.setup({ + on_attach = on_attach, + capabilities = capabilities, + init_options = { + settings = { + -- Any extra CLI arguments for `ruff` go here. + args = {}, + } + } +}) + nvim_lsp.rust_analyzer.setup({ on_attach = on_attach, capabilities = capabilities, From 2c65a5f0d68b7d3b6b71bf000af428db1edb9f61 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 16 May 2023 01:22:20 +0200 Subject: [PATCH 022/108] don't use deprecated nerdtree config params --- lua/plugins.lua | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 759c5d8..2175b1a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -18,15 +18,10 @@ return require('packer').startup(function() create_in_closed_folder = false, disable_netrw = true, hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = {}, respect_buf_cwd = true, open_on_tab = false, hijack_cursor = false, update_cwd = false, - git = { - ignore = true - }, diagnostics = { enable = true, icons = { @@ -71,40 +66,7 @@ return require('packer').startup(function() highlight_opened_files = "all", highlight_git = true, root_folder_modifier = ':~', - special_files = { 'README.md', 'Makefile', 'MAKEFILE' }, - icons = { - padding = ' ', - symlink_arrow = ' >> ', - show = { - git = true, - file = true, - folder = true, - folder_arrow = true - }, - glyphs = { - default = '', - symlink = '', - git = { - unstaged = "✗", - staged = "✓", - unmerged = "-", - renamed = "➜", - untracked = "★", - deleted = "", - ignored = "◌" - }, - folder = { - arrow_open = "-", - arrow_closed = "|", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - } - } - } + special_files = { 'README.md', 'Makefile', 'MAKEFILE' } }, view = { hide_root_folder = false, From bee54bc4c5a7d9a7236b679b92f907ace16cf09a Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 16 May 2023 01:22:43 +0200 Subject: [PATCH 023/108] fix pyright (again) --- lua/lang.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lang.lua b/lua/lang.lua index ba217e3..4f81039 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -79,11 +79,15 @@ capabilities.textDocument.codeAction = { capabilities.textDocument.completion.completionItem.snippetSupport = true; -- LSPs -local servers = {"pylyzer", "vimls", "ocamllsp",} +local servers = {"vimls", "ocamllsp",} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end +nvim_lsp.pyright.setup({ + on_attach = on_attach, +}) + nvim_lsp.ruff_lsp.setup({ on_attach = on_attach, capabilities = capabilities, From b36cad9c7b5cbe2b5b0d64ce131862c1373a469e Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 16 May 2023 02:25:48 +0200 Subject: [PATCH 024/108] turn off lsp coloring/highlight --- lua/lang.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/lang.lua b/lua/lang.lua index 4f81039..acdf3c9 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -44,6 +44,8 @@ local on_attach = function(client, bufnr) "lua vim.lsp.buf.range_formatting()", opts) end + client.server_capabilities.semanticTokensProvider = nil + -- Set autocommands conditional on server_capabilities if client.server_capabilities.document_highlight then vim.api.nvim_exec([[ From 97dfc2aa6a4aab4ae3fb08401fdce9e3bea6f43b Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 3 Jul 2023 06:21:05 +0200 Subject: [PATCH 025/108] improve key mappings a bit and add spellcheck --- init.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 55f054a..1dab1e3 100644 --- a/init.lua +++ b/init.lua @@ -26,15 +26,12 @@ vim.opt.pastetoggle = '' vim.opt.shiftwidth = 4 vim.opt.softtabstop = 4 vim.opt.tabstop = 4 -vim.opt.textwidth = 125 +vim.opt.textwidth = 79 vim.opt.undofile = true -- Enable vimrc files per project and disable unsafe commands in project vimrc vim.opt.exrc = true vim.opt.secure = true -vim.cmd 'noremap :bn' -vim.cmd 'noremap :bp' - -- Toggles on different plugins/modes vim.cmd 'nmap :set nonumber!' vim.cmd 'nmap :NvimTreeToggle' @@ -54,13 +51,22 @@ vim.cmd 'highlight Pmenu ctermbg=253 guibg=253' vim.cmd 'highlight Pmenu ctermfg=232 guifg=232' vim.cmd 'let g:airline_theme=\'papercolor\'' --- Find files using Telescope command-line sugar. -vim.cmd 'nnoremap ff Telescope find_files' -vim.cmd 'nnoremap fg Telescope live_grep' -vim.cmd 'nnoremap fb Telescope buffers' -vim.cmd 'nnoremap fh Telescope help_tags' -vim.cmd 'nnoremap fl Telescope git_files' +local keymap = vim.api.nvim_set_keymap +local default_opts = { noremap = true, silent = true } +-- Use tab and shift+tab to cycle buffers +keymap("n", "", "bn", default_opts) +keymap("n", "", "bp", default_opts) + +-- Find files, buffers, grep in folder using Telescope command-line sugar. +keymap("n", "ff", "Telescope find_files", default_opts) +keymap("n", "fg", "Telescope live_grep", default_opts) +keymap("n", "fb", "Telescope buffers", default_opts) +keymap("n", "fh", "Telescope help_tags", default_opts) +keymap("n", "fl", "Telescope git_files", default_opts) + +-- Turn spellchecker on +keymap("n", "s", "setlocal spell spelllang=en_us", default_opts) -- Install plugins require('plugins') From 4f4e77d2e892a1af9f4398a6ca66c48f6e7c0c4a Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 3 Jul 2023 06:21:25 +0200 Subject: [PATCH 026/108] remove nvim-tree-config --- lua/nvim-tree-config.vim | 2 -- lua/plugins.lua | 2 -- 2 files changed, 4 deletions(-) delete mode 100644 lua/nvim-tree-config.vim diff --git a/lua/nvim-tree-config.vim b/lua/nvim-tree-config.vim deleted file mode 100644 index 7f3996e..0000000 --- a/lua/nvim-tree-config.vim +++ /dev/null @@ -1,2 +0,0 @@ -highlight NvimTreeFolderIcon guibg=blue -set encoding=UTF-8 diff --git a/lua/plugins.lua b/lua/plugins.lua index 2175b1a..12a05bd 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -9,8 +9,6 @@ return require('packer').startup(function() requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} } - vim.cmd('source ~/.config/nvim/lua/nvim-tree-config.vim') - use { 'nvim-tree/nvim-tree.lua', requires = 'nvim-tree/nvim-web-devicons', From f4fa48ed390d7e3dea6517d05005ed58e7490716 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 25 Jul 2023 18:25:24 +0200 Subject: [PATCH 027/108] add treesitter with color customization --- lua/lang.lua | 20 ++++++++++++++++++++ lua/plugins.lua | 2 ++ 2 files changed, 22 insertions(+) diff --git a/lua/lang.lua b/lua/lang.lua index acdf3c9..d538d7c 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -61,6 +61,26 @@ local on_attach = function(client, bufnr) end end +require('nvim-treesitter.configs').setup { + ensure_installed = { "lua", "rust", "elm", "python", "toml" }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting=false, + }, + ident = { + enable = true, + }, + rainbow = { + enable = true, + extended_mode = false, + max_file_lines = nil, + } +} +vim.api.nvim_set_hl(0, "@variable", { }) +vim.api.nvim_set_hl(0, "@parameter", { }) + + local nvim_lsp = require('lspconfig') local capabilities = vim.lsp.protocol.make_client_capabilities() diff --git a/lua/plugins.lua b/lua/plugins.lua index 12a05bd..c0035ea 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -9,6 +9,8 @@ return require('packer').startup(function() requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} } + use 'nvim-treesitter/nvim-treesitter' + use { 'nvim-tree/nvim-tree.lua', requires = 'nvim-tree/nvim-web-devicons', From c16858ffc76d39577eb1c3c517c6f7d46c82b884 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 25 Jul 2023 18:26:39 +0200 Subject: [PATCH 028/108] add spellcheck allowed words --- spell/en.utf-8.add | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 spell/en.utf-8.add diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add new file mode 100644 index 0000000..6ee0f64 --- /dev/null +++ b/spell/en.utf-8.add @@ -0,0 +1,94 @@ +Ansible +AWS +GCP +OpenStack +CouchDB +gRPC +Proto +Cap'n +Protobuf +RabbitMQ +MQTT +ZMQ +NoSQL +PostgreSQL +hackerspace +FOSS +NGO +OSTree +CoreOS +distro +selfhosted +Gitea +toolset +Django +AsyncIO +async +FastAPI +gevent +uWSGI +SqlAlchemy +uWSGI's +Podman +Kubernetes +WebAssembly +esp32 +SRE +Postgres +Clickhouse +Mysql +Opensearch +Ericssons +Linköping +LabOps +Ericsson +Gerrit +Seavus +Hortonworks +Ambari +Telecommution +HDFS +TradeCore +frontend +GitLab +ElasticSearch +Celerry +Itekako +scalable +JSON +RPC +TinyRPC +FFMpeg +Live555 +dockerizing +RedHat +Asseko +MSSQL +Aiven +C2 +Vladan +Popovic +pagenumbering +Bulevar +Oslobodjenja +gmail +vladanovic/! +vladanovic +microservice +transcoding +Tox +Jinja2 +Artifactory +ESP32 +Microcontroller +SIM800L +blox +NEO +A7670E +TCP +adminstrator +devops +COVID +microcontrollers +codebases +OCaml From 9570523e75339a34d9f6f3037b0bd84fcaa784cc Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 27 Jul 2023 17:40:14 +0200 Subject: [PATCH 029/108] add code action menu and remap to Alt+Enter --- lua/lang.lua | 6 +++++- lua/plugins.lua | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/lang.lua b/lua/lang.lua index d538d7c..1a1c862 100644 --- a/lua/lang.lua +++ b/lua/lang.lua @@ -33,7 +33,8 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'llw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) buf_set_keymap('n', 'lt', 'lua vim.lsp.buf.type_definition()', opts) buf_set_keymap('n', 'lrn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'lca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.code_action()', opts) + -- Set some keybinds conditional on server capabilities if client.server_capabilities.document_formatting then @@ -140,6 +141,9 @@ nvim_lsp.rust_analyzer.setup({ procMacro = { enable = true }, + checkOnSave = { + command = "clippy", + }, } } }) diff --git a/lua/plugins.lua b/lua/plugins.lua index c0035ea..832c644 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,7 +1,9 @@ return require('packer').startup(function() -- Packer can manage itself as an optional plugin - use {'wbthomason/packer.nvim', opt = true} + use {'wbthomason/packer.nvim', opt = true } + + use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } -- Fuzzy finder use { From 721bc03588dda960b02f3a47e138cf495f1e3033 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 30 Jul 2023 04:26:25 +0200 Subject: [PATCH 030/108] huge refactor - tidy up - shuffle code around - use same abstractions for all usecases --- .gitignore | 1 + init.lua | 84 ++---------------------- lua/config/init.lua | 1 + lua/config/treesitter.lua | 19 ++++++ lua/keymappings.lua | 18 ++++++ lua/{lang.lua => lsp.lua} | 102 +++++++++--------------------- lua/lsp_lua.lua | 18 ------ lua/packer_setup.lua | 9 +++ lua/plugins.lua | 1 - lua/settings.lua | 26 ++++++-- lua/theme.lua | 13 ++++ lua/{utils/init.lua => utils.lua} | 2 +- 12 files changed, 116 insertions(+), 178 deletions(-) create mode 100644 lua/config/treesitter.lua rename lua/{lang.lua => lsp.lua} (54%) delete mode 100644 lua/lsp_lua.lua create mode 100644 lua/packer_setup.lua create mode 100644 lua/theme.lua rename lua/{utils/init.lua => utils.lua} (87%) diff --git a/.gitignore b/.gitignore index c84aa4a..fe84bef 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ plugin/packer_compiled.lua +*.spl diff --git a/init.lua b/init.lua index 1dab1e3..d5af289 100644 --- a/init.lua +++ b/init.lua @@ -1,86 +1,12 @@ --- LSP --- Map leader to space +-- remap leader to vim.g.mapleader = ' ' -local fn = vim.fn -local execute = vim.api.nvim_command - -- Sensible defaults require('settings') - --- Auto install packer.nvim if not exists -local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' -if fn.empty(fn.glob(install_path)) > 0 then - execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path) -end -vim.cmd [[packadd packer.nvim]] -vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua - -vim.opt.autoindent = true -vim.opt.background = 'light' -vim.opt.errorformat:prepend('%f|%l col %c|%m') -vim.opt.expandtab = true -vim.opt.fileformat = 'unix' -vim.opt.number = true -vim.opt.pastetoggle = '' -vim.opt.shiftwidth = 4 -vim.opt.softtabstop = 4 -vim.opt.tabstop = 4 -vim.opt.textwidth = 79 -vim.opt.undofile = true --- Enable vimrc files per project and disable unsafe commands in project vimrc -vim.opt.exrc = true -vim.opt.secure = true - --- Toggles on different plugins/modes -vim.cmd 'nmap :set nonumber!' -vim.cmd 'nmap :NvimTreeToggle' --- --- Highlight trailing whitespace (darker red) and remove all with Ctrl+k -vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' -vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ :let _s=@/:%s/\\s\\+$//e:let @/=_s' - -vim.cmd 'highlight Visual cterm=bold ctermbg=Grey ctermfg=NONE' -vim.cmd 'highlight Search ctermfg=Black' -vim.cmd 'highlight Comment ctermfg=DarkGrey' -vim.cmd 'highlight SignColumn ctermbg=0' -vim.cmd 'highlight LineNr ctermbg=0 ctermfg=248' -vim.cmd 'highlight Folded ctermbg=Green ctermfg=Black' -vim.cmd 'highlight Pmenu ctermbg=253 guibg=253' -vim.cmd 'highlight Pmenu ctermfg=232 guifg=232' -vim.cmd 'let g:airline_theme=\'papercolor\'' - -local keymap = vim.api.nvim_set_keymap -local default_opts = { noremap = true, silent = true } - --- Use tab and shift+tab to cycle buffers -keymap("n", "", "bn", default_opts) -keymap("n", "", "bp", default_opts) - --- Find files, buffers, grep in folder using Telescope command-line sugar. -keymap("n", "ff", "Telescope find_files", default_opts) -keymap("n", "fg", "Telescope live_grep", default_opts) -keymap("n", "fb", "Telescope buffers", default_opts) -keymap("n", "fh", "Telescope help_tags", default_opts) -keymap("n", "fl", "Telescope git_files", default_opts) - --- Turn spellchecker on -keymap("n", "s", "setlocal spell spelllang=en_us", default_opts) - --- Install plugins +require('packer_setup') require('plugins') - --- Key mappings require('keymappings') - --- Setup Lua language server using submodule -require('lsp_lua') - --- OR you can invoke them individually here ---require('colorscheme') -- color scheme -require('config.compe') -- completion ---require('fugitive') -- fugitive - -require('lang') +require('lsp') +require('config') require('filetypes') +require('theme') diff --git a/lua/config/init.lua b/lua/config/init.lua index 97bca80..53a8971 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -1,2 +1,3 @@ -- nvim-compe require('config.compe') +require('config.treesitter') diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua new file mode 100644 index 0000000..0643a2b --- /dev/null +++ b/lua/config/treesitter.lua @@ -0,0 +1,19 @@ +require('nvim-treesitter.configs').setup { + ensure_installed = { "lua", "rust", "elm", "python", "yaml", "toml" }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting=false, + }, + ident = { + enable = true, + }, + rainbow = { + enable = true, + extended_mode = false, + max_file_lines = nil, + } +} + +vim.api.nvim_set_hl(0, "@variable", { }) +vim.api.nvim_set_hl(0, "@parameter", { }) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 958a746..e94a803 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,2 +1,20 @@ local utils = require('utils') utils.map('n', '', 'noh') -- Clear highlights + +-- Use tab and shift+tab to cycle buffers +utils.map("n", "", "bn") +utils.map("n", "", "bp") + +-- Find files, buffers, grep in folder using Telescope command-line sugar. +utils.map("n", "ff", "Telescope find_files") +utils.map("n", "fg", "Telescope live_grep") +utils.map("n", "fb", "Telescope buffers") +utils.map("n", "fh", "Telescope help_tags") +utils.map("n", "fl", "Telescope git_files") +-- Turn spellchecker on +utils.map("n", "s", "setlocal spell spelllang=en_us") +utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") + +-- Toggles on different plugins/modes +utils.map("n", "", "set nonumber!") +utils.map("n", "", "NvimTreeToggle") diff --git a/lua/lang.lua b/lua/lsp.lua similarity index 54% rename from lua/lang.lua rename to lua/lsp.lua index 1a1c862..b1278da 100644 --- a/lua/lang.lua +++ b/lua/lsp.lua @@ -1,48 +1,34 @@ -USER = vim.fn.expand('$USER') - --- Language specific key mappings ---require('lang.keymappings') - local on_attach = function(client, bufnr) - + local utils = require('utils') require'lsp_signature'.on_attach(client) - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) - end - local function buf_set_option(...) - vim.api.nvim_buf_set_option(bufnr, ...) - end - - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + utils.opt("o", "omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. - local opts = {noremap = true, silent = true} - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) - buf_set_keymap('n', '[l', 'lua vim.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', ']l', 'lua vim.diagnostic.set_loclist()', opts) - buf_set_keymap('n', 'law', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'lrw', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'llw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'lt', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'lrn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.code_action()', opts) + utils.map("n", "gD", "lua vim.lsp.buf.declaration()") + utils.map("n", "gd", "lua vim.lsp.buf.definition()") + utils.map("n", "gi", "lua vim.lsp.buf.implementation()") + utils.map("n", "gr", "lua vim.lsp.buf.references()") + utils.map("n", "K", "lua vim.lsp.buf.hover()") + utils.map("n", "", "lua vim.lsp.buf.signature_help()") + utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") + utils.map("n", "]d", "lua vim.diagnostic.goto_next()") + utils.map("n", "[l", "lua vim.diagnostic.show_line_diagnostics()") + utils.map("n", "]l", "lua vim.diagnostic.set_loclist()") + utils.map("n", "", "lua vim.lsp.buf.code_action()") + utils.map("n", "", "lua vim.lsp.buf.rename()()") + utils.map("n", "", "lua vim.lsp.buf.type_definition()") + -- list/add/remove workspace folders, not that I use them often + utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") + utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - -- Set some keybinds conditional on server capabilities + -- Set formatting keybinds conditional on server capabilities if client.server_capabilities.document_formatting then - buf_set_keymap("n", "lf", - "lua vim.lsp.buf.formatting()", opts) + utils.map('n', 'lf', 'lua vim.lsp.buf.formatting()') elseif client.server_capabilities.document_range_formatting then - buf_set_keymap("n", "lf", - "lua vim.lsp.buf.range_formatting()", opts) + utils.map('n', 'lf', 'lua vim.lsp.buf.range_formatting()') end client.server_capabilities.semanticTokensProvider = nil @@ -62,47 +48,18 @@ local on_attach = function(client, bufnr) end end -require('nvim-treesitter.configs').setup { - ensure_installed = { "lua", "rust", "elm", "python", "toml" }, - auto_install = true, - highlight = { - enable = true, - additional_vim_regex_highlighting=false, - }, - ident = { - enable = true, - }, - rainbow = { - enable = true, - extended_mode = false, - max_file_lines = nil, - } -} -vim.api.nvim_set_hl(0, "@variable", { }) -vim.api.nvim_set_hl(0, "@parameter", { }) - - local nvim_lsp = require('lspconfig') local capabilities = vim.lsp.protocol.make_client_capabilities() --- Code actions -capabilities.textDocument.codeAction = { - dynamicRegistration = true, - codeActionLiteralSupport = { - codeActionKind = { - valueSet = (function() - local res = vim.tbl_values(vim.lsp.protocol.CodeActionKind) - table.sort(res) - return res - end)() - } - } -} - +-- show snippets in code completion popup capabilities.textDocument.completion.completionItem.snippetSupport = true; -- LSPs -local servers = {"vimls", "ocamllsp",} +local servers = { + "lua_ls", + "ocamllsp", + "vimls", +} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end @@ -148,6 +105,8 @@ nvim_lsp.rust_analyzer.setup({ } }) +vim.g.code_action_menu_window_border = 'single' + -- symbols-outline.nvim vim.g.symbols_outline = { highlight_hovered_item = true, @@ -192,6 +151,5 @@ do table.insert(qflist, d) end end - -- setqflist(qflist) end end diff --git a/lua/lsp_lua.lua b/lua/lsp_lua.lua deleted file mode 100644 index 43c873e..0000000 --- a/lua/lsp_lua.lua +++ /dev/null @@ -1,18 +0,0 @@ --- Your custom attach function for nvim-lspconfig goes here. -local on_attach = function(client, bufnr) - require('completion').on_attach() - - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings - local opts = { noremap=true, silent=true } -end - --- To get builtin LSP running, do something like: --- NOTE: This replaces the calls where you would have before done `require('nvim_lsp').sumneko_lua.setup()` ---require('nlua.lsp.nvim').setup(require('lspconfig'), { --- on_attach = on_attach, ---}) diff --git a/lua/packer_setup.lua b/lua/packer_setup.lua new file mode 100644 index 0000000..12ddb2a --- /dev/null +++ b/lua/packer_setup.lua @@ -0,0 +1,9 @@ +-- Auto install packer.nvim if not exists +local install_path = vim.fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim '..install_path) +end + +vim.cmd [[packadd packer.nvim]] +-- Auto compile when there are changes in plugins.lua +vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' diff --git a/lua/plugins.lua b/lua/plugins.lua index 832c644..bff663e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -106,7 +106,6 @@ return require('packer').startup(function() -- Fugitive for Git use { 'tpope/vim-fugitive' } - -- Fugitive for Git use { 'ray-x/lsp_signature.nvim' } -- Airline status bar diff --git a/lua/settings.lua b/lua/settings.lua index d67e471..a683417 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -1,14 +1,17 @@ local utils = require('utils') - -local cmd = vim.cmd local indent = 4 -cmd 'syntax enable' -cmd 'filetype plugin indent on' +vim.cmd 'syntax enable' +vim.cmd 'filetype plugin indent on' +-- +-- Highlight on yank +vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' + utils.opt('b', 'expandtab', true) utils.opt('b', 'shiftwidth', indent) -utils.opt('b', 'smartindent', true) utils.opt('b', 'tabstop', indent) +utils.opt('b', 'softtabstop', indent) +utils.opt('b', 'smartindent', true) utils.opt('o', 'hidden', true) utils.opt('o', 'ignorecase', true) utils.opt('o', 'scrolloff', 4 ) @@ -20,5 +23,14 @@ utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) utils.opt('o', 'clipboard','unnamed,unnamedplus') --- Highlight on yank -vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' +-- see smartindent +-- vim.opt.autoindent = true +vim.opt.background = 'light' +vim.opt.errorformat:prepend('%f|%l col %c|%m') +vim.opt.fileformat = 'unix' +vim.opt.pastetoggle = '' +vim.opt.textwidth = 79 +vim.opt.undofile = true +-- Enable vimrc files per project and disable unsafe commands in project vimrc +vim.opt.exrc = true +vim.opt.secure = true diff --git a/lua/theme.lua b/lua/theme.lua new file mode 100644 index 0000000..ad482d8 --- /dev/null +++ b/lua/theme.lua @@ -0,0 +1,13 @@ +-- Highlight trailing whitespace (darker red) and remove all with Ctrl+k +vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' +vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Sun, 30 Jul 2023 04:31:11 +0200 Subject: [PATCH 031/108] remove lsp-signature it bothers when signature doc overlaps actual code --- lua/lsp.lua | 1 - lua/plugins.lua | 2 -- 2 files changed, 3 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index b1278da..eda592e 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,6 +1,5 @@ local on_attach = function(client, bufnr) local utils = require('utils') - require'lsp_signature'.on_attach(client) utils.opt("o", "omnifunc", "v:lua.vim.lsp.omnifunc") diff --git a/lua/plugins.lua b/lua/plugins.lua index bff663e..e325bb1 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -106,8 +106,6 @@ return require('packer').startup(function() -- Fugitive for Git use { 'tpope/vim-fugitive' } - use { 'ray-x/lsp_signature.nvim' } - -- Airline status bar use { 'vim-airline/vim-airline' } use { 'vim-airline/vim-airline-themes' } From 9b8c24ca6963bba06f54e84b11e80b7294732b91 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 3 Aug 2023 02:49:25 +0200 Subject: [PATCH 032/108] move telescope config to a new module --- lua/config/init.lua | 1 + lua/config/telescope.lua | 19 +++++++++++++++++++ lua/keymappings.lua | 13 ++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 lua/config/telescope.lua diff --git a/lua/config/init.lua b/lua/config/init.lua index 53a8971..960b7cc 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -1,3 +1,4 @@ -- nvim-compe require('config.compe') require('config.treesitter') +require('config.telescope') diff --git a/lua/config/telescope.lua b/lua/config/telescope.lua new file mode 100644 index 0000000..8cde6b1 --- /dev/null +++ b/lua/config/telescope.lua @@ -0,0 +1,19 @@ +local builtin = require('telescope.builtin') + +local find_files_workspace = function() + builtin.find_files({ + search_dirs = vim.lsp.buf.list_workspace_folders(), + prompt_prefix = "🔍", + }) +end +local live_grep_workspace = function() + builtin.live_grep({ + search_dirs = vim.lsp.buf.list_workspace_folders(), + }) +end + +vim.keymap.set('n', 'ff', find_files_workspace, {}) +vim.keymap.set('n', 'fg', live_grep_workspace, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) +vim.keymap.set('n', 'fl', builtin.git_files, {}) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index e94a803..e6df730 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,20 +1,15 @@ local utils = require('utils') -utils.map('n', '', 'noh') -- Clear highlights +-- Clear highlights (search + trailing whitespace) +utils.map('n', '', 'noh') +utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") -- Use tab and shift+tab to cycle buffers utils.map("n", "", "bn") utils.map("n", "", "bp") --- Find files, buffers, grep in folder using Telescope command-line sugar. -utils.map("n", "ff", "Telescope find_files") -utils.map("n", "fg", "Telescope live_grep") -utils.map("n", "fb", "Telescope buffers") -utils.map("n", "fh", "Telescope help_tags") -utils.map("n", "fl", "Telescope git_files") -- Turn spellchecker on utils.map("n", "s", "setlocal spell spelllang=en_us") -utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") --- Toggles on different plugins/modes +-- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") utils.map("n", "", "NvimTreeToggle") From e46e48405edfb7112dacf823bbf870b8f29c746a Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 21 Aug 2023 00:14:23 +0200 Subject: [PATCH 033/108] clangd (for esp-idf) --- lua/lsp.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lsp.lua b/lua/lsp.lua index eda592e..50949af 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -58,6 +58,7 @@ local servers = { "lua_ls", "ocamllsp", "vimls", + "clangd", } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} From 70ee28574e55adcf8d9ee958ac59b0191257b6c6 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 24 Sep 2023 01:19:07 +0200 Subject: [PATCH 034/108] replace compe with cmp --- lua/config/cmp.lua | 67 +++++++++++++++++++++++++++++++++++++ lua/config/compe.lua | 78 -------------------------------------------- lua/config/init.lua | 3 +- lua/plugins.lua | 2 +- plugin/compe.vim | 5 --- 5 files changed, 69 insertions(+), 86 deletions(-) create mode 100644 lua/config/cmp.lua delete mode 100644 lua/config/compe.lua delete mode 100644 plugin/compe.vim diff --git a/lua/config/cmp.lua b/lua/config/cmp.lua new file mode 100644 index 0000000..a3f5ee6 --- /dev/null +++ b/lua/config/cmp.lua @@ -0,0 +1,67 @@ +-- Completion plugin config + +local utils = require('utils') + +vim.cmd [[set shortmess+=c]] +utils.opt('o', 'completeopt', 'menuone,noselect') + +local cmp = require('cmp') + +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }) +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) diff --git a/lua/config/compe.lua b/lua/config/compe.lua deleted file mode 100644 index 1f711a3..0000000 --- a/lua/config/compe.lua +++ /dev/null @@ -1,78 +0,0 @@ --- Configuration for nvim-compe - -local utils = require('utils') - -vim.cmd [[set shortmess+=c]] -utils.opt('o', 'completeopt', 'menuone,noselect') - -require'compe'.setup { - enabled = true; - autocomplete = false; - debug = false; - min_length = 1; - preselect = 'enable'; - throttle_time = 80; - source_timeout = 200; - incomplete_delay = 400; - allow_prefix_unmatch = false; - max_abbr_width = 1000; - max_kind_width = 1000; - max_menu_width = 1000000; - documentation = false; - - - source = { - path = true; - buffer = true; - calc = true; - vsnip = true; - nvim_lsp = true; - nvim_lua = true; - spell = true; - tags = true; - snippets_nvim = true; - treesitter = true; - }; -} - -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - -local check_back_space = function() - local col = vim.fn.col('.') - 1 - if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false - end -end - --- Use (s-)tab to: ---- move to prev/next item in completion menuone ---- jump to prev/next snippet's placeholder --- _G.tab_complete = function() --- if vim.fn.pumvisible() == 1 then --- return t "" --- elseif vim.fn.call("vsnip#available", {1}) == 1 then --- return t "(vsnip-expand-or-jump)" --- elseif check_back_space() then --- return t "" --- else --- return vim.fn['compe#complete']() --- end --- end --- _G.s_tab_complete = function() --- if vim.fn.pumvisible() == 1 then --- return t "" --- elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then --- return t "(vsnip-jump-prev)" --- else --- return t "" --- end --- end - --- utils.map("i", "", "v:lua.tab_complete()", {expr = true}) --- utils.map("s", "", "v:lua.tab_complete()", {expr = true}) --- utils.map("i", "", "v:lua.s_tab_complete()", {expr = true}) --- utils.map("s", "", "v:lua.s_tab_complete()", {expr = true}) diff --git a/lua/config/init.lua b/lua/config/init.lua index 960b7cc..90e69d7 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -1,4 +1,3 @@ --- nvim-compe -require('config.compe') +require('config.cmp') require('config.treesitter') require('config.telescope') diff --git a/lua/plugins.lua b/lua/plugins.lua index e325bb1..dda78c5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -112,7 +112,7 @@ return require('packer').startup(function() use { 'cespare/vim-toml' } use { 'folke/trouble.nvim' } - use { 'hrsh7th/nvim-compe' } + use { 'hrsh7th/nvim-cmp' } use { 'jacoborus/tender.vim' } use { 'RRethy/vim-illuminate' } use { 'rust-lang/rust.vim' } diff --git a/plugin/compe.vim b/plugin/compe.vim deleted file mode 100644 index 2503d85..0000000 --- a/plugin/compe.vim +++ /dev/null @@ -1,5 +0,0 @@ -inoremap compe#complete() -inoremap compe#confirm('') -inoremap compe#close('') -inoremap compe#scroll({ 'delta': +4 }) -inoremap compe#scroll({ 'delta': -4 }) From f0b2401c517c304a5b1175109d57e4469ae083cb Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 24 Sep 2023 01:23:39 +0200 Subject: [PATCH 035/108] replace nvim-tree with oil --- lua/config/init.lua | 1 + lua/config/oil.lua | 132 ++++++++++++++++++++++++++++++++++++++++++++ lua/keymappings.lua | 2 +- lua/plugins.lua | 82 +-------------------------- 4 files changed, 136 insertions(+), 81 deletions(-) create mode 100644 lua/config/oil.lua diff --git a/lua/config/init.lua b/lua/config/init.lua index 90e69d7..b0d767b 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -1,3 +1,4 @@ require('config.cmp') require('config.treesitter') require('config.telescope') +require('config.oil') diff --git a/lua/config/oil.lua b/lua/config/oil.lua new file mode 100644 index 0000000..dadcb0c --- /dev/null +++ b/lua/config/oil.lua @@ -0,0 +1,132 @@ +require('oil').setup({ + default_file_explorer = true, + -- Id is automatically added at the beginning, and name at the end + -- See :help oil-columns + columns = { + "icon", + -- "permissions", + -- "size", + -- "mtime", + }, + -- Buffer-local options to use for oil buffers + buf_options = { + buflisted = false, + bufhidden = "hide", + }, + -- Window-local options to use for oil buffers + win_options = { + wrap = false, + signcolumn = "no", + cursorcolumn = false, + foldcolumn = "0", + spell = false, + list = false, + conceallevel = 3, + concealcursor = "nvic", + }, + -- Send deleted files to the trash instead of permanently deleting them (:help oil-trash) + delete_to_trash = false, + -- Skip the confirmation popup for simple operations + skip_confirm_for_simple_edits = false, + -- Change this to customize the command used when deleting to trash + trash_command = "trash-put", + -- Selecting a new/moved/renamed file or directory will prompt you to save changes first + prompt_save_on_select_new_entry = true, + -- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap + -- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true }) + -- Additionally, if it is a string that matches "actions.", + -- it will use the mapping at require("oil.actions"). + -- Set to `false` to remove a keymap + -- See :help oil-actions for a list of all available actions + keymaps = { + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = "actions.select_vsplit", + [""] = "actions.select_split", + [""] = "actions.select_tab", + [""] = "actions.preview", + [""] = "actions.close", + [""] = "actions.refresh", + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = "actions.tcd", + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["g."] = "actions.toggle_hidden", + }, + -- Set to false to disable all of the above keymaps + use_default_keymaps = true, + view_options = { + -- Show files and directories that start with "." + show_hidden = false, + -- This function defines what is considered a "hidden" file + is_hidden_file = function(name, bufnr) + return vim.startswith(name, ".") + end, + -- This function defines what will never be shown, even when `show_hidden` is set + is_always_hidden = function(name, bufnr) + return false + end, + sort = { + -- sort order can be "asc" or "desc" + -- see :help oil-columns to see which columns are sortable + { "type", "asc" }, + { "name", "asc" }, + }, + }, + -- Configuration for the floating window in oil.open_float + float = { + -- Padding around the floating window + padding = 2, + max_width = 0, + max_height = 0, + border = "rounded", + win_options = { + winblend = 0, + }, + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + override = function(conf) + return conf + end, + }, + -- Configuration for the actions floating preview window + preview = { + -- Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + -- min_width and max_width can be a single value or a list of mixed integer/float types. + -- max_width = {100, 0.8} means "the lesser of 100 columns or 80% of total" + max_width = 0.9, + -- min_width = {40, 0.4} means "the greater of 40 columns or 40% of total" + min_width = { 40, 0.4 }, + -- optionally define an integer/float for the exact width of the preview window + width = nil, + -- Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + -- min_height and max_height can be a single value or a list of mixed integer/float types. + -- max_height = {80, 0.9} means "the lesser of 80 columns or 90% of total" + max_height = 0.9, + -- min_height = {5, 0.1} means "the greater of 5 columns or 10% of total" + min_height = { 5, 0.1 }, + -- optionally define an integer/float for the exact height of the preview window + height = nil, + border = "rounded", + win_options = { + winblend = 0, + }, + }, + -- Configuration for the floating progress window + progress = { + max_width = 0.9, + min_width = { 40, 0.4 }, + width = nil, + max_height = { 10, 0.9 }, + min_height = { 5, 0.1 }, + height = nil, + border = "rounded", + minimized_border = "none", + win_options = { + winblend = 0, + }, + }, + +}) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index e6df730..e75c31e 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -12,4 +12,4 @@ utils.map("n", "s", "setlocal spell spelllang=en_us") -- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") -utils.map("n", "", "NvimTreeToggle") +utils.map("n", "", "Oil") diff --git a/lua/plugins.lua b/lua/plugins.lua index dda78c5..138e9e6 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -13,86 +13,7 @@ return require('packer').startup(function() use 'nvim-treesitter/nvim-treesitter' - use { - 'nvim-tree/nvim-tree.lua', - requires = 'nvim-tree/nvim-web-devicons', - config = function() require'nvim-tree'.setup { - create_in_closed_folder = false, - disable_netrw = true, - hijack_netrw = true, - respect_buf_cwd = true, - open_on_tab = false, - hijack_cursor = false, - update_cwd = false, - diagnostics = { - enable = true, - icons = { - hint = "", - info = "", - warning = "", - error = "", - } - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {} - }, - system_open = { - cmd = nil, - args = {} - }, - filters = { - dotfiles = false, - custom = {} - }, - actions = { - open_file = { - window_picker = { - enable = false, - exclude = { - filetype = { 'notify', 'packer', 'qf' }, - buftype = { 'terminal' } - } - }, - quit_on_open = false, - resize_window = false - } - }, - renderer = { - indent_markers = { - enable = true - }, - add_trailing = true, - group_empty = true, - highlight_opened_files = "all", - highlight_git = true, - root_folder_modifier = ':~', - special_files = { 'README.md', 'Makefile', 'MAKEFILE' } - }, - view = { - hide_root_folder = false, - mappings = { - custom_only = false, - list = {} - }, - float = { - enable = true, - quit_on_focus_loss = true, - open_win_config = { - relative = "editor", - border = "rounded", - width = 30, - height = 30, - row = 1, - col = 1, - } - } - } - } end -} - - -- LSP and completion + -- LSP and related use { 'neovim/nvim-lspconfig' } use { 'nvim-lua/completion-nvim' } @@ -119,4 +40,5 @@ return require('packer').startup(function() use { 'vim-scripts/DrawIt' } use { 'gleam-lang/gleam.vim' } + use { 'stevearc/oil.nvim' } end) From af32327977e9f5c16ef6a83c55274feeaee6ad63 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 24 Sep 2023 01:24:10 +0200 Subject: [PATCH 036/108] move CodeActionMenu to lsp section --- lua/plugins.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 138e9e6..397539b 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -3,8 +3,6 @@ return require('packer').startup(function() -- Packer can manage itself as an optional plugin use {'wbthomason/packer.nvim', opt = true } - use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } - -- Fuzzy finder use { 'nvim-telescope/telescope.nvim', @@ -16,11 +14,11 @@ return require('packer').startup(function() -- LSP and related use { 'neovim/nvim-lspconfig' } use { 'nvim-lua/completion-nvim' } + use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } -- Lua development use { 'tjdevries/nlua.nvim' } - -- Vim dispatch use { 'tpope/vim-dispatch' } From 8ab3473583654ceb92146f9821a3c0d96d41e670 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 24 Sep 2023 01:24:52 +0200 Subject: [PATCH 037/108] try out filetype.nvim --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 397539b..e352c46 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -37,6 +37,7 @@ return require('packer').startup(function() use { 'rust-lang/rust.vim' } use { 'vim-scripts/DrawIt' } use { 'gleam-lang/gleam.vim' } + use { 'nathom/filetype.nvim' } use { 'stevearc/oil.nvim' } end) From c41f6a096ca23baf905e0813014ade4679d6dee3 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 01:51:50 +0200 Subject: [PATCH 038/108] move all plugin related code to plugins module --- init.lua | 1 - lua/config/init.lua | 4 -- lua/plugins.lua | 43 ------------------- lua/{config => plugins}/cmp.lua | 16 +++++--- lua/plugins/init.lua | 57 ++++++++++++++++++++++++++ lua/{config => plugins}/oil.lua | 0 lua/{config => plugins}/telescope.lua | 0 lua/{config => plugins}/treesitter.lua | 0 8 files changed, 67 insertions(+), 54 deletions(-) delete mode 100644 lua/config/init.lua delete mode 100644 lua/plugins.lua rename lua/{config => plugins}/cmp.lua (78%) create mode 100644 lua/plugins/init.lua rename lua/{config => plugins}/oil.lua (100%) rename lua/{config => plugins}/telescope.lua (100%) rename lua/{config => plugins}/treesitter.lua (100%) diff --git a/init.lua b/init.lua index d5af289..5fbade5 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,5 @@ require('packer_setup') require('plugins') require('keymappings') require('lsp') -require('config') require('filetypes') require('theme') diff --git a/lua/config/init.lua b/lua/config/init.lua deleted file mode 100644 index b0d767b..0000000 --- a/lua/config/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -require('config.cmp') -require('config.treesitter') -require('config.telescope') -require('config.oil') diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index e352c46..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,43 +0,0 @@ -return require('packer').startup(function() - - -- Packer can manage itself as an optional plugin - use {'wbthomason/packer.nvim', opt = true } - - -- Fuzzy finder - use { - 'nvim-telescope/telescope.nvim', - requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} - } - - use 'nvim-treesitter/nvim-treesitter' - - -- LSP and related - use { 'neovim/nvim-lspconfig' } - use { 'nvim-lua/completion-nvim' } - use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } - - -- Lua development - use { 'tjdevries/nlua.nvim' } - - -- Vim dispatch - use { 'tpope/vim-dispatch' } - - -- Fugitive for Git - use { 'tpope/vim-fugitive' } - - -- Airline status bar - use { 'vim-airline/vim-airline' } - use { 'vim-airline/vim-airline-themes' } - - use { 'cespare/vim-toml' } - use { 'folke/trouble.nvim' } - use { 'hrsh7th/nvim-cmp' } - use { 'jacoborus/tender.vim' } - use { 'RRethy/vim-illuminate' } - use { 'rust-lang/rust.vim' } - use { 'vim-scripts/DrawIt' } - use { 'gleam-lang/gleam.vim' } - use { 'nathom/filetype.nvim' } - - use { 'stevearc/oil.nvim' } -end) diff --git a/lua/config/cmp.lua b/lua/plugins/cmp.lua similarity index 78% rename from lua/config/cmp.lua rename to lua/plugins/cmp.lua index a3f5ee6..8953f76 100644 --- a/lua/config/cmp.lua +++ b/lua/plugins/cmp.lua @@ -2,8 +2,8 @@ local utils = require('utils') -vim.cmd [[set shortmess+=c]] -utils.opt('o', 'completeopt', 'menuone,noselect') +--vim.cmd [[set shortmess+=c]] +--utils.opt('o', 'completeopt', 'menuone,noselect') local cmp = require('cmp') @@ -18,15 +18,19 @@ cmp.setup({ end, }, window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + completion = { + autocomplete = false, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..3504985 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,57 @@ +require('packer').startup(function() + + -- Packer can manage itself as an optional plugin + use {'wbthomason/packer.nvim', opt = true } + + -- Fuzzy finder + use { + 'nvim-telescope/telescope.nvim', + requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} + } + + -- Autocomplete and snippets + use { + 'hrsh7th/nvim-cmp', + requires = { + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-path' }, + { 'hrsh7th/cmp-cmdline' }, + { 'hrsh7th/vim-vsnip' }, + { 'hrsh7th/vim-vsnip-integ' }, + } + } + + -- Statusbar, colors and syntax + use { 'jacoborus/tender.vim' } + use { 'nvim-treesitter/nvim-treesitter' } + use { 'vim-airline/vim-airline' } + use { 'vim-airline/vim-airline-themes' } + + -- LSP and related + use { 'neovim/nvim-lspconfig' } + use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } + use { 'folke/trouble.nvim' } -- lsp diagnostics + + -- Languages + use { 'cespare/vim-toml' } + use { 'gleam-lang/gleam.vim' } + use { 'rust-lang/rust.vim' } + use { 'tjdevries/nlua.nvim' } + + -- Git + use { 'tpope/vim-fugitive' } + + -- Filesystem in a nvim buffer + use { 'stevearc/oil.nvim' } + + -- Misc + use { 'RRethy/vim-illuminate' } -- highlight all words same as the one under cursor + use { 'vim-scripts/DrawIt' } -- ascii diagrams + use { 'nathom/filetype.nvim' } +end) + +require('plugins.cmp') +require('plugins.treesitter') +require('plugins.telescope') +require('plugins.oil') diff --git a/lua/config/oil.lua b/lua/plugins/oil.lua similarity index 100% rename from lua/config/oil.lua rename to lua/plugins/oil.lua diff --git a/lua/config/telescope.lua b/lua/plugins/telescope.lua similarity index 100% rename from lua/config/telescope.lua rename to lua/plugins/telescope.lua diff --git a/lua/config/treesitter.lua b/lua/plugins/treesitter.lua similarity index 100% rename from lua/config/treesitter.lua rename to lua/plugins/treesitter.lua From 3d6f14f2ff2c840ecf79ee2f706d9477a5bb6d80 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 01:56:25 +0200 Subject: [PATCH 039/108] remove lingering [empty] _init.vim --- _init.vim | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 _init.vim diff --git a/_init.vim b/_init.vim deleted file mode 100644 index e69de29..0000000 From d6c1fa669aa031f9105ce22052596e6ad2867e3f Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 01:58:40 +0200 Subject: [PATCH 040/108] remap Oil to fe --- lua/keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index e75c31e..da49c5f 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -12,4 +12,4 @@ utils.map("n", "s", "setlocal spell spelllang=en_us") -- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") -utils.map("n", "", "Oil") +utils.map("n", "fe", "Oil") From bb552b148262cd9e5da73d0d45628dfcf478ce3a Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 02:01:07 +0200 Subject: [PATCH 041/108] remove old completion config --- lua/completion.lua | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 lua/completion.lua diff --git a/lua/completion.lua b/lua/completion.lua deleted file mode 100644 index 4b4809f..0000000 --- a/lua/completion.lua +++ /dev/null @@ -1,8 +0,0 @@ -local utils = require('utils') -utils.opt('o', 'completeopt', 'menuone,noinsert,noselect') -vim.cmd [[set shortmess+=c]] -vim.g.completion_confirm_key = "" -vim.g.completion_matching_strategy_list = {'exact', 'substring', 'fuzzy'} --- to navigate the completion menu -utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) -utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) From 88e3cb4ead6039f3e05133fefbbee9c88466a3ea Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 02:15:22 +0200 Subject: [PATCH 042/108] move packer_setup to plugins --- init.lua | 1 - lua/plugins/init.lua | 3 +++ lua/{ => plugins}/packer_setup.lua | 0 3 files changed, 3 insertions(+), 1 deletion(-) rename lua/{ => plugins}/packer_setup.lua (100%) diff --git a/init.lua b/init.lua index 5fbade5..838f16d 100644 --- a/init.lua +++ b/init.lua @@ -3,7 +3,6 @@ vim.g.mapleader = ' ' -- Sensible defaults require('settings') -require('packer_setup') require('plugins') require('keymappings') require('lsp') diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3504985..60d95ef 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,3 +1,5 @@ +require('plugins.packer_setup') + require('packer').startup(function() -- Packer can manage itself as an optional plugin @@ -49,6 +51,7 @@ require('packer').startup(function() use { 'RRethy/vim-illuminate' } -- highlight all words same as the one under cursor use { 'vim-scripts/DrawIt' } -- ascii diagrams use { 'nathom/filetype.nvim' } + end) require('plugins.cmp') diff --git a/lua/packer_setup.lua b/lua/plugins/packer_setup.lua similarity index 100% rename from lua/packer_setup.lua rename to lua/plugins/packer_setup.lua From 79b517a247d5759aad0eec8663f4dee9d267fdff Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 02:15:59 +0200 Subject: [PATCH 043/108] map code action popup to ca --- lua/keymappings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index da49c5f..d85412f 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -13,3 +13,4 @@ utils.map("n", "s", "setlocal spell spelllang=en_us") -- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") utils.map("n", "fe", "Oil") +utils.map("n", "ca", "CodeActionMenu") From 2bc591369a2112ffc22d6d27ac26eba149927a46 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 02:25:19 +0200 Subject: [PATCH 044/108] re-enable smartindent and autoindent --- lua/settings.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/settings.lua b/lua/settings.lua index a683417..a460000 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -23,14 +23,15 @@ utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) utils.opt('o', 'clipboard','unnamed,unnamedplus') --- see smartindent --- vim.opt.autoindent = true +vim.opt.autoindent = true +vim.opt.smartindent = true vim.opt.background = 'light' vim.opt.errorformat:prepend('%f|%l col %c|%m') vim.opt.fileformat = 'unix' vim.opt.pastetoggle = '' vim.opt.textwidth = 79 vim.opt.undofile = true + -- Enable vimrc files per project and disable unsafe commands in project vimrc vim.opt.exrc = true vim.opt.secure = true From 3ad264848245ca944a1aedb200f5bd32760d157b Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 26 Sep 2023 20:36:56 +0200 Subject: [PATCH 045/108] add rnix, a nix lsp server --- lua/lsp.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lsp.lua b/lua/lsp.lua index 50949af..8454250 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -59,6 +59,7 @@ local servers = { "ocamllsp", "vimls", "clangd", + "rnix", } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} From 994e42f6889712579798dadeada08afa99173e0d Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 18 Dec 2023 14:25:52 +0100 Subject: [PATCH 046/108] remap code actions to ca --- lua/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 8454250..8074b57 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -14,7 +14,7 @@ local on_attach = function(client, bufnr) utils.map("n", "]d", "lua vim.diagnostic.goto_next()") utils.map("n", "[l", "lua vim.diagnostic.show_line_diagnostics()") utils.map("n", "]l", "lua vim.diagnostic.set_loclist()") - utils.map("n", "", "lua vim.lsp.buf.code_action()") + utils.map("n", "ca", "lua vim.lsp.buf.code_action()") utils.map("n", "", "lua vim.lsp.buf.rename()()") utils.map("n", "", "lua vim.lsp.buf.type_definition()") From e6e25552747a1e9af4b558d4c3bed2276d842d0b Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 18 Dec 2023 14:26:35 +0100 Subject: [PATCH 047/108] switch python lsp to ruff --- lua/lsp.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 8074b57..981c6ab 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -65,9 +65,15 @@ for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end -nvim_lsp.pyright.setup({ - on_attach = on_attach, -}) +nvim_lsp.ruff_lsp.setup { + on_attach = on_attach, + init_options = { + settings = { + -- Any extra CLI arguments for `ruff` go here. + args = {}, + } + } +} nvim_lsp.ruff_lsp.setup({ on_attach = on_attach, From ca0b58aeb465a4e57108e88306bffb5e56ff8fd6 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 18 Dec 2023 14:27:07 +0100 Subject: [PATCH 048/108] switch from fugitive to neogit --- lua/plugins/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 60d95ef..99ca0c6 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -42,7 +42,7 @@ require('packer').startup(function() use { 'tjdevries/nlua.nvim' } -- Git - use { 'tpope/vim-fugitive' } + use { 'NeogitOrg/neogit' } -- Filesystem in a nvim buffer use { 'stevearc/oil.nvim' } From 15bc48a6c59640c68c5b2f37bf955edcce7ff379 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 18 Dec 2023 14:27:58 +0100 Subject: [PATCH 049/108] explicitly configure ripgrep for telescope --- lua/plugins/telescope.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 8cde6b1..ada75cc 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,5 +1,16 @@ +local telescope = require('telescope') local builtin = require('telescope.builtin') +telescope.setup { + defaults = { + vimgrep_arguments = { 'rg', + '--hidden', '--color=never', '--no-heading', + '--with-filename', '--line-number', + '--column', '--smart-case', + }, + }, +} + local find_files_workspace = function() builtin.find_files({ search_dirs = vim.lsp.buf.list_workspace_folders(), From 253d536ba431a465ffe470df51c7188062c78738 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 18 Dec 2023 14:29:25 +0100 Subject: [PATCH 050/108] remap code actions to either c or a --- lua/lsp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 981c6ab..02b412e 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -14,7 +14,8 @@ local on_attach = function(client, bufnr) utils.map("n", "]d", "lua vim.diagnostic.goto_next()") utils.map("n", "[l", "lua vim.diagnostic.show_line_diagnostics()") utils.map("n", "]l", "lua vim.diagnostic.set_loclist()") - utils.map("n", "ca", "lua vim.lsp.buf.code_action()") + utils.map("n", "a", "lua vim.lsp.buf.code_action()") + utils.map("n", "c", "lua vim.lsp.buf.code_action()") utils.map("n", "", "lua vim.lsp.buf.rename()()") utils.map("n", "", "lua vim.lsp.buf.type_definition()") From 4496f44c49a38b2c3fbe45d2a925e2e32df3cf26 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 2 Jan 2024 01:43:10 +0100 Subject: [PATCH 051/108] styles and treesitter config update --- lua/lsp.lua | 23 ++--------------------- lua/plugins/treesitter.lua | 12 ++++++++---- lua/theme.lua | 6 +++--- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 02b412e..79e4823 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -61,32 +61,13 @@ local servers = { "vimls", "clangd", "rnix", + "pyright", + "ruff_lsp", } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} end -nvim_lsp.ruff_lsp.setup { - on_attach = on_attach, - init_options = { - settings = { - -- Any extra CLI arguments for `ruff` go here. - args = {}, - } - } -} - -nvim_lsp.ruff_lsp.setup({ - on_attach = on_attach, - capabilities = capabilities, - init_options = { - settings = { - -- Any extra CLI arguments for `ruff` go here. - args = {}, - } - } -}) - nvim_lsp.rust_analyzer.setup({ on_attach = on_attach, capabilities = capabilities, diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 0643a2b..f564586 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -3,15 +3,19 @@ require('nvim-treesitter.configs').setup { auto_install = true, highlight = { enable = true, - additional_vim_regex_highlighting=false, + additional_vim_regex_highlighting=true, }, ident = { enable = true, }, - rainbow = { + incremental_selection = { enable = true, - extended_mode = false, - max_file_lines = nil, + keymaps = { + init_selection = "gnn", -- set to `false` to disable one of the mappings + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, } } diff --git a/lua/theme.lua b/lua/theme.lua index ad482d8..f55229b 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -2,11 +2,11 @@ vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Wed, 3 Jan 2024 00:15:20 +0100 Subject: [PATCH 052/108] a bit of a refactor, new telescope mappings --- lua/lsp.lua | 11 ++-------- lua/plugins/telescope.lua | 44 +++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 79e4823..10b45aa 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -4,20 +4,13 @@ local on_attach = function(client, bufnr) utils.opt("o", "omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. - utils.map("n", "gD", "lua vim.lsp.buf.declaration()") - utils.map("n", "gd", "lua vim.lsp.buf.definition()") - utils.map("n", "gi", "lua vim.lsp.buf.implementation()") - utils.map("n", "gr", "lua vim.lsp.buf.references()") utils.map("n", "K", "lua vim.lsp.buf.hover()") utils.map("n", "", "lua vim.lsp.buf.signature_help()") - utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") - utils.map("n", "]d", "lua vim.diagnostic.goto_next()") utils.map("n", "[l", "lua vim.diagnostic.show_line_diagnostics()") utils.map("n", "]l", "lua vim.diagnostic.set_loclist()") - utils.map("n", "a", "lua vim.lsp.buf.code_action()") - utils.map("n", "c", "lua vim.lsp.buf.code_action()") + utils.map("n", "ca", "lua vim.lsp.buf.code_action()") + utils.map("n", "", "lua vim.lsp.buf.type_definition()") utils.map("n", "", "lua vim.lsp.buf.rename()()") - utils.map("n", "", "lua vim.lsp.buf.type_definition()") -- list/add/remove workspace folders, not that I use them often utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index ada75cc..236f6c4 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,30 +1,34 @@ local telescope = require('telescope') +local actions = require('telescope.actions') local builtin = require('telescope.builtin') telescope.setup { defaults = { - vimgrep_arguments = { 'rg', - '--hidden', '--color=never', '--no-heading', + live_grep_arguments = { 'rg', + '--hidden', '--no-ignore', '--color=never', '--with-filename', '--line-number', - '--column', '--smart-case', + '--column', '--smart-case', '--no-heading', + }, + }, + pickers = { + live_grep = { + mappings = { + i = { [""] = actions.to_fuzzy_refine }, + }, }, }, } -local find_files_workspace = function() - builtin.find_files({ - search_dirs = vim.lsp.buf.list_workspace_folders(), - prompt_prefix = "🔍", - }) -end -local live_grep_workspace = function() - builtin.live_grep({ - search_dirs = vim.lsp.buf.list_workspace_folders(), - }) -end - -vim.keymap.set('n', 'ff', find_files_workspace, {}) -vim.keymap.set('n', 'fg', live_grep_workspace, {}) -vim.keymap.set('n', 'fb', builtin.buffers, {}) -vim.keymap.set('n', 'fh', builtin.help_tags, {}) -vim.keymap.set('n', 'fl', builtin.git_files, {}) +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.git_files, {}) +vim.keymap.set('n', 'gg', builtin.live_grep, {}) +vim.keymap.set('n', 'bb', builtin.buffers, {}) +vim.keymap.set('n', 'hh', builtin.help_tags, {}) +vim.keymap.set('n', 'ss', builtin.lsp_dynamic_workspace_symbols, {}) +vim.keymap.set('n', 'sd', builtin.lsp_document_symbols, {}) +vim.keymap.set('n', 'dd', builtin.diagnostics, {}) +vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) +vim.keymap.set('n', 'gr', builtin.lsp_references, {}) +vim.keymap.set('n', 'gi', builtin.lsp_implementations, {}) +vim.keymap.set('n', 'ci', builtin.lsp_incoming_calls, {}) +vim.keymap.set('n', 'co', builtin.lsp_outgoing_calls, {}) From 062d618a21f8324a3cae7c3b5ba69ab8fe561522 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 3 Jan 2024 01:24:21 +0100 Subject: [PATCH 053/108] add neogit and venn diagram config --- lua/plugins/init.lua | 20 +++++++++++++++----- lua/plugins/neogit.lua | 5 +++++ lua/plugins/venn.lua | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 lua/plugins/neogit.lua create mode 100644 lua/plugins/venn.lua diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 99ca0c6..f9816a1 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -8,7 +8,10 @@ require('packer').startup(function() -- Fuzzy finder use { 'nvim-telescope/telescope.nvim', - requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} + requires = { + {'nvim-lua/popup.nvim'}, + {'nvim-lua/plenary.nvim'}, + } } -- Autocomplete and snippets @@ -42,19 +45,26 @@ require('packer').startup(function() use { 'tjdevries/nlua.nvim' } -- Git - use { 'NeogitOrg/neogit' } + use { + 'NeogitOrg/neogit', + requires = { + { "nvim-lua/plenary.nvim" }, + { "sindrets/diffview.nvim" }, + }, + } -- Filesystem in a nvim buffer use { 'stevearc/oil.nvim' } -- Misc - use { 'RRethy/vim-illuminate' } -- highlight all words same as the one under cursor - use { 'vim-scripts/DrawIt' } -- ascii diagrams + use { 'jbyuki/venn.nvim' } -- ascii diagrams use { 'nathom/filetype.nvim' } end) require('plugins.cmp') +require('plugins.neogit') +require('plugins.oil') require('plugins.treesitter') require('plugins.telescope') -require('plugins.oil') +require('plugins.venn') diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua new file mode 100644 index 0000000..b08d583 --- /dev/null +++ b/lua/plugins/neogit.lua @@ -0,0 +1,5 @@ +local neogit = require('neogit') + +neogit.setup { } + +vim.keymap.set('n', '', neogit.open, {}) diff --git a/lua/plugins/venn.lua b/lua/plugins/venn.lua new file mode 100644 index 0000000..1a808b9 --- /dev/null +++ b/lua/plugins/venn.lua @@ -0,0 +1,21 @@ +-- venn.nvim: enable or disable keymappings +function _G.Toggle_venn() + local venn_enabled = vim.inspect(vim.b.venn_enabled) + if venn_enabled == "nil" then + vim.b.venn_enabled = true + vim.cmd[[setlocal ve=all]] + -- draw a line on HJKL keystokes + vim.api.nvim_buf_set_keymap(0, "n", "J", "j:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "K", "k:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "L", "l:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "H", "h:VBox", {noremap = true}) + -- draw a box by pressing "f" with visual selection + vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox", {noremap = true}) + else + vim.cmd[[setlocal ve=]] + vim.cmd[[mapclear ]] + vim.b.venn_enabled = nil + end +end +-- toggle keymappings for venn using v +vim.api.nvim_set_keymap('n', 'v', ":lua Toggle_venn()", { noremap = true}) From 1ecaa1dcf8f5c2343d99089279d5bae11612c5f8 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 3 Jan 2024 01:28:54 +0100 Subject: [PATCH 054/108] remap code action menu to ca --- lua/lsp.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 10b45aa..aed2cbe 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -6,12 +6,11 @@ local on_attach = function(client, bufnr) -- Mappings. utils.map("n", "K", "lua vim.lsp.buf.hover()") utils.map("n", "", "lua vim.lsp.buf.signature_help()") - utils.map("n", "[l", "lua vim.diagnostic.show_line_diagnostics()") - utils.map("n", "]l", "lua vim.diagnostic.set_loclist()") - utils.map("n", "ca", "lua vim.lsp.buf.code_action()") utils.map("n", "", "lua vim.lsp.buf.type_definition()") utils.map("n", "", "lua vim.lsp.buf.rename()()") + utils.map("n", "ca", "lua vim.lsp.buf.code_action()") + -- list/add/remove workspace folders, not that I use them often utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") From d89d00af713da180f2511dc0af005756f449df7e Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 3 Jan 2024 02:10:43 +0100 Subject: [PATCH 055/108] test gitsigns ... --- lua/keymappings.lua | 3 +-- lua/plugins/gitsigns.lua | 42 ++++++++++++++++++++++++++++++++++++++++ lua/plugins/init.lua | 3 ++- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 lua/plugins/gitsigns.lua diff --git a/lua/keymappings.lua b/lua/keymappings.lua index d85412f..d56d803 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -8,9 +8,8 @@ utils.map("n", "", "bn") utils.map("n", "", "bp") -- Turn spellchecker on -utils.map("n", "s", "setlocal spell spelllang=en_us") +utils.map("n", "se", "setlocal spell spelllang=en_us") -- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") utils.map("n", "fe", "Oil") -utils.map("n", "ca", "CodeActionMenu") diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..6a4f422 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,42 @@ +require('gitsigns').setup { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, {expr=true}) + + map('n', '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, {expr=true}) + + -- Actions + map('n', 'hs', gs.stage_hunk) + map('n', 'hr', gs.reset_hunk) + map('v', 'hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('v', 'hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('n', 'hS', gs.stage_buffer) + map('n', 'hu', gs.undo_stage_hunk) + map('n', 'hR', gs.reset_buffer) + map('n', 'hp', gs.preview_hunk) + map('n', 'hb', function() gs.blame_line{full=true} end) + map('n', 'tb', gs.toggle_current_line_blame) + map('n', 'hd', gs.diffthis) + map('n', 'hD', function() gs.diffthis('~') end) + map('n', 'td', gs.toggle_deleted) + + -- Text object + map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') + end +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f9816a1..9618355 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -28,7 +28,6 @@ require('packer').startup(function() } -- Statusbar, colors and syntax - use { 'jacoborus/tender.vim' } use { 'nvim-treesitter/nvim-treesitter' } use { 'vim-airline/vim-airline' } use { 'vim-airline/vim-airline-themes' } @@ -52,6 +51,7 @@ require('packer').startup(function() { "sindrets/diffview.nvim" }, }, } + use { "lewis6991/gitsigns.nvim" } -- Filesystem in a nvim buffer use { 'stevearc/oil.nvim' } @@ -63,6 +63,7 @@ require('packer').startup(function() end) require('plugins.cmp') +require('plugins.gitsigns') require('plugins.neogit') require('plugins.oil') require('plugins.treesitter') From 3e2dd9c3322a2104a31900cc412ffbf64fc9eae4 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 4 Jan 2024 00:45:21 +0100 Subject: [PATCH 056/108] most usable config --- init.lua | 2 +- lua/keymappings.lua | 11 +++---- lua/lsp.lua | 11 ++++--- lua/plugins/cmp.lua | 60 +++++++++++++++++++++++++++++++------- lua/plugins/init.lua | 12 +++++++- lua/plugins/treesitter.lua | 11 +++---- 6 files changed, 77 insertions(+), 30 deletions(-) diff --git a/init.lua b/init.lua index 838f16d..dc312bd 100644 --- a/init.lua +++ b/init.lua @@ -4,7 +4,7 @@ vim.g.mapleader = ' ' -- Sensible defaults require('settings') require('plugins') -require('keymappings') require('lsp') require('filetypes') require('theme') +require('keymappings') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index d56d803..2f6751b 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,15 +1,16 @@ local utils = require('utils') --- Clear highlights (search + trailing whitespace) -utils.map('n', '', 'noh') -utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") + +-- Clear trailing whitespace +utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") -- Use tab and shift+tab to cycle buffers utils.map("n", "", "bn") utils.map("n", "", "bp") --- Turn spellchecker on +-- Turn spellchecker on and off utils.map("n", "se", "setlocal spell spelllang=en_us") +utils.map("n", "sq", "setlocal nospell") --- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") utils.map("n", "fe", "Oil") +utils.map("n", "", "Neotree toggle") diff --git a/lua/lsp.lua b/lua/lsp.lua index aed2cbe..eef7984 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -8,10 +8,9 @@ local on_attach = function(client, bufnr) utils.map("n", "", "lua vim.lsp.buf.signature_help()") utils.map("n", "", "lua vim.lsp.buf.type_definition()") utils.map("n", "", "lua vim.lsp.buf.rename()()") - + utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") + utils.map("n", "]d", "lua vim.diagnostic.goto_next()") utils.map("n", "ca", "lua vim.lsp.buf.code_action()") - - -- list/add/remove workspace folders, not that I use them often utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") @@ -76,9 +75,9 @@ nvim_lsp.rust_analyzer.setup({ enable = true, }, }, - procMacro = { - enable = true - }, + --procMacro = { + -- enable = true + --}, checkOnSave = { command = "clippy", }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 8953f76..05ab1a0 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -2,12 +2,53 @@ local utils = require('utils') ---vim.cmd [[set shortmess+=c]] ---utils.opt('o', 'completeopt', 'menuone,noselect') +vim.cmd [[set shortmess+=c]] +utils.opt('o', 'completeopt', 'menuone,noselect') local cmp = require('cmp') +local cmp_kinds = { + Text = ' ', + Method = '󰊕 ', + Function = '󰊕 ', + Constructor = ' ', + Field = ' ', + Variable = ' ', + Class = ' ', + Interface = ' ', + Module = ' ', + Property = ' ', + Unit = ' ', + Value = ' ', + Enum = ' ', + Keyword = ' ', + Snippet = ' ', + Color = ' ', + File = ' ', + Reference = ' ', + Folder = ' ', + EnumMember = ' ', + Constant = ' ', + Struct = ' ', + Event = ' ', + Operator = ' ', + TypeParameter = ' ', +} cmp.setup({ + formatting = { + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format('%s %s', cmp_kinds[vim_item.kind], vim_item.kind) + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + nvim_lua = "[Lua]", + latex_symbols = "[LaTeX]", + })[entry.source.name] + return vim_item + end + }, snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) @@ -27,7 +68,6 @@ cmp.setup({ mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. @@ -44,13 +84,13 @@ cmp.setup({ }) -- Set configuration for specific filetype. -cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). - }, { - { name = 'buffer' }, - }) -}) +--cmp.setup.filetype('gitcommit', { +-- sources = cmp.config.sources({ +-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). +-- }, { +-- { name = 'buffer' }, +-- }) +--}) -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline({ '/', '?' }, { diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 9618355..811f745 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -5,6 +5,16 @@ require('packer').startup(function() -- Packer can manage itself as an optional plugin use {'wbthomason/packer.nvim', opt = true } + use { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + requires = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + } + } + -- Fuzzy finder use { 'nvim-telescope/telescope.nvim', @@ -53,7 +63,7 @@ require('packer').startup(function() } use { "lewis6991/gitsigns.nvim" } - -- Filesystem in a nvim buffer + -- Filesystem browser use { 'stevearc/oil.nvim' } -- Misc diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index f564586..4eb2d0f 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -8,16 +8,13 @@ require('nvim-treesitter.configs').setup { ident = { enable = true, }, - incremental_selection = { + rainbow = { enable = true, - keymaps = { - init_selection = "gnn", -- set to `false` to disable one of the mappings - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, + extended_mode = false, + max_file_lines = nil, } } vim.api.nvim_set_hl(0, "@variable", { }) vim.api.nvim_set_hl(0, "@parameter", { }) +vim.api.nvim_set_hl(0, "@field", { }) From 027c0c81f3b54ad77d18240d0b967fb93d321d9b Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 25 Feb 2024 22:42:26 +0100 Subject: [PATCH 057/108] remove omnifunc config, sort lsp servers by name --- lua/lsp.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index eef7984..e2301ca 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,8 +1,6 @@ local on_attach = function(client, bufnr) local utils = require('utils') - utils.opt("o", "omnifunc", "v:lua.vim.lsp.omnifunc") - -- Mappings. utils.map("n", "K", "lua vim.lsp.buf.hover()") utils.map("n", "", "lua vim.lsp.buf.signature_help()") @@ -47,13 +45,14 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true; -- LSPs local servers = { + "clangd", + "gleam", "lua_ls", "ocamllsp", - "vimls", - "clangd", - "rnix", "pyright", + "rnix", "ruff_lsp", + "vimls", } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} From 65a01e8caa788e3ec8babd7bf82a1204a2781e66 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 25 Feb 2024 22:44:02 +0100 Subject: [PATCH 058/108] remove document highlight from server capabilities --- lua/lsp.lua | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index e2301ca..de496cb 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -21,20 +21,6 @@ local on_attach = function(client, bufnr) end client.server_capabilities.semanticTokensProvider = nil - - -- Set autocommands conditional on server_capabilities - if client.server_capabilities.document_highlight then - vim.api.nvim_exec([[ - hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow - hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow - hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], false) - end end local nvim_lsp = require('lspconfig') From 1b268b2e77be54d2425de45c8753adfcdb83b31d Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 25 Feb 2024 22:45:08 +0100 Subject: [PATCH 059/108] remove treesitter and filetype plugins --- lua/plugins/init.lua | 3 --- lua/plugins/treesitter.lua | 20 -------------------- 2 files changed, 23 deletions(-) delete mode 100644 lua/plugins/treesitter.lua diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 811f745..f32a1ff 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -38,7 +38,6 @@ require('packer').startup(function() } -- Statusbar, colors and syntax - use { 'nvim-treesitter/nvim-treesitter' } use { 'vim-airline/vim-airline' } use { 'vim-airline/vim-airline-themes' } @@ -68,7 +67,6 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams - use { 'nathom/filetype.nvim' } end) @@ -76,6 +74,5 @@ require('plugins.cmp') require('plugins.gitsigns') require('plugins.neogit') require('plugins.oil') -require('plugins.treesitter') require('plugins.telescope') require('plugins.venn') diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua deleted file mode 100644 index 4eb2d0f..0000000 --- a/lua/plugins/treesitter.lua +++ /dev/null @@ -1,20 +0,0 @@ -require('nvim-treesitter.configs').setup { - ensure_installed = { "lua", "rust", "elm", "python", "yaml", "toml" }, - auto_install = true, - highlight = { - enable = true, - additional_vim_regex_highlighting=true, - }, - ident = { - enable = true, - }, - rainbow = { - enable = true, - extended_mode = false, - max_file_lines = nil, - } -} - -vim.api.nvim_set_hl(0, "@variable", { }) -vim.api.nvim_set_hl(0, "@parameter", { }) -vim.api.nvim_set_hl(0, "@field", { }) From e70253835c454231192cac2179864938d033f78c Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 25 Feb 2024 22:45:46 +0100 Subject: [PATCH 060/108] try different telescope layout --- lua/plugins/telescope.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 236f6c4..77a45dd 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -4,6 +4,16 @@ local builtin = require('telescope.builtin') telescope.setup { defaults = { + layout_strategy = "vertical", + layout_config = { + vertical = { + prompt_position = "top", + }, + horizontal = { + prompt_position = "bottom", + }, + }, + sorting_strategy = "ascending", live_grep_arguments = { 'rg', '--hidden', '--no-ignore', '--color=never', '--with-filename', '--line-number', @@ -12,10 +22,14 @@ telescope.setup { }, pickers = { live_grep = { + layout_strategy = "horizontal", mappings = { i = { [""] = actions.to_fuzzy_refine }, }, }, + find_files = { + previewer = false, + }, }, } From 97128cf6e703821e5c04e5d165b1ae5530ec296e Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 26 Feb 2024 14:03:08 +0100 Subject: [PATCH 061/108] add terraform plugin and lsp config --- lua/lsp.lua | 1 + lua/plugins/init.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/lua/lsp.lua b/lua/lsp.lua index de496cb..507044b 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -38,6 +38,7 @@ local servers = { "pyright", "rnix", "ruff_lsp", + "terraformls", "vimls", } for _, lsp in ipairs(servers) do diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f32a1ff..7d2215c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -67,6 +67,7 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams + use { 'hashivim/vim-terraform' } end) From 07d13e67ae978e9f583981c82ca99e9bdd5863eb Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 01:12:42 +0100 Subject: [PATCH 062/108] use luasnip in cmp and telescope --- lua/plugins/cmp.lua | 20 ++++++++------------ lua/plugins/init.lua | 12 +++++++++--- lua/plugins/luasnip.lua | 5 +++++ lua/plugins/telescope.lua | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 lua/plugins/luasnip.lua diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 05ab1a0..d5829df 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -2,7 +2,6 @@ local utils = require('utils') -vim.cmd [[set shortmess+=c]] utils.opt('o', 'completeopt', 'menuone,noselect') local cmp = require('cmp') @@ -50,13 +49,13 @@ cmp.setup({ end }, snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - end, + expand = function(args) + local luasnip = require("luasnip") + if not luasnip then + return + end + luasnip.lsp_expand(args.body) + end, }, window = { completion = cmp.config.window.bordered(), @@ -74,10 +73,7 @@ cmp.setup({ }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. + { name = 'luasnip' }, -- For luasnip users. }, { { name = 'buffer' }, }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 7d2215c..ffe2b25 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -32,10 +32,15 @@ require('packer').startup(function() { 'hrsh7th/cmp-buffer' }, { 'hrsh7th/cmp-path' }, { 'hrsh7th/cmp-cmdline' }, - { 'hrsh7th/vim-vsnip' }, - { 'hrsh7th/vim-vsnip-integ' }, } } + use { 'L3MON4D3/LuaSnip' } + use { "rafamadriz/friendly-snippets" } + use { 'saadparwaiz1/cmp_luasnip' } + use { + "benfowler/telescope-luasnip.nvim", + module = "telescope._extensions.luasnip", -- if you wish to lazy-load + } -- Statusbar, colors and syntax use { 'vim-airline/vim-airline' } @@ -46,7 +51,7 @@ require('packer').startup(function() use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } use { 'folke/trouble.nvim' } -- lsp diagnostics - -- Languages + -- Languages that need a plugin to extend default lsp use { 'cespare/vim-toml' } use { 'gleam-lang/gleam.vim' } use { 'rust-lang/rust.vim' } @@ -71,6 +76,7 @@ require('packer').startup(function() end) +require('plugins.luasnip') require('plugins.cmp') require('plugins.gitsigns') require('plugins.neogit') diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua new file mode 100644 index 0000000..02dc094 --- /dev/null +++ b/lua/plugins/luasnip.lua @@ -0,0 +1,5 @@ +local languages = { + 'python', + 'rust', +} +require('luasnip.loaders.from_vscode').load({ include = languages }) -- Load only python snippets diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 77a45dd..4fc5d0d 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -2,6 +2,9 @@ local telescope = require('telescope') local actions = require('telescope.actions') local builtin = require('telescope.builtin') +local luasnip = require('luasnip') +local lst = telescope.extensions.luasnip + telescope.setup { defaults = { layout_strategy = "vertical", @@ -31,10 +34,22 @@ telescope.setup { previewer = false, }, }, + extensions = { + luasnip = { + search = function(entry) + return lst.filter_null(entry.context.trigger) .. " " .. + lst.filter_null(entry.context.name) .. " " .. + entry.ft .. " " .. + lst.filter_description(entry.context.name, entry.context.description) .. + lst.get_docstring(luasnip, entry.ft, entry.context)[1] + end + }, + } } vim.keymap.set('n', 'ff', builtin.find_files, {}) vim.keymap.set('n', 'fg', builtin.git_files, {}) +vim.keymap.set('n', 'fs', telescope.extensions.luasnip.luasnip, {}) vim.keymap.set('n', 'gg', builtin.live_grep, {}) vim.keymap.set('n', 'bb', builtin.buffers, {}) vim.keymap.set('n', 'hh', builtin.help_tags, {}) From 351d1690aaed96ec86cea54c147f89759b6d4797 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 02:19:14 +0100 Subject: [PATCH 063/108] remove luasnip config file, setup in plugins.init --- lua/plugins/init.lua | 28 +++++++++++++++++++++------- lua/plugins/luasnip.lua | 5 ----- 2 files changed, 21 insertions(+), 12 deletions(-) delete mode 100644 lua/plugins/luasnip.lua diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index ffe2b25..61411a5 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -34,12 +34,27 @@ require('packer').startup(function() { 'hrsh7th/cmp-cmdline' }, } } - use { 'L3MON4D3/LuaSnip' } - use { "rafamadriz/friendly-snippets" } - use { 'saadparwaiz1/cmp_luasnip' } - use { - "benfowler/telescope-luasnip.nvim", - module = "telescope._extensions.luasnip", -- if you wish to lazy-load + use { 'L3MON4D3/LuaSnip', + config = function () + local snippet_path = os.getenv("HOME") .. "/.config/nvim/snippets/" + if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then + vim.opt.rtp:append(snippet_path) + end + + require("luasnip").config.set_config({ + history = true, + updateevents = "TextChanged,TextChangedI", + delete_check_events = "TextChanged,InsertLeave", + }) + require("luasnip.loaders.from_lua").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_snipmate").lazy_load() + end, + requires = { + { "rafamadriz/friendly-snippets" }, + { 'saadparwaiz1/cmp_luasnip' }, + { "benfowler/telescope-luasnip.nvim" }, + }, } -- Statusbar, colors and syntax @@ -76,7 +91,6 @@ require('packer').startup(function() end) -require('plugins.luasnip') require('plugins.cmp') require('plugins.gitsigns') require('plugins.neogit') diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua deleted file mode 100644 index 02dc094..0000000 --- a/lua/plugins/luasnip.lua +++ /dev/null @@ -1,5 +0,0 @@ -local languages = { - 'python', - 'rust', -} -require('luasnip.loaders.from_vscode').load({ include = languages }) -- Load only python snippets From 6d04ade3e565ef8c6c8002949c66af5232558bf5 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 02:19:53 +0100 Subject: [PATCH 064/108] remove experimental telescope layout --- lua/plugins/telescope.lua | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 4fc5d0d..8ab6da0 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -2,20 +2,8 @@ local telescope = require('telescope') local actions = require('telescope.actions') local builtin = require('telescope.builtin') -local luasnip = require('luasnip') -local lst = telescope.extensions.luasnip - telescope.setup { defaults = { - layout_strategy = "vertical", - layout_config = { - vertical = { - prompt_position = "top", - }, - horizontal = { - prompt_position = "bottom", - }, - }, sorting_strategy = "ascending", live_grep_arguments = { 'rg', '--hidden', '--no-ignore', '--color=never', @@ -25,26 +13,11 @@ telescope.setup { }, pickers = { live_grep = { - layout_strategy = "horizontal", mappings = { i = { [""] = actions.to_fuzzy_refine }, }, }, - find_files = { - previewer = false, - }, }, - extensions = { - luasnip = { - search = function(entry) - return lst.filter_null(entry.context.trigger) .. " " .. - lst.filter_null(entry.context.name) .. " " .. - entry.ft .. " " .. - lst.filter_description(entry.context.name, entry.context.description) .. - lst.get_docstring(luasnip, entry.ft, entry.context)[1] - end - }, - } } vim.keymap.set('n', 'ff', builtin.find_files, {}) From df3dc407a77851b22f80f2f50d58cced7148f0fd Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 02:42:07 +0100 Subject: [PATCH 065/108] remove neotree, oil has everything i need --- lua/keymappings.lua | 1 - lua/plugins/init.lua | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 2f6751b..beaf457 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -13,4 +13,3 @@ utils.map("n", "sq", "setlocal nospell") utils.map("n", "", "set nonumber!") utils.map("n", "fe", "Oil") -utils.map("n", "", "Neotree toggle") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 61411a5..e53ee66 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -5,16 +5,6 @@ require('packer').startup(function() -- Packer can manage itself as an optional plugin use {'wbthomason/packer.nvim', opt = true } - use { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - requires = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - } - } - -- Fuzzy finder use { 'nvim-telescope/telescope.nvim', From dd18c0a9bc7a7644a86f8899079f71dd53cc9c1a Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 03:11:27 +0100 Subject: [PATCH 066/108] replace nlua with neodev --- lua/plugins/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index e53ee66..7211e0c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -60,7 +60,7 @@ require('packer').startup(function() use { 'cespare/vim-toml' } use { 'gleam-lang/gleam.vim' } use { 'rust-lang/rust.vim' } - use { 'tjdevries/nlua.nvim' } + use { 'folke/neodev.nvim' } -- Git use { From ccbf466c555bd614cacd1b32934ccf617fe82359 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 03:12:22 +0100 Subject: [PATCH 067/108] replace nvim-code-action-menu with actions-preview --- lua/lsp.lua | 1 - lua/plugins/init.lua | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 507044b..a9ea942 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -8,7 +8,6 @@ local on_attach = function(client, bufnr) utils.map("n", "", "lua vim.lsp.buf.rename()()") utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") utils.map("n", "]d", "lua vim.diagnostic.goto_next()") - utils.map("n", "ca", "lua vim.lsp.buf.code_action()") utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 7211e0c..a8ecbd4 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -53,7 +53,11 @@ require('packer').startup(function() -- LSP and related use { 'neovim/nvim-lspconfig' } - use { 'weilbith/nvim-code-action-menu', cmd = 'CodeActionMenu' } + use { 'aznhe21/actions-preview.nvim', + config = function() + vim.keymap.set("n", "ca", require("actions-preview").code_actions) + end, + } use { 'folke/trouble.nvim' } -- lsp diagnostics -- Languages that need a plugin to extend default lsp From b521d84e7ffab0322e4d0261332b70a50b05a2d5 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 03:14:06 +0100 Subject: [PATCH 068/108] fix wording --- lua/plugins/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index a8ecbd4..0fdfe46 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -60,7 +60,7 @@ require('packer').startup(function() } use { 'folke/trouble.nvim' } -- lsp diagnostics - -- Languages that need a plugin to extend default lsp + -- Plugins to extend builtin language support use { 'cespare/vim-toml' } use { 'gleam-lang/gleam.vim' } use { 'rust-lang/rust.vim' } From 0fabc551bda45d6698b1ffdeb868e771be08d565 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 12:49:19 +0100 Subject: [PATCH 069/108] fix lsp autoformatting on save tested python and rust --- lua/lsp.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index a9ea942..4ac70b8 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,5 +1,6 @@ local on_attach = function(client, bufnr) local utils = require('utils') + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- Mappings. utils.map("n", "K", "lua vim.lsp.buf.hover()") @@ -12,14 +13,16 @@ local on_attach = function(client, bufnr) utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - -- Set formatting keybinds conditional on server capabilities - if client.server_capabilities.document_formatting then - utils.map('n', 'lf', 'lua vim.lsp.buf.formatting()') - elseif client.server_capabilities.document_range_formatting then - utils.map('n', 'lf', 'lua vim.lsp.buf.range_formatting()') + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) end - - client.server_capabilities.semanticTokensProvider = nil end local nvim_lsp = require('lspconfig') From 8a348282a4815a5e03ad28a0b3628d1f047b36d9 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 12:49:43 +0100 Subject: [PATCH 070/108] remove obsolete config --- lua/lsp.lua | 3 --- lua/settings.lua | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 4ac70b8..0263b8d 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -28,9 +28,6 @@ end local nvim_lsp = require('lspconfig') local capabilities = vim.lsp.protocol.make_client_capabilities() --- show snippets in code completion popup -capabilities.textDocument.completion.completionItem.snippetSupport = true; - -- LSPs local servers = { "clangd", diff --git a/lua/settings.lua b/lua/settings.lua index a460000..0f52b6a 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -23,13 +23,11 @@ utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) utils.opt('o', 'clipboard','unnamed,unnamedplus') -vim.opt.autoindent = true -vim.opt.smartindent = true +vim.opt.autoindent = false +vim.opt.smartindent = false vim.opt.background = 'light' vim.opt.errorformat:prepend('%f|%l col %c|%m') vim.opt.fileformat = 'unix' -vim.opt.pastetoggle = '' -vim.opt.textwidth = 79 vim.opt.undofile = true -- Enable vimrc files per project and disable unsafe commands in project vimrc From a35b743b6244991bb05a5b42ce4dd6930c3e105c Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 20 Mar 2024 12:49:43 +0100 Subject: [PATCH 071/108] remove obsolete config and autoformat --- init.lua | 1 - lua/filetypes.lua | 4 - lua/lsp.lua | 23 +++--- lua/plugins/cmp.lua | 36 ++++----- lua/plugins/gitsigns.lua | 76 +++++++++--------- lua/plugins/init.lua | 144 +++++++++++++++++------------------ lua/plugins/neogit.lua | 2 +- lua/plugins/packer_setup.lua | 4 +- lua/plugins/venn.lua | 19 ++--- lua/settings.lua | 6 ++ lua/utils.lua | 10 +-- 11 files changed, 165 insertions(+), 160 deletions(-) delete mode 100644 lua/filetypes.lua diff --git a/init.lua b/init.lua index dc312bd..195a73d 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,5 @@ vim.g.mapleader = ' ' require('settings') require('plugins') require('lsp') -require('filetypes') require('theme') require('keymappings') diff --git a/lua/filetypes.lua b/lua/filetypes.lua deleted file mode 100644 index d29f858..0000000 --- a/lua/filetypes.lua +++ /dev/null @@ -1,4 +0,0 @@ -vim.cmd([[ - autocmd BufRead,BufNewFile *.bu set filetype=yaml - autocmd BufRead,BufNewFile *.ign set filetype=json -]]) diff --git a/lua/lsp.lua b/lua/lsp.lua index 0263b8d..e133dfa 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -13,6 +13,9 @@ local on_attach = function(client, bufnr) utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + -- use vim's default coloring + client.server_capabilities.semanticTokensProvider = nil + if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePre", { @@ -30,18 +33,18 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() -- LSPs local servers = { - "clangd", - "gleam", - "lua_ls", - "ocamllsp", - "pyright", - "rnix", - "ruff_lsp", - "terraformls", - "vimls", + "clangd", + "gleam", + "lua_ls", + "ocamllsp", + "pyright", + "rnix", + "ruff_lsp", + "terraformls", + "vimls", } for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach} + nvim_lsp[lsp].setup { capabilities = capabilities, on_attach = on_attach } end nvim_lsp.rust_analyzer.setup({ diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index d5829df..ac714a6 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -58,35 +58,37 @@ cmp.setup({ end, }, window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), }, completion = { autocomplete = false, }, mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + -- Accept currently selected item. + -- Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.confirm({ select = false }), }), sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, -- For luasnip users. + { name = 'nvim_lsp' }, + { name = 'luasnip' }, }, { - { name = 'buffer' }, + { name = 'buffer' }, }) }) -- Set configuration for specific filetype. ---cmp.setup.filetype('gitcommit', { --- sources = cmp.config.sources({ --- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). --- }, { --- { name = 'buffer' }, --- }) ---}) +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, + }, { + { name = 'buffer' }, + }) +}) -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline({ '/', '?' }, { diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 6a4f422..8b5ba0a 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,42 +1,42 @@ require('gitsigns').setup { - on_attach = function(bufnr) - local gs = package.loaded.gitsigns + on_attach = function(bufnr) + local gs = package.loaded.gitsigns - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, { expr = true }) + + map('n', '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, { expr = true }) + + -- Actions + map('n', 'hs', gs.stage_hunk) + map('n', 'hr', gs.reset_hunk) + map('v', 'hs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('v', 'hr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('n', 'hS', gs.stage_buffer) + map('n', 'hu', gs.undo_stage_hunk) + map('n', 'hR', gs.reset_buffer) + map('n', 'hp', gs.preview_hunk) + map('n', 'hb', function() gs.blame_line { full = true } end) + map('n', 'tb', gs.toggle_current_line_blame) + map('n', 'hd', gs.diffthis) + map('n', 'hD', function() gs.diffthis('~') end) + map('n', 'td', gs.toggle_deleted) + + -- Text object + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') end - - -- Navigation - map('n', ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, {expr=true}) - - map('n', '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, {expr=true}) - - -- Actions - map('n', 'hs', gs.stage_hunk) - map('n', 'hr', gs.reset_hunk) - map('v', 'hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) - map('v', 'hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) - map('n', 'hS', gs.stage_buffer) - map('n', 'hu', gs.undo_stage_hunk) - map('n', 'hR', gs.reset_buffer) - map('n', 'hp', gs.preview_hunk) - map('n', 'hb', function() gs.blame_line{full=true} end) - map('n', 'tb', gs.toggle_current_line_blame) - map('n', 'hd', gs.diffthis) - map('n', 'hD', function() gs.diffthis('~') end) - map('n', 'td', gs.toggle_deleted) - - -- Text object - map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') - end } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 0fdfe46..27b2b4f 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,88 +1,86 @@ require('plugins.packer_setup') require('packer').startup(function() + -- Packer can manage itself as an optional plugin + use { 'wbthomason/packer.nvim', opt = true } - -- Packer can manage itself as an optional plugin - use {'wbthomason/packer.nvim', opt = true } + -- Fuzzy finder + use { + 'nvim-telescope/telescope.nvim', + requires = { + { 'nvim-lua/popup.nvim' }, + { 'nvim-lua/plenary.nvim' }, + } + } - -- Fuzzy finder - use { - 'nvim-telescope/telescope.nvim', - requires = { - {'nvim-lua/popup.nvim'}, - {'nvim-lua/plenary.nvim'}, - } - } + -- Autocomplete and snippets + use { + 'hrsh7th/nvim-cmp', + requires = { + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-path' }, + { 'hrsh7th/cmp-cmdline' }, + } + } + use { 'L3MON4D3/LuaSnip', + config = function() + local snippet_path = os.getenv("HOME") .. "/.config/nvim/snippets/" + if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then + vim.opt.rtp:append(snippet_path) + end - -- Autocomplete and snippets - use { - 'hrsh7th/nvim-cmp', - requires = { - { 'hrsh7th/cmp-nvim-lsp' }, - { 'hrsh7th/cmp-buffer' }, - { 'hrsh7th/cmp-path' }, - { 'hrsh7th/cmp-cmdline' }, - } - } - use { 'L3MON4D3/LuaSnip', - config = function () - local snippet_path = os.getenv("HOME") .. "/.config/nvim/snippets/" - if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then - vim.opt.rtp:append(snippet_path) - end + require("luasnip").config.set_config({ + history = true, + updateevents = "TextChanged,TextChangedI", + delete_check_events = "TextChanged,InsertLeave", + }) + require("luasnip.loaders.from_lua").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_snipmate").lazy_load() + end, + requires = { + { "rafamadriz/friendly-snippets" }, + { 'saadparwaiz1/cmp_luasnip' }, + { "benfowler/telescope-luasnip.nvim" }, + }, + } - require("luasnip").config.set_config({ - history = true, - updateevents = "TextChanged,TextChangedI", - delete_check_events = "TextChanged,InsertLeave", - }) - require("luasnip.loaders.from_lua").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_snipmate").lazy_load() - end, - requires = { - { "rafamadriz/friendly-snippets" }, - { 'saadparwaiz1/cmp_luasnip' }, - { "benfowler/telescope-luasnip.nvim" }, - }, - } + -- Statusbar, colors and syntax + use { 'vim-airline/vim-airline' } + use { 'vim-airline/vim-airline-themes' } - -- Statusbar, colors and syntax - use { 'vim-airline/vim-airline' } - use { 'vim-airline/vim-airline-themes' } + -- LSP and related + use { 'neovim/nvim-lspconfig' } + use { 'aznhe21/actions-preview.nvim', + config = function() + vim.keymap.set("n", "ca", require("actions-preview").code_actions) + end, + } + use { 'folke/trouble.nvim' } -- lsp diagnostics - -- LSP and related - use { 'neovim/nvim-lspconfig' } - use { 'aznhe21/actions-preview.nvim', - config = function() - vim.keymap.set("n", "ca", require("actions-preview").code_actions) - end, - } - use { 'folke/trouble.nvim' } -- lsp diagnostics + -- Plugins to extend builtin language support + use { 'cespare/vim-toml' } + use { 'gleam-lang/gleam.vim' } + use { 'rust-lang/rust.vim' } + use { 'folke/neodev.nvim' } - -- Plugins to extend builtin language support - use { 'cespare/vim-toml' } - use { 'gleam-lang/gleam.vim' } - use { 'rust-lang/rust.vim' } - use { 'folke/neodev.nvim' } + -- Git + use { + 'NeogitOrg/neogit', + requires = { + { "nvim-lua/plenary.nvim" }, + { "sindrets/diffview.nvim" }, + }, + } + use { "lewis6991/gitsigns.nvim" } - -- Git - use { - 'NeogitOrg/neogit', - requires = { - { "nvim-lua/plenary.nvim" }, - { "sindrets/diffview.nvim" }, - }, - } - use { "lewis6991/gitsigns.nvim" } - - -- Filesystem browser - use { 'stevearc/oil.nvim' } - - -- Misc - use { 'jbyuki/venn.nvim' } -- ascii diagrams - use { 'hashivim/vim-terraform' } + -- Filesystem browser + use { 'stevearc/oil.nvim' } + -- Misc + use { 'jbyuki/venn.nvim' } -- ascii diagrams + use { 'hashivim/vim-terraform' } end) require('plugins.cmp') diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua index b08d583..605e648 100644 --- a/lua/plugins/neogit.lua +++ b/lua/plugins/neogit.lua @@ -1,5 +1,5 @@ local neogit = require('neogit') -neogit.setup { } +neogit.setup {} vim.keymap.set('n', '', neogit.open, {}) diff --git a/lua/plugins/packer_setup.lua b/lua/plugins/packer_setup.lua index 12ddb2a..9d1f10b 100644 --- a/lua/plugins/packer_setup.lua +++ b/lua/plugins/packer_setup.lua @@ -1,7 +1,7 @@ -- Auto install packer.nvim if not exists -local install_path = vim.fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' +local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim '..install_path) + vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) end vim.cmd [[packadd packer.nvim]] diff --git a/lua/plugins/venn.lua b/lua/plugins/venn.lua index 1a808b9..ee4f49c 100644 --- a/lua/plugins/venn.lua +++ b/lua/plugins/venn.lua @@ -3,19 +3,20 @@ function _G.Toggle_venn() local venn_enabled = vim.inspect(vim.b.venn_enabled) if venn_enabled == "nil" then vim.b.venn_enabled = true - vim.cmd[[setlocal ve=all]] + vim.cmd [[setlocal ve=all]] -- draw a line on HJKL keystokes - vim.api.nvim_buf_set_keymap(0, "n", "J", "j:VBox", {noremap = true}) - vim.api.nvim_buf_set_keymap(0, "n", "K", "k:VBox", {noremap = true}) - vim.api.nvim_buf_set_keymap(0, "n", "L", "l:VBox", {noremap = true}) - vim.api.nvim_buf_set_keymap(0, "n", "H", "h:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "J", "j:VBox", { noremap = true }) + vim.api.nvim_buf_set_keymap(0, "n", "K", "k:VBox", { noremap = true }) + vim.api.nvim_buf_set_keymap(0, "n", "L", "l:VBox", { noremap = true }) + vim.api.nvim_buf_set_keymap(0, "n", "H", "h:VBox", { noremap = true }) -- draw a box by pressing "f" with visual selection - vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox", { noremap = true }) else - vim.cmd[[setlocal ve=]] - vim.cmd[[mapclear ]] + vim.cmd [[setlocal ve=]] + vim.cmd [[mapclear ]] vim.b.venn_enabled = nil end end + -- toggle keymappings for venn using v -vim.api.nvim_set_keymap('n', 'v', ":lua Toggle_venn()", { noremap = true}) +vim.api.nvim_set_keymap('n', 'v', ":lua Toggle_venn()", { noremap = true }) diff --git a/lua/settings.lua b/lua/settings.lua index 0f52b6a..589094e 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -33,3 +33,9 @@ vim.opt.undofile = true -- Enable vimrc files per project and disable unsafe commands in project vimrc vim.opt.exrc = true vim.opt.secure = true + +-- unknown filetypes mappings +vim.cmd([[ + autocmd BufRead,BufNewFile *.bu set filetype=yaml + autocmd BufRead,BufNewFile *.ign set filetype=json +]]) diff --git a/lua/utils.lua b/lua/utils.lua index 846e425..8411ee5 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -1,6 +1,6 @@ -local utils = { } +local utils = {} -local scopes = {o = vim.o, b = vim.bo, w = vim.wo} +local scopes = { o = vim.o, b = vim.bo, w = vim.wo } function utils.opt(scope, key, value) scopes[scope][key] = value @@ -8,9 +8,9 @@ function utils.opt(scope, key, value) end function utils.map(mode, lhs, rhs, opts) - local options = { noremap = true, silent = true } - if opts then options = vim.tbl_extend('force', options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) + local options = { noremap = true, silent = true } + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) end return utils From 727a6bcfbc1b1bad0c2bfe1a001d6e241a8041c4 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 27 Mar 2024 02:41:32 +0100 Subject: [PATCH 072/108] add flutter plugin and config --- lua/lsp.lua | 19 +++++++----- lua/plugins/flutter.lua | 66 +++++++++++++++++++++++++++++++++++++++++ lua/plugins/init.lua | 8 +++++ 3 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 lua/plugins/flutter.lua diff --git a/lua/lsp.lua b/lua/lsp.lua index e133dfa..a659fe2 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -13,9 +13,6 @@ local on_attach = function(client, bufnr) utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - -- use vim's default coloring - client.server_capabilities.semanticTokensProvider = nil - if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePre", { @@ -26,6 +23,12 @@ local on_attach = function(client, bufnr) end, }) end + + -- use vim's default coloring + client.server_capabilities.semanticTokensProvider = nil + for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do + vim.api.nvim_set_hl(0, group, {}) + end end local nvim_lsp = require('lspconfig') @@ -34,6 +37,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() -- LSPs local servers = { "clangd", + "dartls", "gleam", "lua_ls", "ocamllsp", @@ -63,9 +67,9 @@ nvim_lsp.rust_analyzer.setup({ enable = true, }, }, - --procMacro = { - -- enable = true - --}, + procMacro = { + enable = true + }, checkOnSave = { command = "clippy", }, @@ -105,8 +109,7 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = do local method = "textDocument/publishDiagnostics" local default_handler = vim.lsp.handlers[method] - vim.lsp.handlers[method] = function(err, method, result, client_id, bufnr, - config) + vim.lsp.handlers[method] = function(err, method, result, client_id, bufnr, config) default_handler(err, method, result, client_id, bufnr, config) local diagnostics = vim.diagnostic.get() local qflist = {} diff --git a/lua/plugins/flutter.lua b/lua/plugins/flutter.lua new file mode 100644 index 0000000..5bafc9e --- /dev/null +++ b/lua/plugins/flutter.lua @@ -0,0 +1,66 @@ +require("flutter-tools").setup { + ui = { + border = "rounded", + notification_style = 'native' + }, + decorations = { + statusline = { + app_version = false, + device = false, + project_config = false, + } + }, + debugger = { + enabled = false, + run_via_dap = false, + exception_breakpoints = {}, + --register_configurations = function(paths) + -- require("dap").configurations.dart = { + -- + -- } + --end, + }, + flutter_path = "/usr/bin/flutter", + flutter_lookup_cmd = nil, + root_patterns = { ".git", "pubspec.yaml" }, + fvm = false, + widget_guides = { + enabled = false, + }, + closing_tags = { + highlight = "Comment", + prefix = "/ ", + enabled = true, + }, + dev_log = { + enabled = true, + notify_errors = false, + open_cmd = "tabedit", + }, + dev_tools = { + autostart = false, + auto_open_browser = false, + }, + outline = { + open_cmd = "30vnew", + auto_open = false, + }, + lsp = { + color = { + enabled = false, + background = false, + background_color = nil, + foreground = false, + virtual_text = false, + virtual_text_str = "■", + }, + settings = { + showTodos = true, + completeFunctionCalls = true, + -- analysisExcludedFolders = { "" }, + renameFilesWithClasses = "prompt", + enableSnippets = true, + updateImportsOnRename = true, + } + } +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 27b2b4f..1710b77 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -81,6 +81,13 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams use { 'hashivim/vim-terraform' } + use { + 'akinsho/flutter-tools.nvim', + requires = { + 'nvim-lua/plenary.nvim', + 'stevearc/dressing.nvim', -- optional for vim.ui.select + }, + } end) require('plugins.cmp') @@ -89,3 +96,4 @@ require('plugins.neogit') require('plugins.oil') require('plugins.telescope') require('plugins.venn') +require("plugins.flutter") From 73d0d7c14d6cab8132fe74d913dde3f55eb89bee Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 18 Apr 2024 01:35:21 +0200 Subject: [PATCH 073/108] fix nospell binding --- lua/keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index beaf457..fab9bb7 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -9,7 +9,7 @@ utils.map("n", "", "bp") -- Turn spellchecker on and off utils.map("n", "se", "setlocal spell spelllang=en_us") -utils.map("n", "sq", "setlocal nospell") +utils.map("n", "sq", "setlocal nospell") utils.map("n", "", "set nonumber!") utils.map("n", "fe", "Oil") From c2c40dbe0379a8f8e6622b49206f8c9ecd633b5c Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 18 Apr 2024 14:45:57 +0200 Subject: [PATCH 074/108] fix whitespace in settings --- lua/settings.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/settings.lua b/lua/settings.lua index 589094e..f54617c 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -14,14 +14,14 @@ utils.opt('b', 'softtabstop', indent) utils.opt('b', 'smartindent', true) utils.opt('o', 'hidden', true) utils.opt('o', 'ignorecase', true) -utils.opt('o', 'scrolloff', 4 ) +utils.opt('o', 'scrolloff', 4) utils.opt('o', 'shiftround', true) utils.opt('o', 'smartcase', true) utils.opt('o', 'splitbelow', true) utils.opt('o', 'splitright', true) utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) -utils.opt('o', 'clipboard','unnamed,unnamedplus') +utils.opt('o', 'clipboard', 'unnamed,unnamedplus') vim.opt.autoindent = false vim.opt.smartindent = false From 64d04c8618188b55e9b60aed910c72f6e67bea72 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 18 Apr 2024 14:46:39 +0200 Subject: [PATCH 075/108] make folding and pmenu bckg grey --- lua/theme.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/theme.lua b/lua/theme.lua index f55229b..f3c8dd8 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,4 +1,4 @@ --- Highlight trailing whitespace (darker red) and remove all with Ctrl+k +-- Highlight trailing whitespace (darker red) and remove all with Ctrl+w vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Thu, 18 Apr 2024 14:47:34 +0200 Subject: [PATCH 076/108] make cmp popups with grey bckg and no borders --- lua/plugins/cmp.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index ac714a6..4c2d8c9 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -58,8 +58,13 @@ cmp.setup({ end, }, window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), + completion = { + border = nil, + }, + documentation = { + border = nil, + max_height = 2000, + } }, completion = { autocomplete = false, From eaaf6db7ada547cc17dc69608f18226dc4632129 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 18 Apr 2024 14:49:55 +0200 Subject: [PATCH 077/108] decrease space between cmp symbols --- lua/plugins/cmp.lua | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 4c2d8c9..4d691b9 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -6,31 +6,31 @@ utils.opt('o', 'completeopt', 'menuone,noselect') local cmp = require('cmp') local cmp_kinds = { - Text = ' ', - Method = '󰊕 ', - Function = '󰊕 ', - Constructor = ' ', - Field = ' ', - Variable = ' ', - Class = ' ', - Interface = ' ', - Module = ' ', - Property = ' ', - Unit = ' ', - Value = ' ', - Enum = ' ', - Keyword = ' ', - Snippet = ' ', - Color = ' ', - File = ' ', - Reference = ' ', - Folder = ' ', - EnumMember = ' ', - Constant = ' ', - Struct = ' ', - Event = ' ', - Operator = ' ', - TypeParameter = ' ', + Text = ' ', + Method = '󰊕 ', + Function = '󰊕 ', + Constructor = ' ', + Field = ' ', + Variable = ' ', + Class = ' ', + Interface = ' ', + Module = ' ', + Property = ' ', + Unit = ' ', + Value = ' ', + Enum = ' ', + Keyword = ' ', + Snippet = ' ', + Color = ' ', + File = ' ', + Reference = ' ', + Folder = ' ', + EnumMember = ' ', + Constant = ' ', + Struct = ' ', + Event = ' ', + Operator = ' ', + TypeParameter = ' ', } cmp.setup({ From d79cbd69892ae02a870372739ecddb36ad92510d Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 12:27:13 +0200 Subject: [PATCH 078/108] Revert to vim's default term colorscheme --- lua/theme.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/theme.lua b/lua/theme.lua index f3c8dd8..575dab9 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -2,6 +2,10 @@ vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Mon, 10 Jun 2024 12:35:24 +0200 Subject: [PATCH 079/108] fix comment for whitespace highlighting --- lua/theme.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/theme.lua b/lua/theme.lua index 575dab9..3d4fe4f 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,4 +1,4 @@ --- Highlight trailing whitespace (darker red) and remove all with Ctrl+w +-- Highlight trailing whitespace (darker red) vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Mon, 10 Jun 2024 12:37:48 +0200 Subject: [PATCH 080/108] show comments in vim's default color (blue) --- lua/theme.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/theme.lua b/lua/theme.lua index 3d4fe4f..37e1f6d 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -8,7 +8,6 @@ vim.cmd 'set notermguicolors' vim.cmd 'highlight Visual cterm=bold ctermbg=Grey ctermfg=none' vim.cmd 'highlight Search ctermfg=Black' -vim.cmd 'highlight Comment ctermfg=DarkGrey' vim.cmd 'highlight SignColumn ctermbg=none' vim.cmd 'highlight LineNr ctermbg=none ctermfg=DarkGrey' vim.cmd 'highlight Folded ctermbg=LightGrey ctermfg=Black' From 7ca16fc0bfcbef4f4bdcda3c64df82dfc60af7f5 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 12:38:11 +0200 Subject: [PATCH 081/108] lighter line numbers --- lua/theme.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/theme.lua b/lua/theme.lua index 37e1f6d..6e70b72 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -9,7 +9,7 @@ vim.cmd 'set notermguicolors' vim.cmd 'highlight Visual cterm=bold ctermbg=Grey ctermfg=none' vim.cmd 'highlight Search ctermfg=Black' vim.cmd 'highlight SignColumn ctermbg=none' -vim.cmd 'highlight LineNr ctermbg=none ctermfg=DarkGrey' +vim.cmd 'highlight LineNr ctermbg=none ctermfg=LightGrey' vim.cmd 'highlight Folded ctermbg=LightGrey ctermfg=Black' vim.cmd 'highlight Pmenu ctermbg=253 ctermfg=Black' vim.cmd 'let g:airline_theme=\'papercolor\'' From fa255704a151f9d9a3acaeeb2a20f4148245f4ff Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 12:39:21 +0200 Subject: [PATCH 082/108] fix trailing whitespace highlight --- lua/theme.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/theme.lua b/lua/theme.lua index 6e70b72..9151c72 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,11 +1,11 @@ --- Highlight trailing whitespace (darker red) -vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' -vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Mon, 10 Jun 2024 13:12:26 +0200 Subject: [PATCH 083/108] replace utils.map with vim.keymap.set --- lua/keymappings.lua | 14 +++++++------- lua/lsp.lua | 18 +++++++++--------- lua/plugins/telescope.lua | 19 +++++++++++-------- lua/utils.lua | 6 ------ 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index fab9bb7..9fe6679 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,15 +1,15 @@ local utils = require('utils') -- Clear trailing whitespace -utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") +vim.keymap.set("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") -- Use tab and shift+tab to cycle buffers -utils.map("n", "", "bn") -utils.map("n", "", "bp") +vim.keymap.set("n", "", "bn") +vim.keymap.set("n", "", "bp") -- Turn spellchecker on and off -utils.map("n", "se", "setlocal spell spelllang=en_us") -utils.map("n", "sq", "setlocal nospell") +vim.keymap.set("n", "se", "setlocal spell spelllang=en_us") +vim.keymap.set("n", "sq", "setlocal nospell") -utils.map("n", "", "set nonumber!") -utils.map("n", "fe", "Oil") +vim.keymap.set("n", "", "set nonumber!") +vim.keymap.set("n", "fe", "Oil") diff --git a/lua/lsp.lua b/lua/lsp.lua index a659fe2..75f79c1 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -3,15 +3,15 @@ local on_attach = function(client, bufnr) local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- Mappings. - utils.map("n", "K", "lua vim.lsp.buf.hover()") - utils.map("n", "", "lua vim.lsp.buf.signature_help()") - utils.map("n", "", "lua vim.lsp.buf.type_definition()") - utils.map("n", "", "lua vim.lsp.buf.rename()()") - utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") - utils.map("n", "]d", "lua vim.diagnostic.goto_next()") - utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") - utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + vim.keymaps.set("n", "K", "lua vim.lsp.buf.hover()") + vim.keymaps.set("n", "", "lua vim.lsp.buf.signature_help()") + vim.keymaps.set("n", "", "lua vim.lsp.buf.type_definition()") + vim.keymaps.set("n", "", "lua vim.lsp.buf.rename()()") + vim.keymaps.set("n", "[d", "lua vim.diagnostic.goto_prev()") + vim.keymaps.set("n", "]d", "lua vim.diagnostic.goto_next()") + vim.keymaps.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") + vim.keymaps.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + vim.keymaps.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 8ab6da0..e438d35 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -20,15 +20,18 @@ telescope.setup { }, } +vim.keymap.set('n', 'ss', telescope.extensions.luasnip.luasnip, {}) + vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.git_files, {}) -vim.keymap.set('n', 'fs', telescope.extensions.luasnip.luasnip, {}) -vim.keymap.set('n', 'gg', builtin.live_grep, {}) -vim.keymap.set('n', 'bb', builtin.buffers, {}) -vim.keymap.set('n', 'hh', builtin.help_tags, {}) -vim.keymap.set('n', 'ss', builtin.lsp_dynamic_workspace_symbols, {}) -vim.keymap.set('n', 'sd', builtin.lsp_document_symbols, {}) -vim.keymap.set('n', 'dd', builtin.diagnostics, {}) +vim.keymap.set('n', 'ffg', builtin.git_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fs', builtin.lsp_dynamic_workspace_symbols, {}) +vim.keymap.set('n', 'fsd', builtin.lsp_document_symbols, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) +vim.keymap.set('n', 'fd', builtin.diagnostics, {}) + +-- Use telescope for lsp definitions, calls and references vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) vim.keymap.set('n', 'gr', builtin.lsp_references, {}) vim.keymap.set('n', 'gi', builtin.lsp_implementations, {}) diff --git a/lua/utils.lua b/lua/utils.lua index 8411ee5..1da951a 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -7,10 +7,4 @@ function utils.opt(scope, key, value) if scope ~= 'o' then scopes['o'][key] = value end end -function utils.map(mode, lhs, rhs, opts) - local options = { noremap = true, silent = true } - if opts then options = vim.tbl_extend('force', options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end - return utils From fd32c079c963afeb4f5451c4aa7a251f3473bd13 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 15:36:36 +0200 Subject: [PATCH 084/108] reformat cmp sources --- lua/plugins/cmp.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 4d691b9..1dcea37 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -78,12 +78,15 @@ cmp.setup({ -- Set `select` to `false` to only confirm explicitly selected items. [''] = cmp.mapping.confirm({ select = false }), }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, { - { name = 'buffer' }, - }) + sources = cmp.config.sources( + { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, + { + { name = 'buffer' }, + } + ) }) -- Set configuration for specific filetype. From e42d6245a5cc5ea24055ed2ed0f252d6202ec4e9 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 15:49:21 +0200 Subject: [PATCH 085/108] fix typo (vim.keymap) --- lua/lsp.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 75f79c1..039429f 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -3,15 +3,15 @@ local on_attach = function(client, bufnr) local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- Mappings. - vim.keymaps.set("n", "K", "lua vim.lsp.buf.hover()") - vim.keymaps.set("n", "", "lua vim.lsp.buf.signature_help()") - vim.keymaps.set("n", "", "lua vim.lsp.buf.type_definition()") - vim.keymaps.set("n", "", "lua vim.lsp.buf.rename()()") - vim.keymaps.set("n", "[d", "lua vim.diagnostic.goto_prev()") - vim.keymaps.set("n", "]d", "lua vim.diagnostic.goto_next()") - vim.keymaps.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") - vim.keymaps.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - vim.keymaps.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") + vim.keymap.set("n", "", "lua vim.lsp.buf.signature_help()") + vim.keymap.set("n", "", "lua vim.lsp.buf.type_definition()") + vim.keymap.set("n", "", "lua vim.lsp.buf.rename()()") + vim.keymap.set("n", "[d", "lua vim.diagnostic.goto_prev()") + vim.keymap.set("n", "]d", "lua vim.diagnostic.goto_next()") + vim.keymap.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") + vim.keymap.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + vim.keymap.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) From 2efe116082113d38c24d0348ed72f0ce35df44f9 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 15:49:37 +0200 Subject: [PATCH 086/108] remove flutter plugins --- lua/plugins/init.lua | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 1710b77..27b2b4f 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -81,13 +81,6 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams use { 'hashivim/vim-terraform' } - use { - 'akinsho/flutter-tools.nvim', - requires = { - 'nvim-lua/plenary.nvim', - 'stevearc/dressing.nvim', -- optional for vim.ui.select - }, - } end) require('plugins.cmp') @@ -96,4 +89,3 @@ require('plugins.neogit') require('plugins.oil') require('plugins.telescope') require('plugins.venn') -require("plugins.flutter") From 9a29f155560f147a8f0f7b94cad2c19ae7557c95 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sat, 20 Jul 2024 02:55:46 +0200 Subject: [PATCH 087/108] oil: don't show git ignored files and folders --- lua/plugins/oil.lua | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index dadcb0c..3503f42 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -1,3 +1,27 @@ +local git_ignored = setmetatable({}, { + __index = function(self, key) + local proc = vim.system( + { "git", "ls-files", "--ignored", "--exclude-standard", "--others", "--directory" }, + { + cwd = key, + text = true, + } + ) + local result = proc:wait() + local ret = {} + if result.code == 0 then + for line in vim.gsplit(result.stdout, "\n", { plain = true, trimempty = true }) do + -- Remove trailing slash + line = line:gsub("/$", "") + table.insert(ret, line) + end + end + + rawset(self, key, ret) + return ret + end, +}) + require('oil').setup({ default_file_explorer = true, -- Id is automatically added at the beginning, and name at the end @@ -61,8 +85,16 @@ require('oil').setup({ -- Show files and directories that start with "." show_hidden = false, -- This function defines what is considered a "hidden" file - is_hidden_file = function(name, bufnr) - return vim.startswith(name, ".") + is_hidden_file = function(name, _) + if vim.startswith(name, ".") then + return true + end + local dir = require("oil").get_current_dir() + -- if no local directory (e.g. for ssh connections), always show + if not dir then + return false + end + return vim.list_contains(git_ignored[dir], name) end, -- This function defines what will never be shown, even when `show_hidden` is set is_always_hidden = function(name, bufnr) From b3b051355ae4933cd67a9b9103c4abf2cc93e784 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 22 Jul 2024 09:08:34 +0200 Subject: [PATCH 088/108] add neogit config and fix ebvious errors with keymaps --- init.lua | 2 +- lua/keymappings.lua | 3 + lua/plugins/init.lua | 5 + lua/plugins/neogit.lua | 300 +++++++++++++++++++++++++++++++++++++- lua/plugins/telescope.lua | 6 +- lua/settings.lua | 3 + lua/theme.lua | 2 +- 7 files changed, 314 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 195a73d..33bcdf8 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,6 @@ vim.g.mapleader = ' ' -- Sensible defaults require('settings') require('plugins') -require('lsp') require('theme') +require('lsp') require('keymappings') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9fe6679..23f0484 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -13,3 +13,6 @@ vim.keymap.set("n", "sq", "setlocal nospell") vim.keymap.set("n", "", "set nonumber!") vim.keymap.set("n", "fe", "Oil") + +vim.keymap.set("n", ']d', "lua vim.diagnostic.goto_next()") +vim.keymap.set("n", '[d', "lua vim.diagnostic.goto_prev()") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 27b2b4f..9b2988e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -81,6 +81,11 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams use { 'hashivim/vim-terraform' } + + -- intellij idea to nvim o_O + use { 'Shougo/deoplete.nvim' } + use { 'beeender/Comrade' } + end) require('plugins.cmp') diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua index 605e648..9768e2b 100644 --- a/lua/plugins/neogit.lua +++ b/lua/plugins/neogit.lua @@ -1,5 +1,301 @@ local neogit = require('neogit') -neogit.setup {} - vim.keymap.set('n', '', neogit.open, {}) + +neogit.setup { + -- Hides the hints at the top of the status buffer + disable_hint = false, + -- Disables changing the buffer highlights based on where the cursor is. + disable_context_highlighting = false, + -- Disables signs for sections/items/hunks + disable_signs = false, + -- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to + -- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in + -- normal mode. + disable_insert_on_commit = "auto", + -- When enabled, will watch the `.git/` directory for changes and refresh the status buffer in response to filesystem + -- events. + filewatcher = { + interval = 1000, + enabled = true, + }, + -- "ascii" is the graph the git CLI generates + -- "unicode" is the graph like https://github.com/rbong/vim-flog + graph_style = "ascii", + -- Used to generate URL's for branch popup action "pull request". + git_services = { + ["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1", + ["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1", + ["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}", + }, + -- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf + -- sorter instead. By default, this function returns `nil`. + telescope_sorter = function() + return require("telescope").extensions.fzf.native_fzf_sorter() + end, + -- Persist the values of switches/options within and across sessions + remember_settings = true, + -- Scope persisted settings on a per-project basis + use_per_project_settings = true, + -- Table of settings to never persist. Uses format "Filetype--cli-value" + ignored_settings = { + "NeogitPushPopup--force-with-lease", + "NeogitPushPopup--force", + "NeogitPullPopup--rebase", + "NeogitCommitPopup--allow-empty", + "NeogitRevertPopup--no-edit", + }, + -- Configure highlight group features + highlight = { + italic = true, + bold = true, + underline = true + }, + -- Set to false if you want to be responsible for creating _ALL_ keymappings + use_default_keymaps = true, + -- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size. + -- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it. + auto_refresh = true, + -- Value used for `--sort` option for `git branch` command + -- By default, branches will be sorted by commit date descending + -- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt + -- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options + sort_branches = "-committerdate", + -- Change the default way of opening neogit + kind = "tab", + -- Disable line numbers and relative line numbers + disable_line_numbers = true, + -- The time after which an output console is shown for slow running commands + console_timeout = 2000, + -- Automatically show console if a command takes more than console_timeout milliseconds + auto_show_console = true, + -- Automatically close the console if the process exits with a 0 (success) status + auto_close_console = true, + status = { + show_head_commit_hash = true, + recent_commit_count = 10, + HEAD_padding = 10, + HEAD_folded = false, + mode_padding = 3, + mode_text = { + M = "modified", + N = "new file", + A = "added", + D = "deleted", + C = "copied", + U = "updated", + R = "renamed", + DD = "unmerged", + AU = "unmerged", + UD = "unmerged", + UA = "unmerged", + DU = "unmerged", + AA = "unmerged", + UU = "unmerged", + ["?"] = "", + }, + }, + commit_editor = { + kind = "tab", + show_staged_diff = true, + -- Accepted values: + -- "split" to show the staged diff below the commit editor + -- "vsplit" to show it to the right + -- "split_above" Like :top split + -- "vsplit_left" like :vsplit, but open to the left + -- "auto" "vsplit" if window would have 80 cols, otherwise "split" + staged_diff_split_kind = "split" + }, + commit_select_view = { + kind = "tab", + }, + commit_view = { + kind = "vsplit", + verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary + }, + log_view = { + kind = "tab", + }, + rebase_editor = { + kind = "auto", + }, + reflog_view = { + kind = "tab", + }, + merge_editor = { + kind = "auto", + }, + tag_editor = { + kind = "auto", + }, + preview_buffer = { + kind = "split", + }, + popup = { + kind = "split", + }, + signs = { + -- { CLOSED, OPENED } + hunk = { "", "" }, + item = { ">", "v" }, + section = { ">", "v" }, + }, + -- Each Integration is auto-detected through plugin presence, however, it can be disabled by setting to `false` + integrations = { + -- If enabled, use telescope for menu selection rather than vim.ui.select. + -- Allows multi-select and some things that vim.ui.select doesn't. + telescope = nil, + -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `diffview`. + -- The diffview integration enables the diff popup. + -- + -- Requires you to have `sindrets/diffview.nvim` installed. + diffview = nil, + + -- If enabled, uses fzf-lua for menu selection. If the telescope integration + -- is also selected then telescope is used instead + -- Requires you to have `ibhagwan/fzf-lua` installed. + fzf_lua = nil, + }, + sections = { + -- Reverting/Cherry Picking + sequencer = { + folded = false, + hidden = false, + }, + untracked = { + folded = false, + hidden = false, + }, + unstaged = { + folded = false, + hidden = false, + }, + staged = { + folded = false, + hidden = false, + }, + stashes = { + folded = true, + hidden = false, + }, + unpulled_upstream = { + folded = true, + hidden = false, + }, + unmerged_upstream = { + folded = false, + hidden = false, + }, + unpulled_pushRemote = { + folded = true, + hidden = false, + }, + unmerged_pushRemote = { + folded = false, + hidden = false, + }, + recent = { + folded = true, + hidden = false, + }, + rebase = { + folded = true, + hidden = false, + }, + }, + mappings = { + commit_editor = { + ["q"] = "Close", + [""] = "Submit", + [""] = "Abort", + }, + commit_editor_I = { + [""] = "Submit", + [""] = "Abort", + }, + rebase_editor = { + ["p"] = "Pick", + ["r"] = "Reword", + ["e"] = "Edit", + ["s"] = "Squash", + ["f"] = "Fixup", + ["x"] = "Execute", + ["d"] = "Drop", + ["b"] = "Break", + ["q"] = "Close", + [""] = "OpenCommit", + ["gk"] = "MoveUp", + ["gj"] = "MoveDown", + [""] = "Submit", + [""] = "Abort", + ["[c"] = "OpenOrScrollUp", + ["]c"] = "OpenOrScrollDown", + }, + rebase_editor_I = { + [""] = "Submit", + [""] = "Abort", + }, + finder = { + [""] = "Select", + [""] = "Close", + [""] = "Close", + [""] = "Next", + [""] = "Previous", + [""] = "Next", + [""] = "Previous", + [""] = "MultiselectToggleNext", + [""] = "MultiselectTogglePrevious", + [""] = "NOP", + }, + -- Setting any of these to `false` will disable the mapping. + popup = { + ["?"] = "HelpPopup", + ["A"] = "CherryPickPopup", + ["D"] = "DiffPopup", + ["M"] = "RemotePopup", + ["P"] = "PushPopup", + ["X"] = "ResetPopup", + ["Z"] = "StashPopup", + ["b"] = "BranchPopup", + ["B"] = "BisectPopup", + ["c"] = "CommitPopup", + ["f"] = "FetchPopup", + ["l"] = "LogPopup", + ["m"] = "MergePopup", + ["p"] = "PullPopup", + ["r"] = "RebasePopup", + ["v"] = "RevertPopup", + ["w"] = "WorktreePopup", + }, + status = { + ["k"] = "MoveUp", + ["j"] = "MoveDown", + ["q"] = "Close", + ["o"] = "OpenTree", + ["I"] = "InitRepo", + ["1"] = "Depth1", + ["2"] = "Depth2", + ["3"] = "Depth3", + ["4"] = "Depth4", + [""] = "Toggle", + ["x"] = "Discard", + ["s"] = "Stage", + ["S"] = "StageUnstaged", + [""] = "StageAll", + ["K"] = "Untrack", + ["u"] = "Unstage", + ["U"] = "UnstageStaged", + ["$"] = "CommandHistory", + ["Y"] = "YankSelected", + [""] = "RefreshBuffer", + [""] = "GoToFile", + [""] = "VSplitOpen", + [""] = "SplitOpen", + [""] = "TabOpen", + ["{"] = "GoToPreviousHunkHeader", + ["}"] = "GoToNextHunkHeader", + ["[c"] = "OpenOrScrollUp", + ["]c"] = "OpenOrScrollDown", + }, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index e438d35..9c297c7 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -23,13 +23,13 @@ telescope.setup { vim.keymap.set('n', 'ss', telescope.extensions.luasnip.luasnip, {}) vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'ffg', builtin.git_files, {}) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fg', builtin.git_files, {}) +vim.keymap.set('n', 'gg', builtin.live_grep, {}) vim.keymap.set('n', 'fb', builtin.buffers, {}) vim.keymap.set('n', 'fs', builtin.lsp_dynamic_workspace_symbols, {}) vim.keymap.set('n', 'fsd', builtin.lsp_document_symbols, {}) vim.keymap.set('n', 'fh', builtin.help_tags, {}) -vim.keymap.set('n', 'fd', builtin.diagnostics, {}) +vim.keymap.set('n', 'dd', builtin.diagnostics, {}) -- Use telescope for lsp definitions, calls and references vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) diff --git a/lua/settings.lua b/lua/settings.lua index f54617c..3101d37 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -22,6 +22,7 @@ utils.opt('o', 'splitright', true) utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) utils.opt('o', 'clipboard', 'unnamed,unnamedplus') +utils.opt('o', 'mouse', 'a') vim.opt.autoindent = false vim.opt.smartindent = false @@ -37,5 +38,7 @@ vim.opt.secure = true -- unknown filetypes mappings vim.cmd([[ autocmd BufRead,BufNewFile *.bu set filetype=yaml + autocmd BufRead,BufNewFile *.yml.example set filetype=yaml + autocmd BufRead,BufNewFile *.yaml.example set filetype=yaml autocmd BufRead,BufNewFile *.ign set filetype=json ]]) diff --git a/lua/theme.lua b/lua/theme.lua index 9151c72..77360ef 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,5 +1,5 @@ -- Revert to vim's default term colorscheme -vim.cmd 'colorscheme vim' +--vim.cmd 'colorscheme vim' vim.cmd 'set notermguicolors' -- Highlight trailing whitespace (darker red) From 5c8e114e44c08d8a1c6eff46330be4c68c359a0e Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 12 Aug 2024 16:10:35 +0200 Subject: [PATCH 089/108] remove utils module --- lua/keymappings.lua | 2 -- lua/lsp.lua | 1 - lua/plugins/cmp.lua | 4 +--- lua/plugins/init.lua | 11 ++++++++++ lua/plugins/oil.lua | 2 +- lua/settings.lua | 50 +++++++++++++++++++------------------------- lua/utils.lua | 10 --------- 7 files changed, 35 insertions(+), 45 deletions(-) delete mode 100644 lua/utils.lua diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 23f0484..000918e 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,5 +1,3 @@ -local utils = require('utils') - -- Clear trailing whitespace vim.keymap.set("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") diff --git a/lua/lsp.lua b/lua/lsp.lua index 039429f..9d59498 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,5 +1,4 @@ local on_attach = function(client, bufnr) - local utils = require('utils') local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- Mappings. diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 1dcea37..cfd0ba5 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,8 +1,6 @@ -- Completion plugin config -local utils = require('utils') - -utils.opt('o', 'completeopt', 'menuone,noselect') +vim.opt.completeopt = 'menuone,noselect' local cmp = require('cmp') local cmp_kinds = { diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 9b2988e..7412466 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -86,6 +86,17 @@ require('packer').startup(function() use { 'Shougo/deoplete.nvim' } use { 'beeender/Comrade' } + use({ + 'MeanderingProgrammer/render-markdown.nvim', + after = { 'nvim-treesitter' }, + requires = { 'echasnovski/mini.nvim', opt = true }, -- if you use the mini.nvim suite + -- requires = { 'echasnovski/mini.icons', opt = true }, -- if you use standalone mini plugins + -- requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- if you prefer nvim-web-devicons + config = function() + require('render-markdown').setup({}) + end, + }) + end) require('plugins.cmp') diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 3503f42..fc55dd9 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -94,7 +94,7 @@ require('oil').setup({ if not dir then return false end - return vim.list_contains(git_ignored[dir], name) + -- return vim.list_contains(git_ignored[dir], name) end, -- This function defines what will never be shown, even when `show_hidden` is set is_always_hidden = function(name, bufnr) diff --git a/lua/settings.lua b/lua/settings.lua index 3101d37..4f55cb6 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -1,44 +1,38 @@ -local utils = require('utils') local indent = 4 -vim.cmd 'syntax enable' -vim.cmd 'filetype plugin indent on' --- --- Highlight on yank -vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' - -utils.opt('b', 'expandtab', true) -utils.opt('b', 'shiftwidth', indent) -utils.opt('b', 'tabstop', indent) -utils.opt('b', 'softtabstop', indent) -utils.opt('b', 'smartindent', true) -utils.opt('o', 'hidden', true) -utils.opt('o', 'ignorecase', true) -utils.opt('o', 'scrolloff', 4) -utils.opt('o', 'shiftround', true) -utils.opt('o', 'smartcase', true) -utils.opt('o', 'splitbelow', true) -utils.opt('o', 'splitright', true) -utils.opt('o', 'wildmode', 'list:longest') -utils.opt('w', 'number', true) -utils.opt('o', 'clipboard', 'unnamed,unnamedplus') -utils.opt('o', 'mouse', 'a') +vim.opt.shiftwidth = indent +vim.opt.tabstop = indent +vim.opt.softtabstop = indent +vim.opt.scrolloff = indent +vim.opt.wildmode = 'list:longest,list:full' +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.hidden = true +vim.opt.ignorecase = true +vim.opt.shiftround = true +vim.opt.smartcase = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.number = true vim.opt.autoindent = false vim.opt.smartindent = false -vim.opt.background = 'light' vim.opt.errorformat:prepend('%f|%l col %c|%m') vim.opt.fileformat = 'unix' vim.opt.undofile = true +vim.opt.background = 'light' + -- Enable vimrc files per project and disable unsafe commands in project vimrc vim.opt.exrc = true vim.opt.secure = true --- unknown filetypes mappings vim.cmd([[ - autocmd BufRead,BufNewFile *.bu set filetype=yaml - autocmd BufRead,BufNewFile *.yml.example set filetype=yaml - autocmd BufRead,BufNewFile *.yaml.example set filetype=yaml + syntax enable + filetype plugin indent on + set noautoread + autocmd CursorHold * checktime + autocmd TextYankPost * lua vim.highlight.on_yank {on_visual = false} + autocmd BufRead,BufNewFile *.bu,*.yml.example,*.yaml.example set filetype=yaml autocmd BufRead,BufNewFile *.ign set filetype=json ]]) diff --git a/lua/utils.lua b/lua/utils.lua deleted file mode 100644 index 1da951a..0000000 --- a/lua/utils.lua +++ /dev/null @@ -1,10 +0,0 @@ -local utils = {} - -local scopes = { o = vim.o, b = vim.bo, w = vim.wo } - -function utils.opt(scope, key, value) - scopes[scope][key] = value - if scope ~= 'o' then scopes['o'][key] = value end -end - -return utils From 022660396e6d7c8b1a52011879e7e4ac5f5e9522 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 13 Aug 2024 15:40:32 +0200 Subject: [PATCH 090/108] re-add clipboard, middle click and ctrl+c --- lua/settings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/settings.lua b/lua/settings.lua index 4f55cb6..376fb39 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -14,6 +14,7 @@ vim.opt.smartcase = true vim.opt.splitbelow = true vim.opt.splitright = true vim.opt.number = true +vim.opt.clipboard = 'unnamed,unnamedplus' vim.opt.autoindent = false vim.opt.smartindent = false From 3e6923583f2c51480fd95012e93a13b960935886 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 13 Aug 2024 15:51:42 +0200 Subject: [PATCH 091/108] remove lsp diagnostics also defined in keymappings.lua --- lua/lsp.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 9d59498..68ec12d 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -6,8 +6,6 @@ local on_attach = function(client, bufnr) vim.keymap.set("n", "", "lua vim.lsp.buf.signature_help()") vim.keymap.set("n", "", "lua vim.lsp.buf.type_definition()") vim.keymap.set("n", "", "lua vim.lsp.buf.rename()()") - vim.keymap.set("n", "[d", "lua vim.diagnostic.goto_prev()") - vim.keymap.set("n", "]d", "lua vim.diagnostic.goto_next()") vim.keymap.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") vim.keymap.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") vim.keymap.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") From d7f591fd2624e99dea1c7962e85964e8414692c5 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 14 Aug 2024 14:58:29 +0200 Subject: [PATCH 092/108] Switch to newest nvim and fallback to classic vim colorscheme --- lua/theme.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/theme.lua b/lua/theme.lua index 77360ef..9151c72 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,5 +1,5 @@ -- Revert to vim's default term colorscheme ---vim.cmd 'colorscheme vim' +vim.cmd 'colorscheme vim' vim.cmd 'set notermguicolors' -- Highlight trailing whitespace (darker red) From c0e15e1141538a0caef9aa92998341c33b9454cb Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:36:40 +0200 Subject: [PATCH 093/108] cleanup lsp module --- lua/lsp.lua | 66 +++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 47 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 68ec12d..85e4cd7 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,6 +1,4 @@ -local on_attach = function(client, bufnr) - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - +local common_on_attach = function(client, bufnr) -- Mappings. vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") vim.keymap.set("n", "", "lua vim.lsp.buf.signature_help()") @@ -9,11 +7,11 @@ local on_attach = function(client, bufnr) vim.keymap.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") vim.keymap.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") vim.keymap.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + vim.keymap.set("n", "r", "lua vim.lsp.buf.rename()") + -- Autoformat on save. if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, buffer = bufnr, callback = function() vim.lsp.buf.format() @@ -21,7 +19,7 @@ local on_attach = function(client, bufnr) }) end - -- use vim's default coloring + -- Use vim's default coloring. client.server_capabilities.semanticTokensProvider = nil for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do vim.api.nvim_set_hl(0, group, {}) @@ -40,16 +38,15 @@ local servers = { "ocamllsp", "pyright", "rnix", - "ruff_lsp", "terraformls", "vimls", } for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { capabilities = capabilities, on_attach = on_attach } + nvim_lsp[lsp].setup { capabilities = capabilities, on_attach = common_on_attach } end nvim_lsp.rust_analyzer.setup({ - on_attach = on_attach, + on_attach = common_on_attach, capabilities = capabilities, settings = { ["rust-analyzer"] = { @@ -74,26 +71,21 @@ nvim_lsp.rust_analyzer.setup({ } }) -vim.g.code_action_menu_window_border = 'single' - --- symbols-outline.nvim -vim.g.symbols_outline = { - highlight_hovered_item = true, - show_guides = true, - auto_preview = false, -- experimental - position = 'right', - keymaps = { - close = "", - goto_location = "", - focus_location = "o", - hover_symbol = "", - rename_symbol = "r", - code_actions = "a" +nvim_lsp.ruff.setup({ + on_attach = function (client) + common_on_attach(client) + client.server_capabilities.renameProvider = false + client.server_capabilities.hoverProvider = false + end, + init_options = { + settings = { + -- Any extra CLI arguments for `ruff` go here. + args = {} + } }, - lsp_blacklist = {} -} +}) --- LSP Enable diagnostics +-- LSP diagnostics. vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false, @@ -101,23 +93,3 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = signs = true, update_in_insert = false }) - --- Send diagnostics to quickfix list -do - local method = "textDocument/publishDiagnostics" - local default_handler = vim.lsp.handlers[method] - vim.lsp.handlers[method] = function(err, method, result, client_id, bufnr, config) - default_handler(err, method, result, client_id, bufnr, config) - local diagnostics = vim.diagnostic.get() - local qflist = {} - for bufnr, diagnostic in pairs(diagnostics) do - for _, d in ipairs(diagnostic) do - d.bufnr = bufnr - d.lnum = d.range.start.line + 1 - d.col = d.range.start.character + 1 - d.text = d.message - table.insert(qflist, d) - end - end - end -end From c99606d4eede78930eae49a3f07400548091e2d0 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:37:35 +0200 Subject: [PATCH 094/108] add keymapping for code actions and buffer delete (:bd) --- lua/keymappings.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 000918e..140fdfc 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -14,3 +14,8 @@ vim.keymap.set("n", "fe", "Oil") vim.keymap.set("n", ']d', "lua vim.diagnostic.goto_next()") vim.keymap.set("n", '[d', "lua vim.diagnostic.goto_prev()") +vim.keymap.set("n", "aa", require("actions-preview").code_actions) + + +-- Close all buffers +vim.keymap.set("n", '', "bufdo bd") From 044ed9117fe28a5d790a1b32378d33b11a0b4319 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:38:54 +0200 Subject: [PATCH 095/108] use ctrl+shift+g for neogit --- lua/plugins/neogit.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua index 9768e2b..d842bf3 100644 --- a/lua/plugins/neogit.lua +++ b/lua/plugins/neogit.lua @@ -1,6 +1,6 @@ local neogit = require('neogit') -vim.keymap.set('n', '', neogit.open, {}) +vim.keymap.set('n', '', neogit.open, {}) neogit.setup { -- Hides the hints at the top of the status buffer From 637fed3f6b89fbd56b2644759c1b23750f1fba1d Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:39:21 +0200 Subject: [PATCH 096/108] show hidden files in oil (filebrowser) --- lua/plugins/oil.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index fc55dd9..884e296 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -83,7 +83,7 @@ require('oil').setup({ use_default_keymaps = true, view_options = { -- Show files and directories that start with "." - show_hidden = false, + show_hidden = true, -- This function defines what is considered a "hidden" file is_hidden_file = function(name, _) if vim.startswith(name, ".") then From a1a4dc927e6bdfba05fb803f3a1f26459d8a3282 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:45:19 +0200 Subject: [PATCH 097/108] move code_action_menu_window_border to theme --- lua/theme.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/theme.lua b/lua/theme.lua index 9151c72..77f774c 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -13,3 +13,5 @@ vim.cmd 'highlight LineNr ctermbg=none ctermfg=LightGrey' vim.cmd 'highlight Folded ctermbg=LightGrey ctermfg=Black' vim.cmd 'highlight Pmenu ctermbg=253 ctermfg=Black' vim.cmd 'let g:airline_theme=\'papercolor\'' + +vim.g.code_action_menu_window_border = 'single' From 7d6b3e53c430e9b1d869b559b1efd252460dd4d5 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:46:38 +0200 Subject: [PATCH 098/108] redo telescope one more time :) --- lua/plugins/telescope.lua | 48 +++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 9c297c7..0247fb6 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -2,6 +2,16 @@ local telescope = require('telescope') local actions = require('telescope.actions') local builtin = require('telescope.builtin') +local telescope_last = 0 +function telescope_resume() + if telescope_last == 0 then + telescope_last = 1 + builtin.live_grep() + else + builtin.resume() + end +end + telescope.setup { defaults = { sorting_strategy = "ascending", @@ -15,25 +25,35 @@ telescope.setup { live_grep = { mappings = { i = { [""] = actions.to_fuzzy_refine }, + n = { [""] = telescope_resume }, }, }, + find_files = { + cache_picker = false, + }, + git_files = { + cache_picker = false, + }, }, } +-- Snippets can be useful. vim.keymap.set('n', 'ss', telescope.extensions.luasnip.luasnip, {}) -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.git_files, {}) -vim.keymap.set('n', 'gg', builtin.live_grep, {}) -vim.keymap.set('n', 'fb', builtin.buffers, {}) -vim.keymap.set('n', 'fs', builtin.lsp_dynamic_workspace_symbols, {}) -vim.keymap.set('n', 'fsd', builtin.lsp_document_symbols, {}) -vim.keymap.set('n', 'fh', builtin.help_tags, {}) -vim.keymap.set('n', 'dd', builtin.diagnostics, {}) +-- Fuzzy * files, symbols, buffers, help, etc. +vim.keymap.set('n', 'fa', builtin.find_files) -- f[ind]a[ll] +vim.keymap.set('n', 'fb', builtin.buffers) +vim.keymap.set('n', 'fd', builtin.diagnostics) +vim.keymap.set('n', 'ff', builtin.git_files) +vim.keymap.set('n', 'fh', builtin.help_tags) +vim.keymap.set('n', 'fs', builtin.lsp_dynamic_workspace_symbols) --- Use telescope for lsp definitions, calls and references -vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) -vim.keymap.set('n', 'gr', builtin.lsp_references, {}) -vim.keymap.set('n', 'gi', builtin.lsp_implementations, {}) -vim.keymap.set('n', 'ci', builtin.lsp_incoming_calls, {}) -vim.keymap.set('n', 'co', builtin.lsp_outgoing_calls, {}) +-- Grep (the only one). +vim.keymap.set('n', 'gg', builtin.live_grep) + +-- LSP navigation. +vim.keymap.set('n', 'gd', builtin.lsp_definitions) +vim.keymap.set('n', 'gr', builtin.lsp_references) +vim.keymap.set('n', 'gi', builtin.lsp_implementations) +vim.keymap.set('n', 'ci', builtin.lsp_incoming_calls) +vim.keymap.set('n', 'co', builtin.lsp_outgoing_calls) From eccbfcbea2680a94926955dda39ad4ddbc2ff4ef Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 16:46:56 +0200 Subject: [PATCH 099/108] remove extra actions-preview config --- lua/plugins/init.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 7412466..7c3cdd8 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -52,11 +52,7 @@ require('packer').startup(function() -- LSP and related use { 'neovim/nvim-lspconfig' } - use { 'aznhe21/actions-preview.nvim', - config = function() - vim.keymap.set("n", "ca", require("actions-preview").code_actions) - end, - } + use { 'aznhe21/actions-preview.nvim' } use { 'folke/trouble.nvim' } -- lsp diagnostics -- Plugins to extend builtin language support From 422ecf0308ceed60128c5693dde76916fc475e52 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 17 Sep 2024 17:08:00 +0200 Subject: [PATCH 100/108] Remove unused plugins and add Outline --- lua/keymappings.lua | 5 ++++- lua/plugins/init.lua | 18 +++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 140fdfc..58f4ca9 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -14,7 +14,10 @@ vim.keymap.set("n", "fe", "Oil") vim.keymap.set("n", ']d', "lua vim.diagnostic.goto_next()") vim.keymap.set("n", '[d', "lua vim.diagnostic.goto_prev()") -vim.keymap.set("n", "aa", require("actions-preview").code_actions) +vim.keymap.set("n", "aa", require("actions-preview").code_actions) + +-- Outline!! +vim.keymap.set("n", "o", "Outline") -- Close all buffers diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 7c3cdd8..54d8b43 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -60,6 +60,7 @@ require('packer').startup(function() use { 'gleam-lang/gleam.vim' } use { 'rust-lang/rust.vim' } use { 'folke/neodev.nvim' } + use { 'hashivim/vim-terraform' } -- Git use { @@ -76,22 +77,8 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams - use { 'hashivim/vim-terraform' } - -- intellij idea to nvim o_O - use { 'Shougo/deoplete.nvim' } - use { 'beeender/Comrade' } - - use({ - 'MeanderingProgrammer/render-markdown.nvim', - after = { 'nvim-treesitter' }, - requires = { 'echasnovski/mini.nvim', opt = true }, -- if you use the mini.nvim suite - -- requires = { 'echasnovski/mini.icons', opt = true }, -- if you use standalone mini plugins - -- requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- if you prefer nvim-web-devicons - config = function() - require('render-markdown').setup({}) - end, - }) + use { 'hedyhli/outline.nvim' } end) @@ -101,3 +88,4 @@ require('plugins.neogit') require('plugins.oil') require('plugins.telescope') require('plugins.venn') +require("outline").setup({}) From dfa4d93847294a609198ed4379254625d5568a2a Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 23 Sep 2024 11:45:46 +0200 Subject: [PATCH 101/108] Don't use treesitter in telescope preview --- lua/plugins/telescope.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 0247fb6..707ba1b 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -20,6 +20,9 @@ telescope.setup { '--with-filename', '--line-number', '--column', '--smart-case', '--no-heading', }, + preview = { + treesitter = false + }, }, pickers = { live_grep = { From 4c5afbe2b27f60de787bf5d6e08a063770453810 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 23 Sep 2024 22:48:43 +0200 Subject: [PATCH 102/108] Add catpuccin theme with huge config --- lua/plugins/catppuccin.lua | 244 +++++++++++++++++++++++++++++++++++++ lua/plugins/init.lua | 3 + 2 files changed, 247 insertions(+) create mode 100644 lua/plugins/catppuccin.lua diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua new file mode 100644 index 0000000..fa7c73f --- /dev/null +++ b/lua/plugins/catppuccin.lua @@ -0,0 +1,244 @@ +require("catppuccin").setup({ + -- transparent_background = vim + flavour = "latte", + highlight_overrides = { + all = function(colors) + return { + FloatBorder = { link = "SagaBorder", fg="#4f4f4f" }, + LineNr = { fg = colors.subtext0 }, + Folded = { fg = colors.green }, + MatchWord = { bold = true }, + Visual = { sp = colors.text, underline = true }, + IndentBlankLineContextChar = { fg = colors.sapphire }, + WinSeparator = { fg = colors.text }, + TelescopeSelection = { fg = colors.subtext1, bg = colors.surface0 }, + TelescopeBorder = { fg = colors.surface1, bg = colors.surface1 }, + TelescopeNormal = { bg = "#fafafa" }, + TelescopePromptNormal = { bg = colors.surface1 }, + TelescopePromptBorder = { bg = colors.surface1, fg = colors.surface1 }, + CursorLine = { bg = colors.text }, + NvimTreeWinSeparator = { fg = colors.text }, + NvimTreeGitNew = { fg = colors.green }, + NvimTreeGitDirty = { fg = colors.yellow }, + NvimTreeGitDeleted = { fg = colors.red }, + -- ColorColumn = { bg = colors. }, + SpecialKey = { fg = colors.yellow }, + SagaBorder = { fg = colors.blue }, + HoverNormal = { fg = colors.text }, + + -- Gitsigns + GitSignsAddInline = { link = "DiffAdd" }, + GitSignsDeleteInline = { link = "DiffDelete" }, + GitSignsChangedInline = { link = "DiffChange" } , + Diffview = { link = "DiffChange" } , + + StNormalMode = { fg = colors.surface0, bg = colors.blue, bold = true }, + StVisualMode = { fg = colors.surface0, bg = colors.sky, bold = true }, + StInsertMode = { fg = colors.surface0, bg = colors.lavender, bold = true }, + StTerminalMode = { fg = colors.surface0, bg = colors.green, bold = true }, + StNTerminalMode = { fg = colors.surface0, bg = colors.yellow, bold = true }, + StReplaceMode = { fg = colors.surface0, bg = colors.peach, bold = true }, + StConfirmMode = { fg = colors.surface0, bg = colors.sapphire, bold = true }, + StCommandMode = { fg = colors.surface0, bg = colors.green, bold = true }, + StSelectMode = { fg = colors.surface0, bg = colors.blue, bold = true }, + + StInviSep = { bg = colors.surface1, fg = colors.surface1 }, + StNormalModeSep = { bg = colors.surface1, fg = colors.blue }, + StVisualModeSep = { bg = colors.surface1, fg = colors.sky }, + StInsertModeSep = { bg = colors.surface1, fg = colors.lavender }, + StTerminalModeSep = { bg = colors.surface1, fg = colors.green }, + StNTerminalModeSep = { bg = colors.surface1, fg = colors.yellow }, + StReplaceModeSep = { bg = colors.surface1, fg = colors.peach }, + StConfirmModeSep = { bg = colors.surface1, fg = colors.sapphire }, + StCommandModeSep = { bg = colors.surface1, fg = colors.green }, + StSelectModeSep = { bg = colors.surface1, fg = colors.blue }, + + --CurFile + StCwd = { bg = colors.yellow, fg = colors.text }, + StFile = { bg = colors.peach, fg = colors.text, bold = true }, + StCwdSep = { fg = colors.yellow, bg = colors.surface1 }, + StFileSep = { fg = colors.peach, bg = colors.surface1 }, + StDirFileSep = { fg = colors.yellow, bg = colors.peach }, + -- Git stuffs + StGitBranch = { bg = colors.overlay0, fg = colors.mauve }, + StGitAdded = { bg = colors.overlay0, fg = colors.green }, + StGitChanged = { bg = colors.overlay0, fg = colors.yellow }, + StGitRemoved = { bg = colors.overlay0, fg = colors.red }, + StGitSep = { bg = colors.surface1, fg = colors.overlay0 }, + + -- LSP + StLSPClient = { bg = colors.surface1, fg = colors.blue, bold = true }, + StLSPDiagSep = { bg = colors.surface1, fg = colors.overlay0 }, + StLSPErrors = { bg = colors.overlay0, fg = colors.red }, + StLSPWarnings = { bg = colors.overlay0, fg = colors.yellow }, + StLSPHints = { bg = colors.overlay0, fg = colors.mauve }, + StLspInfo = { bg = colors.overlay0, fg = colors.sky }, + -- + -- Lsp Diagnostics + DiagnosticHint = { fg = colors.mauve }, + DiagnosticError = { fg = colors.red }, + DiagnosticWarn = { fg = colors.yellow }, + DiagnosticInformation = { fg = colors.green }, + + -- File Info + StPosition = { bg = colors.sapphire, fg = colors.surface1 }, + StPositionSep = { bg = colors.surface1, fg = colors.sapphire }, + + TabLineFill = { fg = colors.text, bg = colors.crust, sp = colors.text }, + TabLineBufHidden = { fg = colors.mantle, bg = colors.subtext1, sp = colors.text }, + TabLineBufActive = { fg = colors.text, bg = colors.sapphire, bold = true, sp = colors.text }, + TabLineCurrentBuf = { fg = colors.mantle, bg = colors.red, bold = true, sp = colors.text }, + TabLineBufHiddenModified = { fg = colors.green, bg = colors.subtext1, sp = colors.text }, + TabLineBufActiveModified = { fg = colors.green, bg = colors.sapphire, bold = true, sp = colors.text }, + TabLineCurrentBufModified = { fg = colors.green, bg = colors.red, bold = true, sp = colors.text }, + TabLineModified = { fg = colors.green }, + TabLineCurrentTab = { fg = colors.mantle, bg = colors.red, bold = true, sp = colors.text }, + TabLineOtherTab = { fg = colors.mantle, bg = colors.subtext1, sp = colors.text }, + TabLineBufActiveSep = { fg = colors.sapphire, bg = colors.crust, sp = colors.text }, + TabLineCurrentBufSep = { fg = colors.red, bg = colors.crust, sp = colors.text }, + TabLineBufHiddenSep = { fg = colors.subtext1, bg = colors.crust, sp = colors.text }, + + DiagnosticUnnecessary = { link = "" }, + + ["@conceal.checked"] = { fg = colors.teal }, + ["@none"] = { link = "Normal" }, + ["@field"] = { fg = colors.blue }, + ["@comment.todo"] = { fg = colors.lavender }, + ["@property"] = { fg = colors.blue }, + ["@variable.member"] = { fg = colors.blue }, + ["@variable.parameter"] = { fg = colors.sky }, + ["@parameter"] = { fg = colors.sky }, + ["@comment.note"] = { link = "@comment.hint" }, + ["@lsp.type.annotation"] = { fg = colors.yellow }, + ["@lsp.type.modifier.java"] = { link = "@type.qualifier" }, + ["@lsp.mod.builtin"] = { fg = colors.maroon }, + ["@lsp.mod.readonly.python"] = { link = "Constant" }, + ["@lsp.mod.documentation"] = { bold = true, fg = colors.mauve }, + ["@lsp.type.keyword"] = { fg = colors.mauve }, + } + end, + latte = function(colors) + return { + ["@lsp.type.keyword"] = { fg = colors.lavender }, + + Comment = { fg = colors.blue }, + Conditional = { fg = colors.darkyellow }, + Error = { fg = colors.base, bg = colors.red }, + Exception = { fg = colors.peach }, + Function = { fg = colors.cyan }, + Identifier = { fg = colors.green }, + Include = { fg = colors.pink }, + Keyword = { fg = colors.cyan }, + Operator = { fg = colors.darkyellow }, + Parameter = { fg = colors.sky }, + Special = { fg = colors.flamingo }, + Statement = { fg = colors.darkyellow }, + String = { fg = colors.red }, + Structure = { fg = colors.green }, + WhitespaceError = { fg = colors.base, bg = colors.red }, + } + end, + }, + color_overrides = { + latte = { + base = "#ffffff", + flamingo = "#bb5d60", + pink = "#d54597", + mauve = "#a65fd5", + red = "#D90E18", + maroon = "#db3e68", + peach = "#e46f2a", + yellow = "#bc8705", + darkyellow = "#B2640B", + green = "#1a8e32", + teal = "#00a390", + sky = "#089ec0", + sapphire = "#0ea0a0", + blue = "#017bca", + lavender = "#8584f7", + text = "#222222", + subtext1 = "#444444", + subtext0 = "#666666", + overlay2 = "#777777", + overlay1 = "#888888", + overlay0 = "#999999", + surface2 = "#aaaaaa", + surface1 = "#cccccc", + surface0 = "#e5e5e5", + mantle = "#eeeeee", + crust = "#dddddd", + cyan = "#0EB1A2", + }, + }, + background = { + light = "latte", + dark = "mocha", + }, + term_colors = true, + -- dim_inactive = { + -- enabled = true, + -- shade = "light", + -- percentage = 0.20, + -- }, + styles = { + comments = {}, + }, + integrations = { + alpha = false, + cmp = true, + dap = true, + dap_ui = true, + dashboard = false, + flash = false, + gitsigns = true, + leap = true, + mini = { + enabled = false, + }, + mason = true, + markdown = true, + neogit = true, + nvimtree = true, + ufo = false, + rainbow_delimiters = false, + semantic_tokens = true, + telescope = { enabled = true, style = "nvchad" }, + treesitter = false, + barbecue = false, + illuminate = false, + indent_blankline = { + enabled = true, + colored_indent_levels = false, + }, + native_lsp = { + enabled = true, + virtual_text = { + errors = { "italic" }, + hints = { "italic" }, + warnings = { "italic" }, + information = { "italic" }, + }, + underlines = { + errors = { "underline" }, + hints = { "underline" }, + warnings = { "underline" }, + information = { "underline" }, + }, + inlay_hints = { + background = true, + }, + }, + lsp_saga = true, + lsp_trouble = true, + navic = { + enabled = false, + custom_bg = "NONE", + }, + dropbar = { + enabled = false, + color_mode = false, + }, + }, +}) + +vim.cmd.colorscheme("catppuccin") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 54d8b43..26fcb12 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -80,8 +80,11 @@ require('packer').startup(function() use { 'hedyhli/outline.nvim' } + use { "catppuccin/nvim", as = "catppuccin" } + end) +require('plugins.catppuccin') require('plugins.cmp') require('plugins.gitsigns') require('plugins.neogit') From 772a9b908f24f8f67032147f16725f0bb2471b79 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 23 Sep 2024 22:49:35 +0200 Subject: [PATCH 103/108] Add fzf, telescope and diffview to neogit --- lua/plugins/neogit.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua index d842bf3..771a0e6 100644 --- a/lua/plugins/neogit.lua +++ b/lua/plugins/neogit.lua @@ -144,17 +144,17 @@ neogit.setup { integrations = { -- If enabled, use telescope for menu selection rather than vim.ui.select. -- Allows multi-select and some things that vim.ui.select doesn't. - telescope = nil, + telescope = true, -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `diffview`. -- The diffview integration enables the diff popup. -- -- Requires you to have `sindrets/diffview.nvim` installed. - diffview = nil, + diffview = true, -- If enabled, uses fzf-lua for menu selection. If the telescope integration -- is also selected then telescope is used instead -- Requires you to have `ibhagwan/fzf-lua` installed. - fzf_lua = nil, + fzf_lua = true, }, sections = { -- Reverting/Cherry Picking From b0d6dffe816f16a3676ea537648e239aadbeb5eb Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 23 Sep 2024 22:50:39 +0200 Subject: [PATCH 104/108] Make right order in main imports --- init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 33bcdf8..137cde1 100644 --- a/init.lua +++ b/init.lua @@ -1,9 +1,8 @@ -- remap leader to vim.g.mapleader = ' ' --- Sensible defaults -require('settings') -require('plugins') require('theme') +require('settings') require('lsp') require('keymappings') +require('plugins') From c64bdbbf7fd3b226879c399de2b13ace913a8dd7 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 23 Sep 2024 22:57:08 +0200 Subject: [PATCH 105/108] Remove theme module because of catpuccin --- init.lua | 1 - lua/settings.lua | 4 ++-- lua/theme.lua | 17 ----------------- 3 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 lua/theme.lua diff --git a/init.lua b/init.lua index 137cde1..58112d6 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,6 @@ -- remap leader to vim.g.mapleader = ' ' -require('theme') require('settings') require('lsp') require('keymappings') diff --git a/lua/settings.lua b/lua/settings.lua index 376fb39..639827c 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -29,11 +29,11 @@ vim.opt.exrc = true vim.opt.secure = true vim.cmd([[ - syntax enable - filetype plugin indent on set noautoread autocmd CursorHold * checktime autocmd TextYankPost * lua vim.highlight.on_yank {on_visual = false} autocmd BufRead,BufNewFile *.bu,*.yml.example,*.yaml.example set filetype=yaml autocmd BufRead,BufNewFile *.ign set filetype=json + match Error /\s\+$/ + let g:airline_theme='papercolor' ]]) diff --git a/lua/theme.lua b/lua/theme.lua deleted file mode 100644 index 77f774c..0000000 --- a/lua/theme.lua +++ /dev/null @@ -1,17 +0,0 @@ --- Revert to vim's default term colorscheme -vim.cmd 'colorscheme vim' -vim.cmd 'set notermguicolors' - --- Highlight trailing whitespace (darker red) -vim.cmd 'highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d' -vim.cmd 'match WhitespaceEOL /\\s\\+\\%#\\@ Date: Mon, 23 Sep 2024 23:05:33 +0200 Subject: [PATCH 106/108] Remove forgotten flutter config --- lua/plugins/flutter.lua | 66 ----------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 lua/plugins/flutter.lua diff --git a/lua/plugins/flutter.lua b/lua/plugins/flutter.lua deleted file mode 100644 index 5bafc9e..0000000 --- a/lua/plugins/flutter.lua +++ /dev/null @@ -1,66 +0,0 @@ -require("flutter-tools").setup { - ui = { - border = "rounded", - notification_style = 'native' - }, - decorations = { - statusline = { - app_version = false, - device = false, - project_config = false, - } - }, - debugger = { - enabled = false, - run_via_dap = false, - exception_breakpoints = {}, - --register_configurations = function(paths) - -- require("dap").configurations.dart = { - -- - -- } - --end, - }, - flutter_path = "/usr/bin/flutter", - flutter_lookup_cmd = nil, - root_patterns = { ".git", "pubspec.yaml" }, - fvm = false, - widget_guides = { - enabled = false, - }, - closing_tags = { - highlight = "Comment", - prefix = "/ ", - enabled = true, - }, - dev_log = { - enabled = true, - notify_errors = false, - open_cmd = "tabedit", - }, - dev_tools = { - autostart = false, - auto_open_browser = false, - }, - outline = { - open_cmd = "30vnew", - auto_open = false, - }, - lsp = { - color = { - enabled = false, - background = false, - background_color = nil, - foreground = false, - virtual_text = false, - virtual_text_str = "■", - }, - settings = { - showTodos = true, - completeFunctionCalls = true, - -- analysisExcludedFolders = { "" }, - renameFilesWithClasses = "prompt", - enableSnippets = true, - updateImportsOnRename = true, - } - } -} From 324505f2455e7a8b837aa004ee2737401ef45f42 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 23 Sep 2024 23:42:17 +0200 Subject: [PATCH 107/108] Create outline config from it's default --- lua/plugins/init.lua | 2 +- lua/plugins/outline.lua | 137 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 lua/plugins/outline.lua diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 26fcb12..6095fa2 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -89,6 +89,6 @@ require('plugins.cmp') require('plugins.gitsigns') require('plugins.neogit') require('plugins.oil') +require('plugins.outline') require('plugins.telescope') require('plugins.venn') -require("outline").setup({}) diff --git a/lua/plugins/outline.lua b/lua/plugins/outline.lua new file mode 100644 index 0000000..3ea216c --- /dev/null +++ b/lua/plugins/outline.lua @@ -0,0 +1,137 @@ +require("outline").setup({ + guides = { + enabled = true, + markers = { + bottom = '└', + middle = '├', + vertical = '│', + horizontal = '─', + }, + }, + outline_items = { + show_symbol_details = true, + show_symbol_lineno = false, + -- The two below are both for auto_update_events.follow + highlight_hovered_item = true, + -- On open, always followed. This is for auto_update_events.follow, whether + -- to auto update cursor position to reflect code location. If false, can + -- manually trigger with follow_cursor (API, command, keymap action). + auto_set_cursor = true, + auto_update_events = { + follow = { 'CursorMoved' }, + items = { 'InsertLeave', 'WinEnter', 'BufEnter', 'BufWinEnter', 'BufWritePost' }, + }, + }, + outline_window = { + position = 'right', + split_command = nil, + width = 25, + relative_width = true, + wrap = false, + focus_on_open = true, + auto_close = false, + auto_jump = false, + show_numbers = false, + show_relative_numbers = false, + ---@type boolean|string? + show_cursorline = true, + hide_cursor = false, + winhl = '', + jump_highlight_duration = 400, + center_on_jump = true, + }, + preview_window = { + live = false, + auto_preview = false, + width = 50, + min_width = 50, + relative_width = true, + height = 50, + min_height = 10, + relative_height = true, + border = 'single', + open_hover_on_preview = false, + winhl = 'NormalFloat:', + winblend = 0, + }, + symbol_folding = { + autofold_depth = 1, + auto_unfold = { + hovered = true, + ---@type boolean|integer + only = true, + }, + markers = { '', '' }, + }, + keymaps = { + show_help = '?', + close = { '', 'q' }, + goto_location = '', + peek_location = 'o', + goto_and_close = '', + restore_location = '', + hover_symbol = '', + toggle_preview = 'K', + rename_symbol = 'r', + code_actions = 'a', + fold = 'h', + fold_toggle = '', + fold_toggle_all = '', + unfold = 'l', + fold_all = 'W', + unfold_all = 'E', + fold_reset = 'R', + down_and_jump = '', + up_and_jump = '', + }, + providers = { + priority = { 'lsp', 'coc', 'markdown', 'norg' }, + lsp = { + blacklist_clients = {}, + }, + markdown = { + filetypes = { 'markdown' }, + }, + }, + symbols = { + ---@type outline.FilterConfig? + filter = nil, + icon_source = nil, + icon_fetcher = nil, + icons = { + File = { icon = '', hl = 'Identifier' }, + Module = { icon = '', hl = 'Include' }, + Namespace = { icon = '{}', hl = 'Include' }, + Package = { icon = '', hl = 'Include' }, + Class = { icon = '𝓒', hl = 'Type' }, + Method = { icon = '.ƒ', hl = 'Function' }, + Property = { icon = '', hl = 'Identifier' }, + Field = { icon = '-', hl = 'Identifier' }, + Constructor = { icon = '()', hl = 'Special' }, + Enum = { icon = 'ℰ', hl = 'Type' }, + Interface = { icon = 'i', hl = 'Type' }, + Function = { icon = 'ƒ', hl = 'Function' }, + Variable = { icon = '(x)', hl = 'Constant' }, + Constant = { icon = 'c', hl = 'Constant' }, + String = { icon = '𝓐', hl = 'String' }, + Number = { icon = '#', hl = 'Number' }, + Boolean = { icon = '⊨', hl = 'Boolean' }, + Array = { icon = '[]', hl = 'Constant' }, + Object = { icon = '⦿', hl = 'Type' }, + Key = { icon = '🔐', hl = 'Type' }, + Null = { icon = 'NULL', hl = 'Type' }, + EnumMember = { icon = '', hl = 'Identifier' }, + Struct = { icon = '𝓢', hl = 'Structure' }, + Event = { icon = '🗲', hl = 'Type' }, + Operator = { icon = '+', hl = 'Identifier' }, + TypeParameter = { icon = '𝙏', hl = 'Identifier' }, + Component = { icon = '', hl = 'Function' }, + Fragment = { icon = '-', hl = 'Constant' }, + -- ccls + TypeAlias = { icon = 't ', hl = 'Type' }, + Parameter = { icon = 'p ', hl = 'Identifier' }, + StaticMethod = { icon = '. ', hl = 'Function' }, + Macro = { icon = ' ', hl = 'Function' }, + }, + }, +}) From f173413efff6ab153172f535fafabd7c09316c34 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 24 Sep 2024 19:02:23 +0200 Subject: [PATCH 108/108] Highlight: disable lsp, fix rust and whitespace --- lua/plugins/catppuccin.lua | 40 ++++++++++++++++++++++---------------- lua/settings.lua | 15 +++++++++++++- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua index fa7c73f..d725829 100644 --- a/lua/plugins/catppuccin.lua +++ b/lua/plugins/catppuccin.lua @@ -100,26 +100,27 @@ require("catppuccin").setup({ DiagnosticUnnecessary = { link = "" }, - ["@conceal.checked"] = { fg = colors.teal }, - ["@none"] = { link = "Normal" }, - ["@field"] = { fg = colors.blue }, - ["@comment.todo"] = { fg = colors.lavender }, - ["@property"] = { fg = colors.blue }, - ["@variable.member"] = { fg = colors.blue }, - ["@variable.parameter"] = { fg = colors.sky }, - ["@parameter"] = { fg = colors.sky }, - ["@comment.note"] = { link = "@comment.hint" }, - ["@lsp.type.annotation"] = { fg = colors.yellow }, - ["@lsp.type.modifier.java"] = { link = "@type.qualifier" }, - ["@lsp.mod.builtin"] = { fg = colors.maroon }, - ["@lsp.mod.readonly.python"] = { link = "Constant" }, - ["@lsp.mod.documentation"] = { bold = true, fg = colors.mauve }, - ["@lsp.type.keyword"] = { fg = colors.mauve }, + --["@conceal.checked"] = { fg = colors.teal }, + --["@none"] = { link = "Normal" }, + --["@field"] = { fg = colors.blue }, + --["@comment.todo"] = { fg = colors.lavender }, + --["@property"] = { fg = colors.blue }, + --["@variable.member"] = { fg = colors.blue }, + --["@variable.parameter"] = { fg = colors.sky }, + --["@parameter"] = { fg = colors.sky }, + --["@comment.note"] = { link = "@comment.hint" }, + + --["@lsp.type.annotation"] = { fg = colors.darkyellow }, + --["@lsp.type.modifier.java"] = { link = "@type.qualifier" }, + --["@lsp.mod.builtin"] = { fg = colors.maroon }, + --["@lsp.mod.readonly.python"] = { link = "Constant" }, + --["@lsp.mod.documentation"] = { bold = true, fg = colors.mauve }, + --["@lsp.type.keyword"] = { fg = colors.mauve }, } end, latte = function(colors) return { - ["@lsp.type.keyword"] = { fg = colors.lavender }, + -- ["@lsp.type.keyword"] = { fg = colors.darkyellow }, Comment = { fg = colors.blue }, Conditional = { fg = colors.darkyellow }, @@ -128,7 +129,7 @@ require("catppuccin").setup({ Function = { fg = colors.cyan }, Identifier = { fg = colors.green }, Include = { fg = colors.pink }, - Keyword = { fg = colors.cyan }, + Keyword = { fg = colors.darkyellow }, Operator = { fg = colors.darkyellow }, Parameter = { fg = colors.sky }, Special = { fg = colors.flamingo }, @@ -136,6 +137,10 @@ require("catppuccin").setup({ String = { fg = colors.red }, Structure = { fg = colors.green }, WhitespaceError = { fg = colors.base, bg = colors.red }, + Type = { fg = colors.cyan }, + StorageClass = { fg = colors.green }, + --Macro = { fg = colors.magenta }, + --Define = { fg = colors.magenta }, } end, }, @@ -168,6 +173,7 @@ require("catppuccin").setup({ mantle = "#eeeeee", crust = "#dddddd", cyan = "#0EB1A2", + magenta = "#FF00FF", }, }, background = { diff --git a/lua/settings.lua b/lua/settings.lua index 639827c..7447ed9 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -28,12 +28,25 @@ vim.opt.background = 'light' vim.opt.exrc = true vim.opt.secure = true +vim.api.nvim_create_autocmd('InsertEnter', { + callback = function() + vim.cmd.hi('clear RedundantSpaces') + end, + pattern = '*', +}) +vim.api.nvim_create_autocmd({'InsertLeave', 'BufEnter'}, { + callback = function() + vim.cmd.hi('RedundantSpaces ctermbg=red guibg=red') + end, + pattern = '*', +}) + vim.cmd([[ set noautoread autocmd CursorHold * checktime autocmd TextYankPost * lua vim.highlight.on_yank {on_visual = false} autocmd BufRead,BufNewFile *.bu,*.yml.example,*.yaml.example set filetype=yaml autocmd BufRead,BufNewFile *.ign set filetype=json - match Error /\s\+$/ + match RedundantSpaces /\s\+$/ let g:airline_theme='papercolor' ]])