diff --git a/.gitignore b/.gitignore index d7ad043..a12d545 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +# My temp files +logs/ plugin/ +sessions/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..158caaa --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,102 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [2.0.0] - 2021-04-30 +### Added +- Configurations + - `g:doom_autoload_last_session` variable + - `g:doom_terminal_direction` variable + - `g:doom_terminal_width` variable + - `g:doom_terminal_height` variable +- Plugins + - `auto-session` + +### Changed +- Installation script + - Now you can select the branch to use (main, develop) +- Lua migration + - init + - configs + - plugins +- Implemented better custom plugins system +- Start using TreeSitter based indentation +- Plugins + - Replaced + - `Goyo` in favour of `TrueZen` + - `leader-mapper` in favour of `WhichKey` + - `Vista.vim` in favour of `SymbolsOutline` + - `Neoformat` in favour of `format.nvim` + - `nvim-autopairs` in favour of `pears.nvim` + - Updated + - `nvim-toggleterm` configurations + - Other changes + - `telescope.nvim` cannot be disabled anymore +- Keybindings + - Refact some `` bindings + - Use `:TZAtaraxis` as F6 key bind + - New `:dr` map, easily create crash reports +- Misc + - Cleaned some code hunk + - Formatted all files + - Refact changelog + +### Deleted +- Old Vimscript configs codebase +- Plugins + - Deleted `vim-polyglot` in favour of TreeSitter based + syntax highlighting + +### Fixed +- Some bugs that I don't really remember +- Squashed bugs on autoload functions + +## 1.2.1 - 2021-03-30 +### Added +- New branch `develop` + +### Changed +- Improved installation script + +## [1.2.0] - 2021-03-30 +### Added +- Configurations + - `g:doom_ts_parsers` variable + - New key binding for toggle terminal + - `doomrc` template with the default options values +- Basic implementation for `:checkhealth` command +- Plugins + - `gitsigns` + - `indentLine` + - `nvim-lspinstall` + - Some new colorschemes + +### Changed +- Improved `:DoomUpdate` command +- Some minor changes more under the hood +- Plugins + - `signify` in favor of `gitsigns` + +### Fixed +- Squashed some bugs + +## 1.1.0 - 2021-03-22 +### Added +- `Doom` section to `vim-leader-guide` plugin, + see |doom_nvim_commands_keybindings| +- `:DoomUpdate` command, + see |doom_nvim_commands| +- `g:doom_autosave_sessions`, + see |doom_nvim_options| + +## [1.0.0] - 2021-03-19 +- Initial stable release + +[Unreleased]: https://github.com/NTBBloodbath/doom-nvim/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/NTBBloodbath/doom-nvim/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/NTBBloodbath/doom-nvim/compare/v0.2.0...v0.3.0 +[1.0.0]: https://github.com/NTBBloodbath/doom-nvim/releases/tag/v1.0.0 diff --git a/autoload/doom.vim b/autoload/doom.vim index 24f5e7e..c5002cb 100644 --- a/autoload/doom.vim +++ b/autoload/doom.vim @@ -5,7 +5,7 @@ "================================================ " Doom Nvim version -let g:doom_version = '1.2.1' +let g:doom_version = '2.0.0' lockvar g:doom_version " Force UTF-8 encoding @@ -23,9 +23,13 @@ let g:doom_fmt_on_save = 0 " @default = 0 let g:doom_autosave_sessions = 0 +" Autoload sessions +" @default = 0 +let g:doom_autoload_last_session = 0 + " Preserve last editing position " @default = 0 -let g:doom_preserve_edit_pos = 0 +let g:doom_preserve_edit_pos = 1 " Default indent size " @default = 4 @@ -71,15 +75,15 @@ let g:doom_colorscheme = 'doom-one' " @default = dark let g:doom_colorscheme_bg = 'dark' -" Checkupdates on start +" Check updates of plugins on start " @default = 0 let g:doom_check_updates = 0 " Disabled plugins -" @default = ['indentlines'] +" @default = ['lazygit', 'minimap', 'restclient'] " example: " let g:doom_disabled_plugins = ['emmet-vim'] -let g:doom_disabled_plugins = ['indentlines'] +let g:doom_disabled_plugins = ['lazygit', 'minimap', 'restclient'] " Disabled plugins modules " @default = ['git', 'lsp', 'web'] @@ -89,8 +93,16 @@ let g:doom_disabled_modules = ['git', 'lsp', 'web'] " Install custom plugins " @default = [] -" example: -" let g:doom_custom_plugins = ['andweeb/presence.nvim'] +" examples: +" plugins without options: +" let g:doom_custom_plugins = ['andweeb/presence.nvim'] +" plugins with options: +" let g:doom_custom_plugins = [ +" \ { +" \ 'repo': 'andweeb/presence.nvim', +" \ 'enabled': 1, +" \ } +" \ ] let g:doom_custom_plugins = [] " Set the parsers for TreeSitter @@ -99,10 +111,32 @@ let g:doom_custom_plugins = [] " let g:doom_ts_parsers = ['python', 'javascript'] let g:doom_ts_parsers = [] -"Conceal level -" 0: Disabled -" 1: Enabled -" @default = 0 +" Set the Terminal direction +" Available directions: +" - vertical +" - horizontal +" - window +" - float +" @default = 'vertical' +let g:doom_terminal_direction = 'vertical' + +" Set the Terminal width +" Applies only to float direction +" @default = 70 +let g:doom_terminal_width = 70 + +" Set the Terminal height +" Applies to all directions except window +" @default = 20 +let g:doom_terminal_height = 20 + +" Conceal level +" Set Neovim conceal level +" 0 : Disable indentline and show all +" 1 : Conceal some functions and show indentlines +" 2 : Concealed text is completely hidden unless it has a custom replacement +" character defined +" 3 : Concealed text is completely hidden let g:doom_conceallevel = 0 " Logging level @@ -121,7 +155,7 @@ if has('nvim') if has('nvim-0.5') let g:doom_neovim = 1 else - call doom#logging#message('!!!', 'Doom Nvim requires Neovim 0.5.0, please use the nvim-0.4 branch!', 2) + call doom#logging#message('!!!', 'Doom Nvim requires Neovim 0.5.0', 2) endif else call doom#logging#message('!!!', 'Doom Nvim does not have support for Vim, please use it with Neovim instead!', 2) @@ -156,17 +190,7 @@ endfunction function! doom#end() abort call doom#default#loadGlob() " Test source system-based - call doom#system#grepconfig('config', 'gui.vim', 1) - call doom#system#grepconfig('config', 'keybindings.vim', 1) - - " Plugins, configs are loaded only if the plugin is enabled. - if index(g:doom_disabled_plugins, 'vista') == -1 - call doom#system#grepconfig('config/plugins', 'vista.vim', 1) - endif - if index(g:doom_disabled_plugins, 'neoformat') == -1 - call doom#system#grepconfig('config/plugins', 'neoformat.vim', 1) - endif - call doom#system#grepconfig('config/plugins', 'leader-mapper.vim', 1) + call doom#system#grepconfig('doom', 'keybindings', 1) " Check updates call doom#logging#init() diff --git a/autoload/doom/autocmds.vim b/autoload/doom/autocmds.vim index b2c8dff..bdcaf11 100644 --- a/autoload/doom/autocmds.vim +++ b/autoload/doom/autocmds.vim @@ -14,7 +14,7 @@ function! doom#autocmds#init() abort augroup END " Compile new plugins changes at save - autocmd BufWritePost plugins.lua,doomrc PackerCompile + autocmd BufWritePost init.lua,doomrc PackerCompile profile=true " Disable tabline on Dashboard autocmd FileType dashboard set showtabline=0 | autocmd WinLeave set showtabline=2 @@ -30,9 +30,9 @@ function! doom#autocmds#init() abort endif " Format on save - " NOTE: Requires neoformat to be enabled! + " NOTE: Requires formatter to be enabled! if g:doom_fmt_on_save ==# 1 - autocmd BufWritePre * undojoin | Neoformat + autocmd BufWritePoist * FormatWrite endif " Preserve last editing pos @@ -42,4 +42,7 @@ function! doom#autocmds#init() abort \ exe "normal! g`\"" | \ endif endif + + " Set up vim_buffer_previewer in telescope + autocmd User TelescopePreviewerLoaded setlocal wrap endfunction diff --git a/autoload/doom/config.vim b/autoload/doom/config.vim index e22c20b..dd359bf 100644 --- a/autoload/doom/config.vim +++ b/autoload/doom/config.vim @@ -21,7 +21,7 @@ function! doom#config#loadBFC() if filereadable(g:doom_root . '/doomrc') try execute 'source ' . g:doom_root . '/doomrc' - call doom#logging#message('+', 'Loading the BFC', 2) + call doom#logging#message('+', 'Loading the BFC ...', 2) catch call doom#logging#message('!', 'Error while loading the BFC', 1) endtry diff --git a/autoload/doom/functions.vim b/autoload/doom/functions.vim index dbf914f..c55a6f4 100644 --- a/autoload/doom/functions.vim +++ b/autoload/doom/functions.vim @@ -22,14 +22,6 @@ function! doom#functions#get_root() abort return root endfunction -" ToggleTerm custom function to avoid having -" line numbers inside the terminal buffer -" because that is not from God. -function! doom#functions#toggle_terminal() abort - execute "ToggleTerm" - set nonumber norelativenumber -endfunction - function! doom#functions#quit_doom(write, force) abort try call doom#logging#message('*', 'Checking if the colorscheme was changed...', 2) @@ -55,7 +47,7 @@ function! doom#functions#quit_doom(write, force) abort " Save current session if enabled if g:doom_autosave_sessions ==# 1 - exec ':SessionSave' + exec ':SaveSession' endif if a:write == 1 @@ -71,9 +63,12 @@ endfunction " Create a markdown report to use when a bug occurs, " useful for debugging issues. function! doom#functions#createReport() abort - exec ':silent !echo "# doom crash report" >> $HOME/.config/doom-nvim/logs/report.md' - exec ':silent !echo "## Begin log dump" >> $HOME/.config/doom-nvim/logs/report.md' + let time = strftime('%c') + + exec ':silent !echo "\# doom crash report\n" >> $HOME/.config/doom-nvim/logs/report.md' + exec ":silent !echo \"Report date: ".time."\" >> $HOME/.config/doom-nvim/logs/report.md" + exec ':silent !echo "\n\#\# Begin log dump" >> $HOME/.config/doom-nvim/logs/report.md' exec ':silent !echo | cat $HOME/.config/doom-nvim/logs/doom.log >> $HOME/.config/doom-nvim/logs/report.md' - exec ':silent !echo "## End log dump" >> $HOME/.config/doom-nvim/logs/report.md' - exec ':silent echo "Report created at $HOME/.config/doom-nvim/logs/report.md"' + exec ':silent !echo "\#\# End log dump\n" >> $HOME/.config/doom-nvim/logs/report.md' + echo "Report created at ".expand("$HOME/.config/doom-nvim/logs/report.md") endfunction diff --git a/autoload/doom/logging.vim b/autoload/doom/logging.vim index b5999d0..598b715 100644 --- a/autoload/doom/logging.vim +++ b/autoload/doom/logging.vim @@ -13,7 +13,7 @@ function! doom#logging#init() echo boot_msg endif exec ':silent !echo " " >> $HOME/.config/doom-nvim/logs/doom.log' - exec ':silent !echo '.boot_msg.' >> $HOME/.config/doom-nvim/logs/doom.log' + exec ":silent !echo \"".boot_msg."\" >> $HOME/.config/doom-nvim/logs/doom.log" catch echo 'Cannot write on_start log message' exec ':!touch $HOME/.config/doom-nvim/logs/doom.log' diff --git a/autoload/doom/system.vim b/autoload/doom/system.vim index 2962350..2a3f135 100644 --- a/autoload/doom/system.vim +++ b/autoload/doom/system.vim @@ -8,7 +8,7 @@ scriptencoding utf-8 function! doom#system#whichos() - call doom#logging#message('+', 'Checking OS', 2) + call doom#logging#message('+', 'Checking OS ...', 2) let g:doom_os = '' let g:doom_separator = '' @@ -26,28 +26,31 @@ function! doom#system#whichos() let g:doom_os = 'cygwin' let g:doom_separator = '\\' else - echo 'OS not recognized' + call doom#logging#message('!', 'OS not recognized', 1) endif - call doom#logging#message('+', 'Current OS: '.g:doom_os, 2) + call doom#logging#message('+', 'Current OS : ' . g:doom_os, 2) endfunction function! doom#system#grepconfig(folder, filename, source) abort " Source file or returns the full path - let fullpath = g:doom_root . g:doom_separator . a:folder . g:doom_separator . a:filename + let fullpath = g:doom_root . g:doom_separator . 'lua' . g:doom_separator .a:folder . g:doom_separator . a:filename + let b:luafile = a:folder . '.' . a:filename - if filereadable(fullpath) + if filereadable(fullpath . '.lua') if a:source ==# 1 try - execute 'source ' fullpath - call doom#logging#message('+', 'Sourced file : '.a:filename, 2) + lua require(vim.b.luafile) + call doom#logging#message('+', 'Sourced file : ' . a:filename, 2) catch - call doom#logging#message('!', 'Failed sourcing '.a:filename, 1) + call doom#logging#message('!', 'Failed sourcing ' . a:filename . "\n" . v:exception, 1) endtry else - call doom#logging#message('+', 'Returned '.a:filename.' path', 2) + call doom#logging#message('+', 'Returned ' . a:filename . ' path', 2) return fullpath endif + else + call doom#logging#message('!', 'Trying to source an inexistent file (' . fullpath.'.lua' . ')', 1) endif endfunction diff --git a/colors/doom-one.vim b/colors/doom-one.vim index c6bb738..6ef4e69 100644 --- a/colors/doom-one.vim +++ b/colors/doom-one.vim @@ -511,7 +511,7 @@ hi! link TSFuncBuiltin FunctionBuiltin hi! link TSFuncMacro Function hi! link TSInclude Include hi! link TSKeyword Keyword -hi! link TSKeywordFunction Function +hi! link TSKeywordFunction Keyword hi! link TSKeywordOperator Operator hi! link TSLabel Label hi! link TSLiteral Constant diff --git a/config/gui.vim b/config/gui.vim deleted file mode 100644 index 95e426a..0000000 --- a/config/gui.vim +++ /dev/null @@ -1,31 +0,0 @@ -"================================================ -" gui.vim - Doom Nvim Gui settings -" Author: NTBBloodbath -" License: MIT -"================================================ - -" If no colorscheme was established then fallback to defaults -if g:doom_colorscheme !=# '' - try - exec 'set background=' . g:doom_colorscheme_bg - exec 'colorscheme ' . g:doom_colorscheme - catch - call doom#logging#message('!', 'Colorscheme not found', 1) - exec 'colorscheme ' . g:doom_colorscheme - endtry -else - call doom#logging#message('!', 'Forced default colorscheme', 1) - exec 'colorscheme default' -endif - -" If guicolors are enabled -if g:doom_enable_guicolors == 1 - if has('nvim') - set termguicolors - endif - if exists('+termguicolors') - set termguicolors - elseif exists('+guicolors') - set guicolors - endif -endif diff --git a/config/keybindings.vim b/config/keybindings.vim deleted file mode 100644 index 268aa1f..0000000 --- a/config/keybindings.vim +++ /dev/null @@ -1,94 +0,0 @@ -" Define leader key to space -" and call leader mapper -nnoremap -let g:mapleader = " " - -"==============================================" - - "========================================" - " " - " Custom Key Mappings " - " " - " b = Buffer Menu " - " f = File Menu " - " g = Git Menu " - " p = Plugin Menu " - " r = Runner Menu " - " s = Session Menu " - " T = Toggle Menu " - " w = Window Menu " - " " - " TAB = Cycle buffers " - " ESC = Search highlighting off " - " F2 = Toggle Tagbar " - " F3 = Toggle Tree Explorer " - " F4 = Toggle Terminal " - " F5 = Toggle Minimap " - " F6 = Toggle distraction-free " - " F7 = Run dot-http " - " " - "========================================" - -"==============================================" - -"===========================" -" LSP Keybindings " -"===========================" -" If the LSP group is not disabled or the nvim-compe plugin is not disabled -" then set its mappings. -if index(g:doom_disabled_modules, 'lsp') == -1 - " https://github.com/hrsh7th/nvim-compe#mappings - inoremap compe#complete() - inoremap compe#confirm('') - inoremap compe#close('') - inoremap compe#scroll({ 'delta': +4 }) - inoremap compe#scroll({ 'delta': -4 }) -endif - -" tab to cycle buffers too, why not? -nnoremap :bnext -nnoremap :bprevious - -" esc to turn off search highlighting -nnoremap :noh - -" F keybindings -if index(g:doom_disabled_plugins, 'vista') == -1 - nnoremap :Vista!! -endif -if index(g:doom_disabled_plugins, 'tree') == -1 - nnoremap :NvimTreeToggle -endif -if index(g:doom_disabled_plugins, 'terminal') == -1 - nnoremap :call doom#functions#toggle_terminal() -endif -if index(g:doom_disabled_plugins, 'minimap') == -1 - nnoremap :MinimapToggle -endif -if index(g:doom_disabled_plugins, 'goyo') == -1 - nnoremap :Goyo -endif -if index(g:doom_disabled_modules, 'web') == -1 && - \ index(g:doom_disabled_plugins, 'restclient') == -1 - nnoremap :DotHttp -endif - -"=====================" -" Disable keys " -"=====================" -" disable accidentally pressing ctrl-z and suspending -nnoremap - -" disable ex mode -nnoremap Q - -" disable recording -nnoremap q - -" Fast exit from Doom Nvim -nnoremap ZZ :call doom#functions#quit_doom(1,1) - -if index(g:doom_disabled_modules, 'fuzzy') == -1 || index(g:doom_disabled_plugins, 'telescope') == -1 - " Set-up vim_buffer_ previewer - autocmd User TelescopePreviewerLoaded setlocal wrap -endif diff --git a/config/plugins/leader-mapper.vim b/config/plugins/leader-mapper.vim deleted file mode 100644 index 0da9ccf..0000000 --- a/config/plugins/leader-mapper.vim +++ /dev/null @@ -1,259 +0,0 @@ -" Define prefix dictionary -let g:lmap = {} - -" LSP Menu -if index(g:doom_disabled_modules, 'lsp') == -1 && index(g:doom_disabled_plugins, 'compe') == -1 - let g:lmap.l = {'name': 'LSP Menu'} - " Show type definition - nnoremap lD lua vim.lsp.buf.type_definition() - let g:lmap.l.D = 'Show type definition' - " Show line diagnostics - nnoremap le lua vim.lsp.diagnostic.show_line_diagnostics() - let g:lmap.l.e = 'Show line diagnostics' - " Diagnostics into location list - nnoremap lq lua vim.lsp.diagnostic.set_loclist() - let g:lmap.l.q = 'Diagnostics into location list' -endif - -" Git Menu -if index(g:doom_disabled_modules, 'git') == -1 && index(g:doom_disabled_plugins, 'lazygit') == -1 || - \ index(g:doom_disabled_modules, 'git') == -1 && index(g:doom_disabled_plugins, 'toggleterm') == -1 || - \ index(g:doom_disabled_modules, 'git') == -1 && index(g:doom_disabled_plugins, 'gitsigns') == -1 - let g:lmap.g = {'name': 'Git Menu'} - if index(g:doom_disabled_plugins, 'lazygit') == -1 - " Open LazyGit - nnoremap go :LazyGit - let g:lmap.g.o = 'Open LazyGit' - endif - if index(g:doom_disabled_plugins, 'toggleterm') == -1 - " Pull - nnoremap gP :TermExec cmd='git pull' - let g:lmap.g.P = 'Pull' - " Push - nnoremap gp :TermExec cmd='git push' - let g:lmap.g.p = 'Push' - " Status - nnoremap gs :TermExec cmd='git status' - let g:lmap.g.s = 'Status' - endif - if index(g:doom_disabled_plugins, 'gitsigns') == -1 - " Stage hunk - let g:lmap.g.S = 'Stage hunk' - " Undo stage hunk - let g:lmap.g.u = 'Undo stage hunk' - " Reset hunk - let g:lmap.g.r = 'Reset hunk' - " Reset buffer - let g:lmap.g.R = 'Reset buffer' - " Preview hunk - let g:lmap.g.h = 'Preview hunk' - " Blame line - let g:lmap.g.b = 'Blame line' - endif -endif - -" Plugin Menu -let g:lmap.p = {'name': 'Plugin Menu'} -" Clean disabled or unused plugins -nnoremap pc :PackerClean -let g:lmap.p.c = 'Clean disabled or unused plugins' -" Install missing plugins -nnoremap pi :PackerInstall -let g:lmap.p.i = 'Install missing plugins' -" Performs PackerClean and then PackerUpdate -nnoremap ps :PackerSync -let g:lmap.p.s = 'Performs PackerClean and then PackerUpdate' -" Update your plugins -nnoremap pu :PackerUpdate -let g:lmap.p.u = 'Update your plugins' - -" Buffer Menu -let g:lmap.b = {'name': 'Buffer Menu'} -" Go to buffer 1 -nnoremap b1 :BufferGoto 1 -let g:lmap.b.1 = 'Buffer 1' -" Go to buffer 2 -nnoremap b2 :BufferGoto 2 -let g:lmap.b.2 = 'Buffer 2' -" Go to buffer 3 -nnoremap b3 :BufferGoto 3 -let g:lmap.b.3 = 'Buffer 3' -" Go to buffer 4 -nnoremap b4 :BufferGoto 4 -let g:lmap.b.4 = 'Buffer 4' -" Go to buffer 5 -nnoremap b5 :BufferGoto 5 -let g:lmap.b.5 = 'Buffer 5' -" Go to buffer 6 -nnoremap b6 :BufferGoto 6 -let g:lmap.b.6 = 'Buffer 6' -" Go to buffer 7 -nnoremap b7 :BufferGoto 7 -let g:lmap.b.7 = 'Buffer 7' -" Go to buffer 8 -nnoremap b8 :BufferGoto 8 -let g:lmap.b.8 = 'Buffer 8' -" Go to last buffer -nnoremap b9 :BufferLast -let g:lmap.b.9 = 'Last buffer' -" Close current buffer -nnoremap bc :BufferClose -let g:lmap.b.c = 'Close buffer' -" Format buffer -nnoremap bf :Neoformat -let g:lmap.b.f = 'Format buffer' -" Next buffer -nnoremap bn :BufferNext -let g:lmap.b.n = 'Next buffer' -" Pick buffer -nnoremap bP :BufferPick -let g:lmap.b.P = 'Pick buffer' -" Previous buffer -nnoremap bp :BufferPrevious -let g:lmap.b.p = 'Previous buffer' - -" Order Buffer Menu -let g:lmap.o = {'name': 'Order Menu'} -" Sort by directory -nnoremap od :BufferOrderByDirectory -let g:lmap.o.d = 'Sort by directory' -" Sort by language -nnoremap ol :BufferOrderByLanguage -let g:lmap.o.l = 'Sort by language' -" Re-order buffer to next -nnoremap on :BufferMoveNext -let g:lmap.o.n = 'Re-order buffer to next' -" Re-order buffer to previous -nnoremap op :BufferMovePrevious -let g:lmap.o.p = 'Re-order buffer to previous' - -" File Menu -let g:lmap.f = {'name': 'File Menu'} -" Edit Neovim configuration -nnoremap fc :e $MYVIMRC -let g:lmap.f.c = 'Edit Neovim configuration' -" Create a new unnamed buffer -nnoremap fn :new -let g:lmap.f.n = 'Create a new unnamed buffer' -if index(g:doom_disabled_plugins, 'telescope') == -1 - " Bookmarks - nnoremap fb :Telescope marks - let g:lmap.f.b = 'Bookmarks' - " Find file - nnoremap ff :Telescope find_files - let g:lmap.f.f = 'Find file' - " Find word - nnoremap fg :Telescope live_grep - let g:lmap.f.g = 'Find word' - " Help tags - nnoremap ft :Telescope help_tags - let g:lmap.f.t = 'Help Tags' - " Override existing telescope fh mapping - autocmd VimEnter * noremap fh :Telescope oldfiles - " Recently opened files - nnoremap fh :Telescope oldfiles - let g:lmap.f.h = 'Recently opened files' -endif -if index(g:doom_disabled_plugins, 'suda') == -1 - " Write file with sudo permissions (For unwritable files) - nnoremap fw :SudaWrite - let g:lmap.f.w = 'Write file with sudo permissions (For unwritable files)' - " Re-open file with sudo permissions (For unreadable files only!) - nnoremap fr :SudaRead - let g:lmap.f.r = 'Re-open file with sudo permissions (For unreadable files only!)' -endif - -" Window Menu -let g:lmap.w = {'name': 'Window Menu'} -" Close all other windows -nnoremap wC :only -let g:lmap.w.C = 'Close all other windows' -" Close current window -nnoremap wc :close -let g:lmap.w.c = 'Close current window' -" Split horizontally -nnoremap wh :split -let g:lmap.w.h = 'Split horizontally' -" Split vertically -nnoremap wv :vsplit -let g:lmap.w.v = 'Split vertically' - -" Runner Menu -if index(g:doom_disabled_modules, 'web') == -1 - let g:lmap.r = {'name': 'Runner Menu'} - if index(g:doom_disabled_plugins, 'dot-http') == -1 - " Run dot-http on the line that the cursor is currently on - nnoremap rh :DotHttp - let g:lmap.r.h = 'Run dot-http on the line that the cursor is currently on' - endif -endif - -" Session Menu -let g:lmap.s = {'name': 'Session Menu'} -" Save session -nnoremap ss :SessionSave -let g:lmap.s.s = 'Save session' -" Load session -nnoremap sl :SessionLoad -let g:lmap.s.l = 'Load session' - -" Doom Menu -let g:lmap.d = {'name': 'Doom Menu'} -" Open your Doom Nvim configurations -nnoremap dc :e ~/.config/doom-nvim/doomrc -let g:lmap.d.c = 'Edit your Doom Nvim configuration' -" Open Doom Nvim docs -nnoremap dd :help doom_nvim -let g:lmap.d.d = 'Open Doom Nvim Documentation' -" Check Doom Nvim Updates and update if available -nnoremap du :DoomUpdate -let g:lmap.d.u = 'Check Doom Nvim Updates' - -" ToggleNumbers function, -" toggle between relative numbers and absolute numbers -" depending on the value of g:doom_relative_num -function ToggleNumbers() - if g:doom_relative_num ==# 1 - set number! relativenumber! - else - set number! - endif -endfunction -" Toggle Menu -let g:lmap.t = {'name': 'Toggler Menu'} -" Toggle Line Numbers -nnoremap tn :call ToggleNumbers() -let g:lmap.t.n = 'Toggle Line Numbers' -" Open start screen -nnoremap ts :Dashboard -let g:lmap.t.s = 'Open start screen' -" Change colorscheme -nnoremap tc :DashboardChangeColorscheme -let g:lmap.t.c = 'Change colorscheme' -if index(g:doom_disabled_plugins, 'tree') == -1 - " Toggle Tree Explorer - nnoremap te :NvimTreeToggle - let g:lmap.t.e = 'Toggle Tree Explorer' -endif -if index(g:doom_disabled_plugins, 'minimap') == -1 - " Toggle Minimap - nnoremap tm :MinimapToggle - let g:lmap.t.m = 'Toggle Minimap' -endif -if index(g:doom_disabled_plugins, 'vista') == -1 - " Toggle Tags view - nnoremap tT :Vista!! - let g:lmap.t.T = 'Toggle Tags view' -endif -if index(g:doom_disabled_plugins, 'toggleterm') == -1 - " Open a new terminal - nnoremap tt :call doom#functions#toggle_terminal() - let g:lmap.t.t = 'Toggle terminal' -endif - -" Display menus with a `+` in-front of the description (à la emacs-which-key). -let g:leaderGuide_display_plus_menus = 1 -" Register the dictionary -call leaderGuide#register_prefix_descriptions('', 'g:lmap') -nnoremap :LeaderGuide '' -vnoremap :LeaderGuideVisual '' diff --git a/config/plugins/neoformat.vim b/config/plugins/neoformat.vim deleted file mode 100644 index f7b3885..0000000 --- a/config/plugins/neoformat.vim +++ /dev/null @@ -1,12 +0,0 @@ -" - Enable basic formatting when a ft is not found -" Enable alignment -let g:neoformat_basic_format_align = 1 -" Enable tab to spaces conversion -let g:neoformat_basic_format_retab = 1 -" Enable trimming of trailing whitespace -let g:neoformat_basic_format_trim = 1 - -" Run all the formatters if the defined below fails -let g:neoformat_run_all_formatters = 1 -" Only message when there is an error -let g:neoformat_only_msg_on_error = 1 diff --git a/config/plugins/vista.vim b/config/plugins/vista.vim deleted file mode 100644 index 230c23c..0000000 --- a/config/plugins/vista.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Position to open the vista sidebar only -if g:doom_tagbar_left ==# 1 - let g:vista_sidebar_position = 'vertical topleft' -else - let g:vista_sidebar_position = 'vertical botright' -endif - -" Sidebar width -let g:vista_sidebar_width = g:doom_sidebar_width - -" Executive used when opening vista sidebar without specifying it. -let g:vista_default_executive = 'nvim_lsp' - -" Set how to show the detailed information of the current cursor symbol -let g:vista_echo_cursor_strategy = 'both' - -" Close the vista window automatically when you jump to a symbol -let g:vista_close_on_jump = 1 - -" Ensure you have installed some decent font to show these pretty symbols, -" then you can enable icon for the kind. -let g:vista#renderer#enable_icon = 1 - -" The default icons can't be suitable for all the filetypes, you can extend it -" as you wish. -let g:vista#renderer#icons = { - \ "function": "\uf794", - \ "variable": "\uf71b", - \} diff --git a/doc/doom_nvim.txt b/doc/doom_nvim.txt index 745d667..cd643da 100644 --- a/doc/doom_nvim.txt +++ b/doc/doom_nvim.txt @@ -38,20 +38,20 @@ 7. Modules..............................|doom_nvim_configuration_modules| 1. Enabling modules..........|doom_nvim_configuration_modules_enabling| 2. Disabling modules........|doom_nvim_configuration_modules_disabling| - 8. LSP......................................|doom_nvim_configuration_lsp| + 8. Custom Plugins................|doom_nvim_configuration_custom_plugins| + 9. LSP......................................|doom_nvim_configuration_lsp| 4. Commands............................................|doom_nvim_commands| 1. Keybindings...........................|doom_nvim_commands_keybindings| - 5. Functions..........................................|doom_nvim_functions| - 6. Usage..................................................|doom_nvim_usage| + 5. Usage..................................................|doom_nvim_usage| 1. Moving around..........................|doom_nvim_usage_moving_around| - 7. Known issues..........................................|doom_nvim_issues| - 8. FAQ......................................................|doom_nvim_faq| - 9. Hacking Doom Nvim....................................|doom_nvim_hacking| + 6. Known issues..........................................|doom_nvim_issues| + 7. FAQ......................................................|doom_nvim_faq| + 8. Hacking Doom Nvim....................................|doom_nvim_hacking| 1. Autoload..................................|doom_nvim_hacking_autoload| - 10. Acknowledgements...........................|doom_nvim_acknowledgements| - 11. License.............................................|doom_nvim_license| - 12. Contributing...................................|doom_nvim_contributing| - 13. Changelog.........................................|doom_nvim_changelog| + 9. Acknowledgements...........................|doom_nvim_acknowledgements| + 10. License.............................................|doom_nvim_license| + 11. Contributing...................................|doom_nvim_contributing| + 12. Changelog.........................................|doom_nvim_changelog| ============================================================================== @@ -74,7 +74,7 @@ OPTIONS *doom_nvim_options* Doom Nvim configuration files resides in the `$HOME/.config/doom-nvim/config` directory. Global variables for Doom Nvim resides in -`$HOME/.doom-nvim/autoload/doom.vim`. +`$HOME/.config/doom-nvim/autoload/doom.vim`. All the options available in the `doom.vim` file are global variables. They all start with `g:doom_` followed by a description of ther nature: @@ -95,9 +95,15 @@ default value = 0 default value = 0 0 : Disable session autosave 1 : Enable session autosave +This option will also autoload saved sessions -`g:doom_preserve_edit_pos` +`g:doom_autoload_last_session` default value = 0 +0 : Disable autoload of last unsaved session +1 : Enable autoload of last unsaved session + +`g:doom_preserve_edit_pos` +default value = 1 0 : Disable preservation of last editing position 1 : Enable preservation of last editing position @@ -154,7 +160,7 @@ default value = 0 Check updates of plugins on start `g:doom_disabled_plugins` -default value = [] +default value = ['lazygit', 'minimap', 'restclient'] List of user disabled plugins `g:doom_disabled_modules` @@ -169,8 +175,27 @@ List of user custom plugins Set the parsers for TreeSitter default value = [] +`g:doom_terminal_direction` +default value = 'vertical' +Set the Terminal direction +Available directions: + - vertical + - horizontal + - window + - float + +`g:doom_terminal_width` +default value = 70 +Set the Terminal width +Applies only to float direction + +`g:doom_terminal_height` +default value = 20 +Set the Terminal height +Applies to all directions except window + `g:doom_conceallevel` -default value = 1 +default value = 0 Set Neovim conceal level 0 : Disable indentline and show all 1 : Conceal some functions and show indentlines @@ -250,7 +275,7 @@ following layout: -'A' : The tagbar (Plugin: vista.vim) +'A' : The tagbar (Plugin: SymbolsOutline) 'B' : The main buffer 'C' : The terminal (Plugin: nvim-toggleterm.lua) 'D' : The minimap (Plugin: minimap.vim) @@ -290,11 +315,13 @@ TAGBAR *doom_nvim_configuration_layout_tagbar* Tagbar is a plugin that can show the tags and structure of the opened file, ordered by its scope. For this function, Doom Nvim makes use of -`liuchengxu/vista.vim`. It can be toggled by performing the following commands: -tT for `Tagbar` +`simrat39/symbols-outline.nvim`. It can be toggled by performing the following +commands: + +tS for `Tagbar` for `Tagbar` -See https://github.com/liuchengxu/vista.vim for more information. +See https://github.com/simrat39/symbols-outline.nvim for more information. ============================================================================== @@ -313,6 +340,7 @@ The terminal is placed like in others editors, e.g. Visual Studio Code. The buffer of the terminal is automatically set to `INSERT` mode. The only way to close it is to enter `exit` to close the shell session, or if you just want to toggle it, you can enter in `NORMAL` mode: + tt for `Terminal` for `Terminal` @@ -325,12 +353,12 @@ bundle of plugins, configuration and commands, organized into a unit that can be toggled easily. To give a quick summary, the modules are as follows: - - Essentials (package manager, utilities for using Lua inside Neovim) + - Essentials (package manager, TreeSitter and utilities for using + Lua inside Neovim) - UI (everything related to UI) - - Fuzzy (telescope.nvim, fuzzy searching) - Git (everything related to Git) - LSP (for using Language Server Protocols by using the built-in LSP) - - Files (utilities like formatter, commenter, improvements, etc) + - Files (utilities like formatter, commenter, etc) - Web (for web development) You can see in a more detailed view the modules and its plugins at @@ -345,7 +373,7 @@ To enable a module, you can use the `g:doom_disabled_modules` variable on your Example: To enable all modules except web, just put only 'web' in the disabled - modules array and then, reboot Neovim and do `:PackerSync`. + modules array and then reboot Neovim and do `:PackerSync`. let g:doom_disabled_modules = ['web'] @@ -358,11 +386,40 @@ your `doomrc`. Example: To disable only the web module, just put only 'web' in the disabled - modules array and then, reboot Neovim and do `:PackerSync`. + modules array and then reboot Neovim and do `:PackerSync`. let g:doom_disabled_modules = ['web'] +============================================================================== +CUSTOM PLUGINS *doom_nvim_configuration_custom_plugins* + +To use your own plugins in Doom Nvim you can use the `g:doom_custom_plugins` +variable on your `doomrc`. + +To add plugins without extra configurations (e.g., if a plugin does not depends +on other plugins), you can simply set it as follow: + + let g:doom_custom_plugins = ['andweeb/presence.nvim'] + +Otherwise, if your plugin depends on other or you do not want to enable it, +then you can do it as follow: + + let g:doom_custom_plugins = [ + \ { + \ 'repo': 'andweeb/presence.nvim', + \ 'enabled': 1, + \ 'requires': ['foo', 'bar'] + \ } + \ ] + +As you can see, the second way depends on a structure to work. + + repo: the repository where the plugin resides + enabled: if the plugin should be enabled, not required (true by default) + requires: plugin dependencies, not required + + ============================================================================== LSP *doom_nvim_configuration_lsp* @@ -429,26 +486,33 @@ In Doom Nvim, we make use of the keystroke as the map leader. | oom | | Edit your Doom Nvim configuration | | Open Doom Nvim docs +| | Create crash reports, useful for debugging | | Check Doom Nvim updates | ile | | Bookmarks | | Edit your Neovim Configuration | | Find file -| | Find word +| | Find word | | Recently opened files | | New unnamed buffer | | Re-open an unreadable file with sudo permissions | | Help tags | | Write an unwritable file with sudo permissions | it +| | Blame line +| | Preview hunk +| | Reset buffer +| | Reset hunk | | Open LazyGit -| |

Push | |

Pull +| |

Push +| | Stage hunk | | Status +| | Undo stage hunk | sp -| | Show type definition -| | Show line diagnostics -| | Diagnostics into location list +| | Show type definition +| | Show line diagnostics +| | Diagnostics into location list | rder | | Sort by directory | | Sort by language @@ -457,21 +521,22 @@ In Doom Nvim, we make use of the keystroke as the map leader. |

lugin | | Clean unused plugins | | Install missing plugins +| |

Profile the time taken loading your plugins | | Sync plugins (Clean and Update) | | Update plugins | unner -| | Run rest client in the current cursor line +| | Run restclient in the current cursor line | ession -| | Save session -| | Load session +| | Session switcher/selector +| | Save current session +| | Restore previously saved session | oggler | | Change colorscheme | | Toggle Tree Explorer | | Toggle Minimap -| | Toggle Line Numbers +| | Toggle Symbols view | | Toggle Start Screen | | Toggle Terminal -| | Toggle Tagbar | indow | | Close current window | | Close all other windows @@ -489,9 +554,9 @@ your life easier! | | Toggle Tree Explorer | | Toggle Terminal | | Toggle Minimap -| | Toggle distraction-free mode -| | Run rest client -| | Fast exit from Doom Nvim +| | ToggleZen mode +| | Run restclient +| | Fast exit from Doom Nvim (also dumps `:messages` to logs) | | Comment selected block (`VISUAL` mode) You can modify the default keybindings by modifying the following files: @@ -502,14 +567,6 @@ You can modify the default keybindings by modifying the following files: You can also make your own keybindings by editing your `doomrc` file. -============================================================================== -FUNCTIONS *doom_nvim_functions* - -`ToggleNumbers`: Toggles the line numbers, if `g:doom_relative_num` is `1` -then it will toggle the relative numbers, otherwise, it will toggle the -absolute numbers. - - ============================================================================== USAGE *doom_nvim_usage* @@ -535,19 +592,16 @@ Use `h` go to left, `j` to go down, `k` to go up, `l` to go right. j v -See `Tutor` to know how to use Vim and its keybindings +See `Tutor` to know how to use Vim and its keybindings. To move around buffers execute b to select the `buffers` section -and then press the key corresponding to the buffer you want to select (`1-9`). +and then press the key corresponding to the buffer you want to select (`1-9`) +or press `` to cycle buffers. ============================================================================== KNOWN ISSUES *doom_nvim_issues* -- When using the distraction-free mode, it will be still displaying the - statusbar, at the moment cannot be fixed unless you use other statusline. - See |doom_nvim_configuration_modules_disabling| for more information. - - If you are facing an undocummented issue, feel free to open an issue at Doom Nvim's repository on GitHub and we will try to fix it. https://github.com/NTBBloodbath/doom-nvim/issues/new @@ -578,40 +632,40 @@ Doom Nvim aims to be hackable to suit everyone's needs. Therefore This is the structure of Doom Nvim: - ./ -├──  autoload/ # Files loaded at launch -│ ├──  color.vim # Color utilities, required by doom-one.vim -│ ├──  doom/ # Doom Nvim core -│ │ ├──  autocmds.vim # Doom Nvim autocommands -│ │ ├──  config.vim # Doom Nvim custom config file loader -│ │ ├──  default.vim # Doom Nvim default configs -│ │ ├──  functions.vim # Doom Nvim core functions -│ │ ├──  health.vim # Doom Nvim health -│ │ ├──  logging.vim # Doom Nvim logging manager -│ │ └──  system.vim # Doom Nvim system detection (early stage) -│ └──  doom.vim # Config file for various globals -├──  colors/ # Doom Nvim colorschemes directory -│ └──  doom-one.vim # `romgrk` doom colorscheme ported to Nvim (`default`) -├──  config/ # Configuration files for Doom Nvim -│ ├──  gui.vim # Doom Nvim GUI options -│ ├──  keybindings.vim # Doom Nvim keybindings -│ ├──  main.vim # Init file, loads packer.nvim and plugins -│ └──  plugins/ # Vimscript plugins configs directory -│ ├──  leader....vim # leader-mapper keybindings -│ ├──  neoformat.vim # neoformat configs -│ └──  vista.vim # vista.vim configs -├──  doc/ # Doom Nvim documentation to be used inside Nvim -│ └──  doom_nvim.txt # Doom Nvim help file -├──  docs/ # Doom Nvim docs meant to be readed on GitHub -├──  init.vim # init.vim file -├──  install.sh # Doom Nvim manager -├──  LICENSE # Doom Nvim License -├──  logs/ # Location of Doom Nvim log file -├──  lua/ # Location of Lua plugins, including packer.nvim -│ ├──  configs/ # Location of Lua plugins configurations -│ └──  plugins.lua # Plugin manager configurations -└──  sessions/ # Location of Vim workspaces - + . +├──  autoload # Files loaded at launch +│ ├──  color.vim # Color utilities, required by `doom-one.vim` +│ ├──  doom # Doom Nvim core +│ │ ├──  autocmds.vim # Doom Nvim autocommands +│ │ ├──  config.vim # Doom Nvim custom config file loader +│ │ ├──  default.vim # Doom Nvim default configs +│ │ ├──  functions.vim # Doom Nvim core functions +│ │ ├──  logging.vim # Doom Nvim logging manager +│ │ └──  system.vim # Doom Nvim system detection (early stage) +│ ├──  doom.vim # Config file for various globals +│ └──  health # Doom Nvim health add-ons for `:checkhealth` +├──  colors # Doom Nvim pre-installed colorschemes directory +│ └──  doom-one.vim # `romgrk` doom colorscheme ported to Nvim (`default`) +├──  doc # Doom Nvim documentation to be used inside Nvim +│ └──  doom_nvim.txt # Doom Nvim help file +├──  docs # Doom Nvim docs meant to be readed on GitHub +├──  doomrc # Doom Nvim user configurations file +├──  init.lua # init.lua file +├──  install.sh # Doom Nvim installer +├──  LICENSE # Doom Nvim License +├──  logs # Location of Doom Nvim logs +│ ├──  doom.log # Doom Nvim logs +│ └──  report.md # Doom Nvim crash reports, does not exists by default +├──  lua # Location of Doom Nvim Lua files +│ ├──  doom # Doom Nvim Lua core +│ │ ├──  config # Main configurations of Doom Nvim +│ │ ├──  health.lua # Doom Nvim health checking, complement for health dir +│ │ ├──  keybindings.lua # Doom Nvim default keybindings +│ │ └──  utils # Doom Nvim Lua utilities +│ └──  plugins # Location of Doom Nvim plugins +│ ├──  configs # Plugins configurations +│ └──  init.lua # packer.nvim setup +└──  sessions # Location of Neovim workspaces Doom Nvim also creates the `BFC`, which serves as the user configuration file if it is not present on the system. It allows a fine control over the core @@ -684,35 +738,88 @@ CONTRIBUTING *doom_nvim_contributing* ============================================================================== CHANGELOG *doom_nvim_changelog* -Doom Nvim follows the semantic versioning and reached its stable version in -version 1.0.0 - +The format is based on Keep a Changelog (https://keepachangelog.com/en/1.0.0/), +and this project adheres to Semantic Versioning +(https://semver.org/spec/v2.0.0.html). + +- 2.0.0 (in development) + - Added + - Configurations + - `g:doom_autoload_last_session` variable, see |doom_nvim_options| + - `g:doom_terminal_direction` variable, see |doom_nvim_options| + - `g:doom_terminal_width` variable, see |doom_nvim_options| + - `g:doom_terminal_height` variable, see |doom_nvim_options| + - Plugins + - `auto-session` + - Changed + - Installation script + - Now you can select the branch to use (main, develop) + - Lua migration + - init + - configs + - plugins + - Implemented better custom plugins system, + see |doom_nvim_configuration_custom_plugins| + - Start using TreeSitter based indentation + - Plugins + - Replaced + - `Goyo` in favour of `TrueZen` + - `leader-mapper` in favour of `WhichKey` + - `Vista.vim` in favour of `SymbolsOutline` + - `Neoformat` in favour of `format.nvim` + - `nvim-autopairs` in favour of `pears.nvim` + - Updated + - `nvim-toggleterm` configurations + - Other changes + - `telescope.nvim` cannot be disabled anymore + - Keybindings + - Refact some `` bindings + - Use `:TZAtaraxis` as F6 key bind + - New `:dr` map, easily create crash reports + - Misc + - Cleaned some code hunk + - Formatted all files + - Refact changelog + - Deleted + - Old Vimscript configs codebase + - Plugins + - Deleted `vim-polyglot` in favour of TreeSitter based + syntax highlighting + - Fixed + - Some bugs that I don't really remember + - Squashed bugs on autoload functions - 1.2.1 - - Improved installation script - - New branch `develop` + - Added + - New branch `develop` + - Changed + - Improved installation script - 1.2.0 - - Added `g:doom_ts_parsers`, - see |doom_nvim_options| - - Added new keybinding for toggle terminal, - see |doom_nvim_commands_keybindings| - - Added a basic implementation for `:checkhealth` command - - Added a `doomrc` template with the default options values - - Improved `:DoomUpdate` command - - Added new plugins - - `gitsigns` - - `indentLine` - - `nvim-lspinstall` - - some new colorschemes, see |doom_colorscheme| - - Removed plugins - - `signify` in favor of `gitsigns` - - Squashed some bugs - - Some minor changes more under the hood + - Added + - Configurations + - `g:doom_ts_parsers`, see |doom_nvim_options| + - New key binding for toggle terminal, + see |doom_nvim_commands_keybindings| + - `doomrc` template with the default options values + - Basic implementation for `:checkhealth` command + - Plugins + - `gitsigns` + - `indentLine` + - `nvim-lspinstall` + - Some new colorschemes, see |doom_colorscheme| + - Changed + - Improved `:DoomUpdate` command + - Some minor changes more under the hood + - Plugins + - `signify` in favor of `gitsigns` + - Fixed + - Squashed some bugs - 1.1.0 - - Added `Doom` section to `vim-leader-guide` plugin, - see |doom_nvim_commands_keybindings| - - Added `:DoomUpdate` command, - see |doom_nvim_commands| - - Added `g:doom_autosave_sessions`, - see |doom_nvim_options| + - Added + - `Doom` section to `vim-leader-guide` plugin, + see |doom_nvim_commands_keybindings| + - `:DoomUpdate` command, + see |doom_nvim_commands| + - `g:doom_autosave_sessions`, + see |doom_nvim_options| - 1.0.0 - - Initial stable release + - Initial stable release diff --git a/doc/tags b/doc/tags index 43cc885..591e97f 100644 --- a/doc/tags +++ b/doc/tags @@ -5,15 +5,20 @@ doom_nvim_changelog doom_nvim.txt /*doom_nvim_changelog* doom_nvim_commands doom_nvim.txt /*doom_nvim_commands* doom_nvim_commands_keybindings doom_nvim.txt /*doom_nvim_commands_keybindings* doom_nvim_configuration doom_nvim.txt /*doom_nvim_configuration* +doom_nvim_configuration_custom_plugins doom_nvim.txt /*doom_nvim_configuration_custom_plugins* doom_nvim_configuration_layout doom_nvim.txt /*doom_nvim_configuration_layout* doom_nvim_configuration_layout_explorer doom_nvim.txt /*doom_nvim_configuration_layout_explorer* doom_nvim_configuration_layout_mainbuffer doom_nvim.txt /*doom_nvim_configuration_layout_mainbuffer* +doom_nvim_configuration_layout_minimap doom_nvim.txt /*doom_nvim_configuration_layout_minimap* doom_nvim_configuration_layout_tagbar doom_nvim.txt /*doom_nvim_configuration_layout_tagbar* doom_nvim_configuration_layout_terminal doom_nvim.txt /*doom_nvim_configuration_layout_terminal* +doom_nvim_configuration_lsp doom_nvim.txt /*doom_nvim_configuration_lsp* +doom_nvim_configuration_modules doom_nvim.txt /*doom_nvim_configuration_modules* +doom_nvim_configuration_modules_disabling doom_nvim.txt /*doom_nvim_configuration_modules_disabling* +doom_nvim_configuration_modules_enabling doom_nvim.txt /*doom_nvim_configuration_modules_enabling* doom_nvim_contents doom_nvim.txt /*doom_nvim_contents* doom_nvim_contributing doom_nvim.txt /*doom_nvim_contributing* doom_nvim_faq doom_nvim.txt /*doom_nvim_faq* -doom_nvim_functions doom_nvim.txt /*doom_nvim_functions* doom_nvim_hacking doom_nvim.txt /*doom_nvim_hacking* doom_nvim_hacking_autoload doom_nvim.txt /*doom_nvim_hacking_autoload* doom_nvim_intro doom_nvim.txt /*doom_nvim_intro* diff --git a/docs/contributing.md b/docs/contributing.md index 31329d7..245aee5 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -8,7 +8,7 @@ You are welcome to contribute with anything to improve Doom Nvim, but please look at [contributing code](#contributing-code) to know better how to contribute and which code style you should use :heart: -> **Working on your first Pull Request?** You can learn how from this *free* series +> **Working on your first Pull Request?** You can learn how from this _free_ series > [How to Contribute to an Open Source Project on GitHub](https://kcd.im/pull-request). # Table of Contents @@ -42,15 +42,15 @@ and which code style you should use :heart: ## Acquire a backtrace from errors -All the errors ocurred in Doom Nvim are saved into a `doom.log` file inside your -Doom Nvim root dir (`$HOME/.config/doom-nvim` by default). If the logs are very long, please -paste it using a [gist]. +All the errors ocurred in Doom Nvim are saved into a `doom.log` file inside a `logs/` +directory inside your Doom Nvim root dir (`$HOME/.config/doom-nvim` by default). +If the logs are very long, please paste it using a [gist]. > **NOTE:** Alternatively you can paste the most recent lines starting with the > following if the logs are extremely long. > > [!] - Errors -> +> > [!!!] - Critical errors ## Create a step-by-step reproduction guide @@ -61,6 +61,7 @@ thus reach a solution more quickly. ## Include information about your Doom Nvim install Some important data would be: + - Your Neovim version - Your custom configuration if you have one (`$HOME/.config/doom-nvim/doomrc`) - Which branch of Doom Nvim are you using @@ -87,20 +88,31 @@ Doom Nvim follows some code style rules like ones the mentioned below: - Variable names in `snake_case`, except in the BASH installation script. - Function names in `snake_case`, the only exception are the Vimscript functions which does not are from doom itself, e.g. `function ToggleTerm() ... endfunction`. +- [stylua] is used to format lua files with the following configuration: + +```toml +column_width = 80 +line_endings = "Unix" +indent_type = "Tabs" +indent_width = 4 +quote_style = "AutoPreferSingle" + +``` ### Commits & PRs -- Target `develop-nightly` instead of `main`. +- Target `develop` instead of `main`. the only exception are hotfixes! ### Keybind conventions -- The keybindings should be declared in [config/keybindings](../config/keybindings.vim), - except when they are keybindings of the [leader-mapper](../config/plugins/leader-mapper.vim) - or keybindings of [Lua plugins](../lua/configs). +- The keybindings should be declared in [config/keybindings](../lua/doom/keybindings.lua), + except when they are keybindings of [Lua plugins](../lua/plugins/configs). ## Submitting pull requests After having made all your changes and having tested them locally to certify that they work and do not break any of the current code, you can proceed to upload your pull request :) + +[stylua]: https://github.com/JohnnyMorganz/StyLua diff --git a/docs/getting_started.md b/docs/getting_started.md index 7102369..ee1e001 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -221,7 +221,7 @@ Read on to learn how to use this system to install your own plugins. ### Installing plugins -To install a custom package, add it to `g:doom_custom_plugins` variable into your +To install a custom plugin, add it to `g:doom_custom_plugins` variable into your `doomrc`. ```vim @@ -229,6 +229,19 @@ To install a custom package, add it to `g:doom_custom_plugins` variable into you let g:doom_custom_plugins = ['plugin_author/plugin_repo'] ``` +You can also use other method if the plugin depends on other plugins. + +```vim +let g:doom_custom_plugins = [ + \ 'plugin_author/plugin_repo', + \ { + \ 'repo': 'plugin_author/second_plugin_repo', + \ 'enabled': 1, " not required, 1 by default + \ 'requires': ['foo', 'bar'] " not required if the plugin does not have dependencies + \ }, + \ ] +``` + > **NOTES:** > > 1. Do not forget to run `:PackerInstall` to install your new plugins. @@ -265,8 +278,7 @@ You can change Doom's default settings by tweaking your `doomrc`, please see Do you want to change some configurations of some modules? -Go to `lua/configs` dir and you will find the configurations for the Lua plugins, -or go to `config/plugins` dir to change the Vimscript plugins configurations. +Go to `lua/plugins/configs` dir and you will find the configurations for the plugins. ### Configuring LSP @@ -282,8 +294,8 @@ You can see a list of currently supported languages at [bundled installers](http ## Binding keys You can modify the default keybindings by modifying the following files: - - `config/keybindings.vim` - general keybindings - - `config/plugins/leader-mapper.vim` - SPC keybindings - - `lua/configs` - lua plugins keybindings + +- `lua/doom/keybindings.lua` - General and SPC keybindings +- `lua/plugins/configs` - lua plugins keybindings You can also make your own keybindings by editing your `doomrc` file. diff --git a/docs/modules.md b/docs/modules.md index 7271c7f..51ea268 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -1,12 +1,21 @@ # Doom Nvim Modules # Table of Contents + - [Introduction](#introduction) - [Tweaking Doom Nvim Modules](#tweaking-doom-nvim-modules) - [List of modules](#list-of-modules) - - [Enabling modules](#enabling-modules) + - [Essentials](#essentials) + - [UI](#ui) + - [Fuzzy](#fuzzy) + - [Git](#git) + - [LSP](#lsp) + - [Files](#files) + - [Web](#web) + - [Managing modules](#managing-modules) + - [Enabling modules](#enabling-modules) - [Enabling module plugins](#enabling-module-plugins) - - [Disabling modules](#disabling-modules) + - [Disabling modules](#disabling-modules) - [Disabling module plugins](#disabling-module-plugins) # Introduction @@ -24,98 +33,108 @@ You can easily tweak Doom Nvim Modules by tweaking your doomrc First of all, we must know which modules we can enable and disable, including their plugins individually. -- Essentials - - [x] Enabled by default - - [ ] Can be disabled - - Plugins inside - - [ ] packer.nvim (Plugins manager) - - [ ] vimpeccable (Helpers for Lua configs) - - [ ] vim-polyglot (Support for languages) -- UI - - [x] Enabled by default - - [ ] Can be disabled - - Plugins inside - - [ ] dashboard-nvim (Start screen) - - [ ] colorschemes (obviously, colorschemes) - - [x] nvim-tree (File tree) - - Use `tree` to disable it - - [x] galaxyline.nvim (Statusline) - - Use `statusline` to disable it - - [x] barbar.nvim (Tabline) - - Use `tabline` to disable it - - [x] focus.nvim (better splits) - - Use `focus` to disable it - - [x] nvim-toggleterm (better terminal) - - Use `terminal` to disable it - - [x] vista.vim (viewer for LSP symbols and tags) - - Use `vista` to disable it - - [x] minimap.vim (Minimap) - - Use `minimap` to disable it - - **Depends on** [wfxr/code-minimap](htps://github.com/wfxr/code-minimap) **to work!** - - [ ] vim-leader-guide (Menu like Emacs's guide-key) - - [x] goyo.vim (Distraction free environment) - - Use `goyo` to disable it -- Fuzzy Search - - [x] Enabled by default - - [x] Can be disabled - - Use `fuzzy` to disable the entire module - - Plugins inside - - [x] telescope.nvim (Fuzzy search & more) - - Use `telescope` to disable it - - **NOTE:** dashboard-nvim depends on telescope to do some things, like shortcuts! -- Git - - [ ] Enabled by default - - [x] Can be disabled - - Use `git` to disable the entire module - - Plugins inside - - [x] vim-signify (Show a diff using Vim its sign column) - - Use `signify` to disable it - - [x] lazygit (Call lazygit from within Neovim) - - Use `lazygit` to disable it - - **Depends on** [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) **to work!** -- LSP - - [ ] Enabled by default - - [x] Can be disabled - - Use `lsp` to disable the entire module - - Plugins inside - - [x] nvim-lspconfig (Configurations for the Nvim LSP client) - - Use `lspconfig` to disable it - - **NOTE:** do not disable it if you are going to use LSP! - - [x] nvim-compe (Auto completion plugin for nvim) - - Use `compe` to disable it -- Files - - [x] Enabled by default - - [x] Can be disabled - - Use `files` to disable the entire module - - Plugins inside - - [x] suda.vim (Write/Read files without having to use `sudo nvim`, still requires user password!) - - Use `suda` to disable it - - [x] neoformat (File formatting) - - Use `neoformat` to disable it - - [x] nvim-autopairs (Autopairs) - - Use `autopairs` to disable it - - [x] indent-blankline (Indent Lines Guide) - - Use `indentlines` to disable it - - [x] editorconfig (EditorConfig support) - - Use `editorconfig` to disable it - - [x] treesitter (Better syntax highlight & more) - - Use `treesitter` to disable it - - [x] kommentary (Comments plugin) - - Use `kommentary` to disable it -- Web - - [ ] Enabled by default - - [x] Can be disabled - - Use `web` to disable the entire module - - Plugins inside - - [x] nvim-colorizer (Fastest colorizer without external dependencies) - - Use `colorizer` to disable it - - [x] vim-dot-http (Rest HTTP Client) - - Use `restclient` to disable it - - **Depends on** [bayne/dot-http](https://github/bayne/dot-http) **to work!** - - [x] emmet-vim (Emmet plugin for Vim) - - Use `emmet` to disable it - -## Enabling modules +### Essentials + +- [x] Enabled by default +- [ ] Can be disabled +- Plugins inside + - [ ] [packer.nvim] - A use-package inspired plugin manager for Neovim. + - [ ] [vimpeccable] - Helpers for Lua configs. + - [x] [treesitter] - Nvim Treesitter configurations and abstraction layer. + +### UI + +- [x] Enabled by default +- [ ] Can be disabled +- Plugins inside + - [ ] [dashboard-nvim] - Vim dashboard. + - [ ] colorschemes - Obviously, colorschemes. + - [x] [nvim-tree.lua] - A file explorer tree for neovim written in lua. + - Use `tree` to disable it + - [x] [galaxyline.nvim] - galaxyline is a light-weight and Super Fast statusline plugin. + - Use `statusline` to disable it + - [x] [barbar.nvim] - Tabs, as understood by any other editor. + - Use `tabline` to disable it + - [x] [focus.nvim] - Auto-Focusing Splits/Windows for Neovim written in Lua + - Use `focus` to disable it + - [x] [nvim-toggleterm.lua] - A neovim plugin to persist and toggle multiple terminals during an editing session + - Use `terminal` to disable it + - [x] [symbols-outline.nvim] - A tree like view for symbols in Neovim using the Language Server Protocol. + - Use `tagbar` to disable it + - [x] [minimap.vim] - Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust. + - Use `minimap` to disable it + - **Depends on** [wfxr/code-minimap](htps://github.com/wfxr/code-minimap) **to work!** + - [ ] [which-key.nvim] - WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing. + - [x] [TrueZen.nvim] - Clean and elegant distraction-free writing for NeoVim. + - Use `zen` to disable it + +### Fuzzy + +- [x] Enabled by default +- [ ] Can be disabled +- Plugins inside + - [ ] [telescope.nvim] - Find, Filter, Preview, Pick. All lua, all the time. + +### Git + +- [ ] Enabled by default +- [x] Can be disabled + - Use `git` to disable the entire module +- Plugins inside + - [x] [gitsigns.nvim] - Git signs written in pure lua + - Use `gitsigns` to disable it + - [x] [lazygit.nvim] - Plugin for calling lazygit from within neovim. + - Use `lazygit` to disable it + - **Depends on** [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) **to work!** + +### LSP + +- [ ] Enabled by default +- [x] Can be disabled + - Use `lsp` to disable the entire module +- Plugins inside + - [x] [nvim-lspconfig] - Quickstart configurations for the Nvim LSP client + - Use `lspconfig` to disable it + - **NOTE:** do not disable it if you are going to use LSP! + - [x] [nvim-compe] - Auto completion plugin for nvim that written in Lua. + - Use `compe` to disable it + +### Files + +- [x] Enabled by default +- [x] Can be disabled + - Use `files` to disable the entire module +- Plugins inside + - [x] [suda.vim] - suda is a plugin to read or write files with sudo command. + - Use `suda` to disable it + - [x] [format.nvim] - Neovim lua plugin to format the current buffer with external executables. + - Use `formatter` to disable it + - [x] [pears.nvim] - Auto pair plugin for neovim + - Use `autopairs` to disable it + - [x] [indentLine] - A vim plugin to display the indention levels with thin vertical lines + - Use `indentlines` to disable it + - [x] [editorconfig-vim] - EditorConfig support + - Use `editorconfig` to disable it + - [x] [kommentary] - Neovim commenting plugin, written in lua. + - Use `kommentary` to disable it + +### Web + +- [ ] Enabled by default +- [x] Can be disabled + - Use `web` to disable the entire module +- Plugins inside + - [x] [nvim-colorizer.lua] - A high-performance color highlighter for Neovim which has no external dependencies written in performant Luajit. + - Use `colorizer` to disable it + - [x] [vim-dot-http] - Rest HTTP Client + - Use `restclient` to disable it + - **Depends on** [bayne/dot-http](https://github/bayne/dot-http) **to work!** + - [x] [emmet-vim] - Emmet for Vim + - Use `emmet` to disable it + +## Managing modules + +### Enabling modules To enable a module, you can use the `g:doom_disabled_modules` variable on your `doomrc`. @@ -123,7 +142,7 @@ To enable a module, you can use the `g:doom_disabled_modules` variable on your ```vim " To enable all modules except web, just put only 'web' in the disabled modules " array and then, reboot Neovim and do :PackerSync -" +" " @default = ['git', 'lsp', 'web'] let g:doom_disabled_modules = ['web'] ``` @@ -135,7 +154,7 @@ All the module plugins will be enabled by default unless the entire module is di > If you want to use custom plugins, please refer to > [Installing plugins](./getting_started.md#installing-plugins). -## Disabling modules +### Disabling modules To disable a module, you can use the `g:doom_disabled_modules` variable on your `doomrc`. @@ -143,7 +162,7 @@ on your `doomrc`. ```vim " To disable only the web module, just put only 'web' in the disabled modules " array and then, reboot Neovim and do :PackerSync -" +" " @default = ['git', 'lsp', 'web'] let g:doom_disabled_modules = ['web'] ``` @@ -157,3 +176,48 @@ on your `doomrc`. " @default = [] let g:doom_disabled_plugins = ['emmet'] ``` + + + +[packer.nvim]: https://github.com/wbthomason/packer.nvim +[vimpeccable]: https://github.com/svermeulen/vimpeccable +[treesitter]: https://github.com/nvim-treesitter/nvim-treesitter + + + +[dashboard-nvim]: https://github.com/glepnir/dashboard-nvim +[nvim-tree.lua]: https://github.com/kyazdani42/nvim-tree.lua +[galaxyline.nvim]: https://github.com/glepnir/galaxyline.nvim +[barbar.nvim]: https://github.com/romgrk/barbar.nvim +[focus.nvim]: https://github.com/beauwilliams/focus.nvim +[nvim-toggleterm.lua]: https://github.com/akinsho/nvim-toggleterm.lua +[symbols-outline.nvim]: https://github.com/simrat39/symbols-outline.nvim +[minimap.vim]: https://github.com/wfxr/minimap.vim +[which-key.nvim]: https://github.com/folke/which-key.nvim +[truezen.nvim]: https://github.com/kdav5758/TrueZen.nvim + + + +[telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim + + + +[gitsigns.nvim]: https://github.com/lewis6991/gitsigns.nvim +[lazygit]: https://github.com/kdheepak/lazygit.nvim + + + +[nvim-lspconfig]: https://github.com/neovim/nvim-lspconfig +[nvim-compe]: +[suda.vim]: https://github.com/lambdalisue/suda.vim +[format.nvim]: https://github.com/lukas-reineke/format.nvim +[pears.nvim]: https://github.com/steelsojka/pears.nvim +[indentline]: https://github.com/Yggdroot/indentLine +[editorconfig-vim]: https://github.com/editorconfig/editorconfig-vim +[kommentary]: https://github.com/b3nj5m1n/kommentary + + + +[nvim-colorizer.lua]: https://github.com/norcalli/nvim-colorizer.lua +[vim-dot-http]: https://github.com/bayne/vim-dot-http +[emmet-vim]: https://github.com/mattn/emmet-vim diff --git a/doomrc b/doomrc index 6748486..799f0e6 100644 --- a/doomrc +++ b/doomrc @@ -15,17 +15,22 @@ let g:doom_autosave = 0 " @default = 0 let g:doom_fmt_on_save = 0 -" Autosave sessions +" Autosave and autoload saved sessions " 0 : Disable session autosave " 1 : Enable session autosave " @default = 0 let g:doom_autosave_sessions = 0 +" Autoload last unsaved session +" 0 : Disable last session autoload +" 1 : Enable last session autosave +let g:doom_autoload_last_session = 0 + " Preserve last editing position " 0 : Disable preservation of last editing position " 1 : Enable preservation of last editing position " @default = 0 -let g:doom_preserve_edit_pos = 0 +let g:doom_preserve_edit_pos = 1 " Default indent size " @default = 4 @@ -80,15 +85,15 @@ let g:doom_colorscheme = 'doom-one' " @default = dark let g:doom_colorscheme_bg = 'dark' -" Checkupdates on start +" Check updates on start " @default = 0 let g:doom_check_updates = 0 " Disabled plugins -" @default = [] +" @default = ['lazygit', 'minimap', 'restclient'] " example: " let g:doom_disabled_plugins = ['emmet-vim'] -let g:doom_disabled_plugins = [] +let g:doom_disabled_plugins = ['lazygit', 'minimap', 'restclient'] " Disabled plugins modules " @default = ['git', 'lsp', 'web'] @@ -98,8 +103,16 @@ let g:doom_disabled_modules = ['git', 'lsp', 'web'] " Install custom plugins " @default = [] -" example: -" let g:doom_custom_plugins = ['andweeb/presence.nvim'] +" examples: +" plugins without options: +" let g:doom_custom_plugins = ['andweeb/presence.nvim'] +" plugins with options: +" let g:doom_custom_plugins = [ +" \ { +" \ 'repo': 'andweeb/presence.nvim', +" \ 'enabled': 1, +" \ } +" \ ] let g:doom_custom_plugins = [] " Set the parsers for TreeSitter @@ -108,6 +121,25 @@ let g:doom_custom_plugins = [] " let g:doom_ts_parsers = ['python', 'javascript'] let g:doom_ts_parsers = [] +" Set the Terminal direction +" Available directions: +" - vertical +" - horizontal +" - window +" - float +" @default = 'vertical' +let g:doom_terminal_direction = 'vertical' + +" Set the Terminal width +" Applies only to float direction +" @default = 70 +let g:doom_terminal_width = 70 + +" Set the Terminal height +" Applies to all directions except window +" @default = 20 +let g:doom_terminal_height = 20 + " Conceal level " Set Neovim conceal level " 0 : Disable indentline and show all @@ -115,7 +147,6 @@ let g:doom_ts_parsers = [] " 2 : Concealed text is completely hidden unless it has a custom replacement " character defined " 3 : Concealed text is completely hidden -" @default = 0 let g:doom_conceallevel = 0 " Logging level diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3cad7dc --- /dev/null +++ b/init.lua @@ -0,0 +1,11 @@ +---[[---------------------------------------]]--- +-- init.lua - Init file of Doom Nvim -- +-- Author: NTBBloodbath -- +-- License: MIT -- +---[[---------------------------------------]]--- +-- Utility functions +require('doom.utils') + +-- Main configurations +require('doom.config.main') +require('doom.config.ui') diff --git a/init.vim b/init.vim deleted file mode 100644 index 6bed5e0..0000000 --- a/init.vim +++ /dev/null @@ -1,7 +0,0 @@ -"================================================ -" init.lua - Init file of Doom Nvim -" Author: NTBBloodbath -" License: MIT -"================================================ - -execute 'source' fnamemodify(expand(''), ':h').'/config/main.vim' diff --git a/install.sh b/install.sh index e628ea3..fe1cb1c 100755 --- a/install.sh +++ b/install.sh @@ -32,7 +32,7 @@ BYellow='\033[1;33m' # Yellow # }}} # Doom Nvim version -DoomNvimVersion='1.2.1' +DoomNvimVersion='2.0.0' # System OS System="$(uname -s)" diff --git a/lua/configs/lsp.lua b/lua/configs/lsp.lua deleted file mode 100644 index 312798e..0000000 --- a/lua/configs/lsp.lua +++ /dev/null @@ -1,102 +0,0 @@ --- taken from https://github.com/neovim/nvim-lspconfig#keybindings-and-completion --- changed servers and ctermbg=237 --- added buf_set_keymap('n', 'ga', 'lua vim.lsp.buf.code_action()', opts) -local nvim_lsp = require('lspconfig') - --- Snippets support -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - --- Signature help -require('lsp_signature').on_attach() - --- Vscode-like pictograms on completion -require('lspkind').init({ - with_text = true, - symbol_map = { - Text = '', - Method = 'ƒ', - Function = '', - Constructor = '', - Variable = '', - Class = '', - Interface = 'ﰮ', - Module = '', - Property = '', - Unit = '', - Value = '', - Enum = '了', - Keyword = '', - Snippet = '﬌', - Color = '', - File = '', - Folder = '', - EnumMember = '', - Constant = '', - Struct = '' - }, -}) - -local on_attach = function(client, bufnr) - function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - -- Mappings. - opts = { noremap=true, silent=true } - buf_set_keymap('n', 'ga', 'lua vim.lsp.buf.code_action()', opts) - 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', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', 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', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - -- Set some keybinds conditional on server capabilities - if client.resolved_capabilities.document_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) - elseif client.resolved_capabilities.document_range_formatting then - buf_set_keymap("n", "f", "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 ctermbg=237 guibg=LightYellow - hi LspReferenceText ctermbg=237 guibg=LightYellow - hi LspReferenceWrite ctermbg=237 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 - ---[[-----------------]]-- --- LSP Setup -- ---]]-----------------[[-- --- https://github.com/kabouzeid/nvim-lspinstall#advanced-configuration-recommended -local function setup_servers() - -- Provide the missing :LspInstall - require('lspinstall').setup() - local servers = require('lspinstall').installed_servers() - for _, server in pairs(servers) do - nvim_lsp[server].setup{} - end -end - -setup_servers() - --- Automatically reload after `:LspInstall ` so we don't have to restart neovim -require('lspinstall').post_install_hook = function () - setup_servers() -- reload installed servers - vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server -end diff --git a/lua/configs/nvim-colorizer.lua b/lua/configs/nvim-colorizer.lua deleted file mode 100644 index 8f5e944..0000000 --- a/lua/configs/nvim-colorizer.lua +++ /dev/null @@ -1,6 +0,0 @@ --- https://github.com/norcalli/nvim-colorizer.lua#customization -require('colorizer').setup { - '*'; -- Highlight all files, but customize some others. - css = { rgb_fn = true; }; -- Enable parsing rgb(...) functions in css. - html = { names = false; } -- Disable parsing "names" like Blue or Gray -} diff --git a/lua/configs/nvim-compe.lua b/lua/configs/nvim-compe.lua deleted file mode 100644 index ae0af80..0000000 --- a/lua/configs/nvim-compe.lua +++ /dev/null @@ -1,29 +0,0 @@ ---- nvim-compe configuration --- https://github.com/hrsh7th/nvim-compe#lua-config -require('compe').setup { - enabled = true; - autocomplete = true; - debug = false; - min_length = 2; - preselect = 'enable'; - throttle_time = 80; - source_timeout = 200; - incomplete_delay = 400; - max_abbr_width = 100; - max_kind_width = 100; - max_menu_width = 100; - 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; - }; -} diff --git a/lua/configs/nvim-gitsigns.lua b/lua/configs/nvim-gitsigns.lua deleted file mode 100644 index 5b17553..0000000 --- a/lua/configs/nvim-gitsigns.lua +++ /dev/null @@ -1,38 +0,0 @@ -require('gitsigns').setup { - signs = { - add = {hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, - change = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - topdelete = {hl = 'GitSignsDelete', text = '‾', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - }, - numhl = false, - linehl = false, - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - - ['n ]c'] = { expr = true, "&diff ? ']c' : 'lua require\"gitsigns\".next_hunk()'"}, - ['n [c'] = { expr = true, "&diff ? '[c' : 'lua require\"gitsigns\".prev_hunk()'"}, - - ['n gS'] = 'lua require"gitsigns".stage_hunk()', - ['n gu'] = 'lua require"gitsigns".undo_stage_hunk()', - ['n gr'] = 'lua require"gitsigns".reset_hunk()', - ['n gR'] = 'lua require"gitsigns".reset_buffer()', - ['n gh'] = 'lua require"gitsigns".preview_hunk()', - ['n gb'] = 'lua require"gitsigns".blame_line()', - - -- Text objects - ['o ih'] = ':lua require"gitsigns".select_hunk()', - ['x ih'] = ':lua require"gitsigns".select_hunk()' - }, - watch_index = { - interval = 1000 - }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - use_decoration_api = true, - use_internal_diff = true, -- If luajit is present -} diff --git a/lua/configs/nvim-telescope.lua b/lua/configs/nvim-telescope.lua deleted file mode 100644 index 74f8215..0000000 --- a/lua/configs/nvim-telescope.lua +++ /dev/null @@ -1,50 +0,0 @@ --- https://github.com/nvim-telescope/telescope.nvim#telescope-defaults --- Required to close with ESC in insert mode -local actions = require('telescope.actions') -local telescope = require('telescope') - -telescope.setup{ - defaults = { - mappings = { - i = { - [''] = actions.close - } - }, - vimgrep_arguments = { - 'rg', - '--pretty', - '--with-filename', - '--column', - '--smart-case' - }, - prompt_position = "bottom", - prompt_prefix = ">", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "horizontal", - layout_defaults = { - -- TODO add builtin options. - }, - file_sorter = require'telescope.sorters'.get_fuzzy_file, - file_ignore_patterns = {}, - generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, - shorten_path = true, - winblend = 0, - width = 0.75, - preview_cutoff = 80, - results_height = 1, - results_width = 0.8, - border = {}, - borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰'}, - color_devicons = true, - use_less = true, - set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil, - file_previewer = require'telescope.previewers'.vim_buffer_cat.new, - grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, - qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, - - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker - } -} diff --git a/lua/configs/nvim-toggleterm.lua b/lua/configs/nvim-toggleterm.lua deleted file mode 100644 index a03ff13..0000000 --- a/lua/configs/nvim-toggleterm.lua +++ /dev/null @@ -1,9 +0,0 @@ -require('toggleterm').setup{ - size = 10, - open_mapping = [[]], - shade_filetypes = {}, - shade_terminals = true, - start_in_insert = true, - persist_size = true, - direction = 'horizontal', -} diff --git a/lua/configs/statusline.lua b/lua/configs/statusline.lua deleted file mode 100644 index 6a213b3..0000000 --- a/lua/configs/statusline.lua +++ /dev/null @@ -1,203 +0,0 @@ --- Extracted from https://github.com/glepnir/galaxyline.nvim/blob/main/example/eviline.lua --- Credits goes to its author (glepnir) :) -local gl = require('galaxyline') -local colors = require('galaxyline.theme').default -local condition = require('galaxyline.condition') -local gls = gl.section - -gl.short_line_list = {'NvimTree','vista','dbui','packer'} - -gls.left[1] = { - RainbowRed = { - provider = function() return '▊ ' end, - highlight = {colors.blue,colors.bg} - }, -} -gls.left[2] = { - ViMode = { - provider = function() - -- auto change color according the vim mode - local mode_color = { - n = colors.red, i = colors.green, v = colors.blue, - [''] = colors.blue, V = colors.blue, - c = colors.magenta, no = colors.red, s = colors.orange, - S = colors.orange, [''] = colors.orange, - ic = colors.yellow, R = colors.violet, Rv = colors.violet, - cv = colors.red, ce = colors.red, r = colors.cyan, - rm = colors.cyan, ['r?'] = colors.cyan, - ['!'] = colors.red, t = colors.red - } - vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color[vim.fn.mode()]) - return ' ' - end, - highlight = {colors.red,colors.bg,'bold'}, - }, -} -gls.left[3] = { - FileSize = { - provider = 'FileSize', - condition = condition.buffer_not_empty, - highlight = {colors.fg,colors.bg} - } -} -gls.left[4] ={ - FileIcon = { - provider = 'FileIcon', - condition = condition.buffer_not_empty, - highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.bg}, - }, -} -gls.left[5] = { - FileName = { - provider = 'FileName', - condition = condition.buffer_not_empty, - highlight = {colors.magenta,colors.bg,'bold'} - } -} -gls.left[6] = { - LineInfo = { - provider = 'LineColumn', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.fg,colors.bg}, - }, -} -gls.left[7] = { - PerCent = { - provider = 'LinePercent', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.fg,colors.bg,'bold'}, - } -} -gls.left[8] = { - DiagnosticError = { - provider = 'DiagnosticError', - icon = '  ', - highlight = {colors.red,colors.bg} - } -} -gls.left[9] = { - DiagnosticWarn = { - provider = 'DiagnosticWarn', - icon = '  ', - highlight = {colors.yellow,colors.bg}, - } -} -gls.left[10] = { - DiagnosticHint = { - provider = 'DiagnosticHint', - icon = '  ', - highlight = {colors.cyan,colors.bg}, - } -} -gls.left[11] = { - DiagnosticInfo = { - provider = 'DiagnosticInfo', - icon = '  ', - highlight = {colors.blue,colors.bg}, - } -} - -gls.mid[1] = { - ShowLspClient = { - provider = 'GetLspClient', - condition = function () - local tbl = {['dashboard'] = true,['']=true} - if tbl[vim.bo.filetype] then - return false - end - return true - end, - icon = ' LSP: ', - highlight = {colors.cyan,colors.bg,'bold'} - } -} - -gls.right[1] = { - FileEncode = { - provider = 'FileEncode', - condition = condition.hide_in_width, - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.green,colors.bg,'bold'} - } -} -gls.right[2] = { - FileFormat = { - provider = 'FileFormat', - condition = condition.hide_in_width, - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.green,colors.bg,'bold'} - } -} -gls.right[3] = { - GitIcon = { - provider = function() return '  ' end, - condition = condition.check_git_workspace, - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.violet,colors.bg,'bold'}, - } -} -gls.right[4] = { - GitBranch = { - provider = 'GitBranch', - condition = condition.check_git_workspace, - highlight = {colors.violet,colors.bg,'bold'}, - } -} -gls.right[5] = { - DiffAdd = { - provider = 'DiffAdd', - condition = condition.hide_in_width, - icon = '  ', - highlight = {colors.green,colors.bg}, - } -} -gls.right[6] = { - DiffModified = { - provider = 'DiffModified', - condition = condition.hide_in_width, - icon = ' 柳', - highlight = {colors.orange,colors.bg}, - } -} -gls.right[7] = { - DiffRemove = { - provider = 'DiffRemove', - condition = condition.hide_in_width, - icon = '  ', - highlight = {colors.red,colors.bg}, - } -} -gls.right[8] = { - RainbowBlue = { - provider = function() return ' ▊' end, - highlight = {colors.blue,colors.bg} - }, -} - -gls.short_line_left[1] = { - BufferType = { - provider = 'FileTypeName', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.blue,colors.bg,'bold'} - } -} -gls.short_line_left[2] = { - SFileName = { - provider = 'SFileName', - condition = condition.buffer_not_empty, - highlight = {colors.fg,colors.bg,'bold'} - } -} - -gls.short_line_right[1] = { - BufferIcon = { - provider= 'BufferIcon', - highlight = {colors.fg,colors.bg} - } -} diff --git a/lua/doom/config/load_plugins.lua b/lua/doom/config/load_plugins.lua new file mode 100644 index 0000000..d11fc92 --- /dev/null +++ b/lua/doom/config/load_plugins.lua @@ -0,0 +1,48 @@ +-- /home/user/.config/doom-nvim/lua/plugins/init.lua +-- /home/user/.config/doom-nvim/lua/plugins/configs/*.lua +-- Don't load plugin config if the plugin is disabled to improve performance +if fn['doom#functions#checkplugin']('pears.nvim') == 1 then + require('plugins.configs.nvim-pears') +end +if fn['doom#functions#checkplugin']('nvim-lspconfig') == 1 then + require('plugins.configs.lsp') +end +if fn['doom#functions#checkplugin']('nvim-colorizer.lua') == 1 then + require('plugins.configs.nvim-colorizer') +end +if fn['doom#functions#checkplugin']('nvim-compe') == 1 then + require('plugins.configs.nvim-compe') +end +if fn['doom#functions#checkplugin']('focus.nvim') == 1 then + require('plugins.configs.nvim-focus') +end +if fn['doom#functions#checkplugin']('telescope.nvim') == 1 then + require('plugins.configs.nvim-telescope') +end +if fn['doom#functions#checkplugin']('nvim-toggleterm.lua') == 1 then + require('plugins.configs.nvim-toggleterm') +end +if fn['doom#functions#checkplugin']('nvim-tree.lua') == 1 then + require('plugins.configs.nvim-tree') +end +if fn['doom#functions#checkplugin']('galaxyline.nvim') == 1 then + require('plugins.configs.statusline') +end +if fn['doom#functions#checkplugin']('nvim-treesitter') == 1 then + require('plugins.configs.tree-sitter') +end +if fn['doom#functions#checkplugin']('gitsigns.nvim') == 1 then + require('plugins.configs.nvim-gitsigns') +end +if fn['doom#functions#checkplugin']('which-key.nvim') == 1 then + require('plugins.configs.which-key') +end +if fn['doom#functions#checkplugin']('symbols-outline.nvim') == 1 then + require('plugins.configs.symbols') +end +if fn['doom#functions#checkplugin']('auto-session') == 1 then + require('plugins.configs.auto-session') +end +if fn['doom#functions#checkplugin']('format.nvim') == 1 then + require('plugins.configs.nvim-format') +end diff --git a/lua/doom/config/main.lua b/lua/doom/config/main.lua new file mode 100644 index 0000000..880fe7e --- /dev/null +++ b/lua/doom/config/main.lua @@ -0,0 +1,29 @@ +---[[---------------------------------------]]--- +-- main.vim - Core of Doom Nvim -- +-- Author: NTBBloodbath -- +-- License: MIT -- +---[[---------------------------------------]]--- +-- If packer.nvim is not installed then install it +local packer_install_path = fn.stdpath('data') + .. '/site/pack/packer/start/packer.nvim' +if fn.empty(fn.glob(packer_install_path)) > 0 then + execute( + 'silent !git clone https://github.com/wbthomason/packer.nvim ' + .. packer_install_path + ) + execute('packadd packer.nvim') +end + +-- Set some configs on load +if fn.has('vim_starting') == 1 then + -- Set encoding + opt('o', 'encoding', 'utf-8') + -- Required to use some colorschemes and improve colors + opt('o', 'termguicolors', true) +end + +-- Start Doom and run packer.nvim +fn['doom#begin']() +require('plugins') +require('doom.config.load_plugins') +fn['doom#end']() diff --git a/lua/doom/config/ui.lua b/lua/doom/config/ui.lua new file mode 100644 index 0000000..40eebf9 --- /dev/null +++ b/lua/doom/config/ui.lua @@ -0,0 +1,32 @@ +---[[---------------------------------------]]--- +-- ui.lua - Doom Nvim UI settings -- +-- Author: NTBBloodbath -- +-- License: MIT -- +---[[---------------------------------------]]--- +-- If no colorscheme was established then fallback to defauls +if not is_empty(g.doom_colorscheme) then + try({ + function() + execute('set background=' .. g.doom_colorscheme_bg) + execute('colorscheme ' .. g.doom_colorscheme) + end, + catch({ + function(_) + fn['doom#logging#message']('!', 'Colorscheme not found', 1) + execute('colorscheme ' .. g.doom_colorscheme) + end, + }), + }) +else + fn['doom#logging#message']('!', 'Forced default Doom colorscheme', 1) + execute('colorscheme doom-one') +end + +-- If guicolors are enabled +if g.doom_enable_guicolors == 1 then + if fn.exists('+termguicolors') then + opt('o', 'termguicolors', true) + elseif fn.exists('+guicolors') then + opt('o', 'guicolors', true) + end +end diff --git a/lua/doom/health.lua b/lua/doom/health.lua index 0eb6855..0618c30 100644 --- a/lua/doom/health.lua +++ b/lua/doom/health.lua @@ -1,75 +1,70 @@ ----[[----------]]--- --- Wrappers -- ----]]----------[[--- -local fn = vim.fn - -- Health status local health_start = fn['health#report_start'] -local health_ok = fn['health#report_ok'] +local health_ok = fn['health#report_ok'] local health_error = fn['health#report_error'] -local health_warn = fn['health#report_warn'] +local health_warn = fn['health#report_warn'] local M = {} -- Installation health local function install_health() - health_start('Installation') + health_start('Installation') - ---[[-----------------------]]--- - -- REQUIRED DEPENDENCIES -- - ---]]-----------------------[[--- - -- Check Git - if fn.executable('git') == 0 then - health_error('`git` executable not found.', { - 'Install it with your package manager.', - 'Check that your `$PATH` is set correctly.' - }) - else - health_ok('`git` executable found.') - end + ---[[-----------------------]]--- + -- REQUIRED DEPENDENCIES -- + ---]]-----------------------[[--- + -- Check Git + if fn.executable('git') == 0 then + health_error('`git` executable not found.', { + 'Install it with your package manager.', + 'Check that your `$PATH` is set correctly.', + }) + else + health_ok('`git` executable found.') + end - ---[[-----------------------]]--- - -- OPTIONAL DEPENDENCIES -- - ---]]-----------------------[[--- - -- Ripgrep and fd - if fn.executable('rg') == 0 then - health_warn('`rg` executable not found.', { - 'Required to improve file indexing performance for some commands', - 'Ignore this message if you have `fd` installed.' - }) - else - health_ok('`rg` executable found.') - end - if fn.executable('fd') == 0 then - health_warn('`fd` executable not found.', { - 'Required to improve file indexing performance for some commands', - 'Ignore this message if you have `rg` installed.' - }) - else - health_ok('`fd` executable found.') - end + ---[[-----------------------]]--- + -- OPTIONAL DEPENDENCIES -- + ---]]-----------------------[[--- + -- Ripgrep and fd + if fn.executable('rg') == 0 then + health_warn('`rg` executable not found.', { + 'Required to improve file indexing performance for some commands', + 'Ignore this message if you have `fd` installed.', + }) + else + health_ok('`rg` executable found.') + end + if fn.executable('fd') == 0 then + health_warn('`fd` executable not found.', { + 'Required to improve file indexing performance for some commands', + 'Ignore this message if you have `rg` installed.', + }) + else + health_ok('`fd` executable found.') + end - -- Check NodeJS and NPM - if fn.executable('node') == 0 then - health_warn('`node` executable not found.', { - 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.' - }) - else - health_ok('`node` executable found.') - end - if fn.executable('npm') == 0 then - health_warn('`npm` executable not found.', { - 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.', - 'If node is installed but npm is not, you should need to install it with your package manager' - }) - else - health_ok('`npm` executable found.') - end + -- Check NodeJS and NPM + if fn.executable('node') == 0 then + health_warn('`node` executable not found.', { + 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.', + }) + else + health_ok('`node` executable found.') + end + if fn.executable('npm') == 0 then + health_warn('`npm` executable not found.', { + 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.', + 'If node is installed but npm is not, you should need to install it with your package manager', + }) + else + health_ok('`npm` executable found.') + end end function M.checkhealth() - -- Installation checks - install_health() + -- Installation checks + install_health() end return M diff --git a/lua/doom/keybindings.lua b/lua/doom/keybindings.lua new file mode 100644 index 0000000..d9beae9 --- /dev/null +++ b/lua/doom/keybindings.lua @@ -0,0 +1,311 @@ +local wk = require('which-key') + +-- Define leader key to space +-- and call leader mapper +map('n', '', '') +api.nvim_set_var('mapleader', ' ') + +------------------------------------------------- + +---[[-------------------------------]]--- +-- Custom Key Mappings -- +-- -- +-- b = Buffer Menu -- +-- f = File Menu -- +-- g = Git Menu -- +-- p = Plugin Menu -- +-- r = Runner Menu -- +-- s = Session Menu -- +-- t = Toggle Menu -- +-- w = Window Menu -- +-- -- +-- TAB = Cycle buffers -- +-- ESC = Search highlight off -- +-- F2 = Toggle Tagbar -- +-- F3 = Toggle Tree Explorer -- +-- F4 = Toggle Terminal -- +-- F5 = Toggle Minimap -- +-- F6 = Toggle Zen Mode -- +-- F7 = Run restclient -- +---]]-------------------------------[[--- + +------------------------------------------------- + +-- Additional options for mappings +local opts = { silent = true } + +---[[-----------------]]--- +-- LSP Keybindings -- +---]]-----------------[[--- +-- If the LSP group is not disabled or the nvim-compe plugin is not disabled +-- then set its mappings. +if + not has_value(g.doom_disabled_modules, 'lsp') + and (not has_value(g.doom_disabled_plugins, 'compe')) +then + -- https://github.com/hrsh7th/nvim-compe#mappings + map('i', ' ', fn['compe#complete'](), opts) + map('i', ' ', fn['compe#confirm'](''), opts) + map('i', ' ', fn['compe#close'](''), opts) + map( + 'i', + ' ', + fn['compe#scroll']({ delta = '+4' }), + opts + ) + map( + 'i', + ' ', + fn['compe#scroll']({ delta = '-4' }), + opts + ) +end + +-- TAB to cycle buffers too, why not? +map('n', '', ':bnext', opts) +map('n', '', ':bprevious', opts) + +-- ESC to turn off search highlighting +map('n', '', ':noh', opts) + +--- F keybindings +if not has_value(g.doom_disabled_plugins, 'tagbar') then + map('n', '', ':SymbolsOutline') +end +if not has_value(g.doom_disabled_plugins, 'tree') then + map('n', '', ':NvimTreeToggle') +end +if not has_value(g.doom_disabled_plugins, 'terminal') then + map('n', '', ':ToggleTerm') +end +if not has_value(g.doom_disabled_plugins, 'minimap') then + map('n', '', ':MinimapToggle') +end +if not has_value(g.doom_disabled_plugins, 'zen') then + map('n', '', ':TZAtaraxis') +end +if + not has_value(g.doom_disabled_modules, 'web') + and (not has_value(g.doom_disabled_plugins, 'restclient')) +then + map('n', '', ':DotHttp') +end + +---[[-----------------]]--- +-- Disable keys -- +---]]-----------------[[--- +-- Disable accidentally pressing ctrl-z and suspending +map('n', '', '') + +-- Disable ex mode +map('n', 'Q', '') + +-- Disable recording +map('n', 'q', '') + +-- Fast exit from Doom Nvim and write messages to logs +map('n', 'ZZ', ':call doom#functions#quit_doom(1,1)') + +---[[-----------------]]--- +-- Leader keys -- +---]]-----------------[[--- +-- Buffers +wk.register({ + [''] = { + b = { + name = '+buffer', + ['1'] = { ':BufferGoto 1', 'Buffer 1' }, + ['2'] = { ':BufferGoto 2', 'Buffer 2' }, + ['3'] = { ':BufferGoto 3', 'Buffer 3' }, + ['4'] = { ':BufferGoto 4', 'Buffer 4' }, + ['5'] = { ':BufferGoto 5', 'Buffer 5' }, + ['6'] = { ':BufferGoto 6', 'Buffer 6' }, + ['7'] = { ':BufferGoto 7', 'Buffer 7' }, + ['8'] = { ':BufferGoto 8', 'Buffer 8' }, + ['9'] = { ':BufferLast', 'Last buffer' }, + c = { ':BufferClose', 'Close buffer' }, + f = { ':FormatWrite', 'Format buffer' }, + n = { ':BufferNext', 'Next buffer' }, + P = { ':BufferPick', 'Pick buffer' }, + p = { ':BufferPrevious', 'Previous buffer' }, + }, + }, +}) + +-- Plugins +wk.register({ + [''] = { + p = { + name = '+plugins', + c = { ':PackerClean', 'Clean disabled or unused plugins' }, + i = { ':PackerInstall', 'Install missing plugins' }, + p = { + ':PackerProfile', + 'Profile the time taken loading your plugins', + }, + s = { + ':PackerSync', + 'Performs PackerClean and then PackerUpdate', + }, + u = { ':PackerUpdate', 'Update your plugins' }, + }, + }, +}) + +-- Order +wk.register({ + [''] = { + o = { + name = '+order', + d = { ':BufferOrderByDirectory', 'Sort by directory' }, + l = { ':BufferOrderByLanguage', 'Sort by language' }, + n = { ':BufferMoveNext', 'Re-order buffer to next' }, + p = { ':BufferMovePrevious', 'Re-order buffer to previous' }, + }, + }, +}) + +-- File +wk.register({ + [''] = { + f = { + name = '+file', + c = { ':e $MYVIMRC', 'Edit Neovim configuration' }, + n = { ':new', 'Create a new unnamed buffer' }, + f = { ':Telescope find_files', 'Find files' }, + b = { ':Telescope marks', 'Bookmarks' }, + W = { ':Telescope live_grep', 'Find word' }, + t = { ':Telescope help_tags', 'Help tags' }, + h = { ':Telescope oldfiles', 'Recently opened files' }, + w = { ':SudaWrite', 'Write file with sudo permissions' }, + r = { ':SudaRead', 'Re-open file with sudo permissions' }, + }, + }, +}) + +-- Window +wk.register({ + [''] = { + w = { + name = '+window', + C = { ':only', 'Close all other windows' }, + c = { ':close', 'Close current window' }, + h = { ':split', 'Split horizontally' }, + v = { 'vsplit', 'Split vertically' }, + }, + }, +}) + +-- Sessions +wk.register({ + [''] = { + s = { + name = '+sessions', + s = { ':SaveSession', 'Save current session' }, + r = { ':RestoreSession', 'Restore previously saved session' }, + l = { + ':Telescope session-lens search_session', + 'Session switcher', + }, + }, + }, +}) + +-- Doom Menu +wk.register({ + [''] = { + d = { + name = '+doom', + c = { + ':e ~/.config/doom-nvim/doomrc', + 'Edit your Doom Nvim configuration', + }, + d = { ':help doom_nvim', 'Open Doom Nvim documentation' }, + u = { ':DoomUpdate', 'CHeck Doom Nvim udpates' }, + r = { + ':call doom#functions#createReport()', + 'Create crash report', + }, + }, + }, +}) + +-- Toggler +wk.register({ + [''] = { + t = { + name = '+toggle', + s = { ':Dashboard', 'Open start screen' }, + c = { ':DashboardChangeColorscheme', 'Change colorscheme' }, + e = { ':NvimTreeToggle', 'Toggle Tree Explorer' }, + m = { ':MinimapToggle', 'Toggle Minimap' }, + S = { ':SymbolsOutline', 'Toggle Symbols view' }, + t = { ':ToggleTerm', 'Toggle terminal' }, + }, + }, +}) + +-- If web is enabled and restclient is enabled too +if + not has_value(g.doom_disabled_modules, 'web') + and (not has_value(g.doom_disabled_plugins, 'restclient')) +then + wk.register({ + [''] = { + r = { + name = '+runner', + r = { + ':DotHttp', + 'Run restclient on the line that the cursor is currently on', + }, + }, + }, + }) +end + +-- If LSP is enabled +if + not has_value(g.doom_disabled_modules, 'lsp') + and (not has_value(g.doom_disabled_plugins, 'compe')) +then + wk.register({ + [''] = { + l = { + name = '+lsp', + d = { + 'lua vim.lsp.buf.type_definition()', + 'Show type definition', + }, + l = { + 'lua vim.lsp.diagnostic.show_line_diagnostics()', + 'Show line diagnostics', + }, + L = { + 'lua vim.lsp.diagnostic.set_loclist()', + 'Diagnostics into location list', + }, + }, + }, + }) +end + +-- If Git is enabled +if not has_value(g.doom_disabled_modules, 'git') then + wk.register({ + [''] = { + g = { + name = '+git', + o = { ':LazyGit', 'Open LazyGit' }, + P = { ':TermExec cmd="git pull"', 'Pull' }, + p = { ':TermExec cmd="git push"', 'Push' }, + S = { 'Stage hunk' }, + s = { ':TermExec cmd="git status"', 'Status' }, + u = { 'Undo stage hunk' }, + R = { 'Reset buffer' }, + r = { 'Reset hunk' }, + h = { 'Preview hunk' }, + b = { 'Blame line' }, + }, + }, + }) +end diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua new file mode 100644 index 0000000..18203c4 --- /dev/null +++ b/lua/doom/utils/init.lua @@ -0,0 +1,97 @@ +-------------------- HELPERS -------------------- +api, cmd, fn = vim.api, vim.cmd, vim.fn +keymap, execute, g = api.nvim_set_keymap, api.nvim_command, vim.g +scopes = { o = vim.o, b = vim.bo, w = vim.wo } + +--- Require packer so we can use `packer.use` function in `custom_plugins` function +local packer = require('packer') + +-- Mappings wrapper, extracted from +-- https://github.com/ojroques/dotfiles/blob/master/nvim/init.lua#L8-L12 +function map(mode, lhs, rhs, opts) + local options = { noremap = true } + if opts then + default_options = vim.tbl_extend('force', options, opts) + end + keymap(mode, lhs, rhs, options) +end + +-- Options wrapper, extracted from +-- https://github.com/ojroques/dotfiles/blob/master/nvim/init.lua#L14-L17 +function opt(scope, key, value) + scopes[scope][key] = value + if scope ~= 'o' then + scopes['o'][key] = value + end +end + +-- Check if string is empty or if it's nil +function is_empty(str) + return str == '' or str == nil +end + +-- Search if a table have the value we are looking for, +-- useful for plugins management +function has_value(tabl, val) + for _, value in ipairs(tabl) do + if value == val then + return true + end + end + + return false +end + +-- try/catch statements, see +-- https://gist.github.com/cwarden/1207556 +function catch(err) + return err[1] +end + +function try(block) + status, result = pcall(block[1]) + if not status then + block[2](result) + end + return result +end + +-- A better and less primitive implementation of custom plugins in Doom Nvim +function custom_plugins(plugins) + -- if a plugin have some configs like enabled or requires then we will + -- store them in that table + local plugin_with_configs = {} + + if type(plugins) ~= 'string' then + for idx, val in pairs(plugins) do + -- Create the correct plugin structure to packer + -- use { + -- url, + -- enabled, + -- requires + -- } + if idx == 'repo' then + table.insert(plugin_with_configs, val) + end + + if idx == 'enabled' then + if val == 1 then + plugin_with_configs['enabled'] = true + else + plugin_with_configs['enabled'] = false + end + end + + if idx == 'requires' then + plugin_with_configs['requires'] = val + end + end + -- Send the configured plugin to packer + packer.use(plugin_with_configs) + else + -- Send the simple plugins, e.g. those who have not declared with configs + -- 'user/repo' ← simple plugin + -- { 'user/repo', opts } ← configured plugin + packer.use(plugins) + end +end diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index c23281a..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,373 +0,0 @@ --- Manage vim global variables -local g = vim.g -local nvim_set_var = vim.api.nvim_set_var - --- Useful function to see if the Vim variable have the value we are looking for -function has_value(tabl, val) - for _, value in ipairs(tabl) do - if value == val then - return true - end - end - - return false -end - ------ Plugins modules --- Essentials, ! cannot be disabled (Plugin manager, vimpeccable and languages) --- UI Related, / can be disabled (All look-and-feel plugins) --- Fuzzy Search (fuzzy), + can be disabled (Fuzzy search & more) --- Git Integration (git), + can be disabled (Some git plugins, including LazyGit) --- Completion (lsp), + can be disabled (Built-in LSP configurations) --- File-related (files), + can be disabled (EditorConfig, formatting, Tree-sitter, etc) --- Web-related (web), + can be disabled (Colorizer, emmet, rest client) --- --- Legend: --- ! : The group and its plugins cannot be disabled --- / : The group cannot be disabled but some of its plugins can be --- + : The group and its plugins can be disabled --- --- NOTES: --- 1. You can disable an entire group or just some or their plugins based on --- the legend, please refer to our documentation to learn how to do it. --- 2. The UI dashboard depends on the Fuzzy Search group for --- providing some features, but if you do not want to use them, --- you can safely disable the Fuzzy Search group. --- 3. We do not provide other LSP integration like coc.nvim, --- please refer to our FAQ to see why. - ---- Set disabled plugins modules and plugins -local disabled_plugins = {} ---- Disabled modules -local disabled_fuzzy = has_value(g.doom_disabled_modules, 'fuzzy') -local disabled_git = has_value(g.doom_disabled_modules, 'git') -local disabled_completion = has_value(g.doom_disabled_modules, 'lsp') -local disabled_files = has_value(g.doom_disabled_modules, 'files') -local disabled_web = has_value(g.doom_disabled_modules, 'web') - -local packer = require('packer') -return packer.startup(function() - -----[[------------]]----- - --- Essentials --- - -----]]------------[[----- - -- Plugins manager - use 'wbthomason/packer.nvim' - -- Auxiliar functions for using Lua in Neovim - use 'svermeulen/vimpeccable' - -- Languages support - use 'sheerun/vim-polyglot' - - -----[[------------]]----- - --- UI Related --- - -----]]------------[[----- - -- Fancy start screen - -- cannot be disabled - use { - 'glepnir/dashboard-nvim', - disabled = false - } - -- Colorschemes - -- cannot be disabled at the moment - use { - 'sainnhe/sonokai', - 'sainnhe/edge', - 'sainnhe/everforest', - 'wadackel/vim-dogrun', - 'joshdick/onedark.vim', - 'ajmwagar/vim-deus' - } - -- File tree - local disabled_tree = has_value(g.doom_disabled_plugins, 'tree') - if disabled_tree then - table.insert(disabled_plugins, 'tree') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'kyazdani42/nvim-tree.lua', - requires = { 'kyazdani42/nvim-web-devicons' }, - disabled = disabled_tree - } - -- Statusline - -- can be disabled to use your own statusline - local disabled_statusline = has_value(g.doom_disabled_plugins, 'statusline') - if disabled_statusline then - table.insert(disabled_plugins, 'statusline') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'glepnir/galaxyline.nvim', - disabled = disabled_statusline - } - -- Tabline - -- can be disabled to use your own tabline - local disabled_tabline = has_value(g.doom_disabled_plugins, 'tabline') - if disabled_tabline then - table.insert(disabled_plugins, 'tabline') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'romgrk/barbar.nvim', - disabled = disabled_tabline - } - -- Better splits - -- NOTE: we are using this specific branch because the main still does not have - -- the ignore filetypes feature, thanks to its owner per adding it <3 - local disabled_focus = has_value(g.doom_disabled_plugins, 'focus') - if disabled_focus then - table.insert(disabled_plugins, 'focus') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'beauwilliams/focus.nvim', - branch = 'cust_filetypes', - disabled = disabled_focus - } - -- Better terminal - -- can be disabled to use your own terminal plugin - local disabled_terminal = has_value(g.doom_disabled_plugins, 'terminal') - if disabled_terminal then - table.insert(disabled_plugins, 'terminal') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'akinsho/nvim-toggleterm.lua', - disabled = disabled_terminal - } - -- Viewer & finder for LSP symbols and tags - local disabled_tagbar = has_value(g.doom_disabled_plugins, 'tagbar') - if disabled_tagbar then - table.insert(disabled_plugins, 'tagbar') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'liuchengxu/vista.vim', - disabled = disabled_tagbar - } - -- Minimap - -- Depends on wfxr/code-minimap to work! - local disabled_minimap = has_value(g.doom_disabled_plugins, 'minimap') - if disabled_minimap then - table.insert(disabled_plugins, 'minimap') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'wfxr/minimap.vim', - disabled = disabled_minimap - } - -- Keybindings menu like Emacs's guide-key - -- cannot be disabled - use { - 'spinks/vim-leader-guide', - disabled = false - } - -- Distraction free environment - local disabled_goyo = has_value(g.doom_disabled_plugins, 'goyo') - if disabled_goyo then - table.insert(disabled_plugins, 'goyo') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'junegunn/goyo.vim', - disabled = disabled_goyo - } - - -----[[--------------]]----- - --- Fuzzy Search --- - -----]]--------------[[----- - local disabled_telescope = has_value(g.doom_disabled_plugins, 'telescope') - if disabled_fuzzy and (not disabled_telescope) then - table.insert(disabled_plugins, 'telescope') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'nvim-telescope/telescope.nvim', - requires = { - {'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'} - }, - disable = (disabled_fuzzy and true or disabled_telescope) - } - - -----[[-------------]]----- - --- GIT RELATED --- - -----]]-------------[[----- - -- Git gutter better alternative, written in Lua - -- can be disabled to use your own git gutter plugin - local disabled_gitsigns = has_value(g.doom_disabled_plugins, 'gitsigns') - if disabled_git and (not disabled_gitsigns) then - table.insert(disabled_plugins, 'gitsigns') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'lewis6991/gitsigns.nvim', - disable = (disabled_git and true or disabled_gitsigns), - } - -- LazyGit integration - local disabled_lazygit = has_value(g.doom_disabled_plugins, 'lazygit') - if disabled_git and (not disabled_lazygit) then - table.insert(disabled_plugins, 'lazygit') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'kdheepak/lazygit.nvim', - requires = { 'nvim-lua/plenary.nvim' }, - disable = (disabled_git and true or disabled_lazygit) - } - - -----[[------------]]----- - --- Completion --- - -----]]------------[[----- - -- Built-in LSP Config - -- NOTE: It should not be disabled if you are going to use LSP! - local disabled_lspconfig = has_value(g.doom_disabled_plugins, 'lspconfig') - if disabled_lsp and (not disabled_lspconfig) then - table.insert(disabled_plugins, 'lspconfig') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'neovim/nvim-lspconfig', - disable = (disabled_completion and true or disabled_lspconfig) - } - -- Completion plugin - -- can be disabled to use your own completion plugin - local disabled_compe = has_value(g.doom_disabled_plugins, 'compe') - if disabled_lsp and (not disabled_compe) then - table.insert(disabled_plugins, 'compe') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'hrsh7th/nvim-compe', - requires = { - {'ray-x/lsp_signature.nvim'}, {'onsails/lspkind-nvim'}, - {'norcalli/snippets.nvim'} - }, - disable = (disabled_completion and true or disabled_compe) - } - -- provides the missing `:LspInstall` for `nvim-lspconfig`. - local disabled_lspinstall = has_value(g.doom_disabled_plugins, 'lspinstall') - if disabled_lsp and (not disabled_lspinstall) then - table.insert(disabled_plugins, 'lspinstall') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use 'kabouzeid/nvim-lspinstall' - - -----[[--------------]]----- - --- File Related --- - -----]]--------------[[----- - -- Write / Read files without permissions (e.g. /etc files) without having - -- to use `sudo nvim /path/to/file` - local disabled_suda = has_value(g.doom_disabled_plugins, 'suda') - if disabled_files and (not disabled_suda) then - table.insert(disabled_plugins, 'suda') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'lambdalisue/suda.vim', - disable = (disabled_files and true or disabled_suda) - } - -- File formatting - -- can be disabled to use your own file formatter - local disabled_neoformat = has_value(g.doom_disabled_plugins, 'neoformat') - if disabled_files and (not disabled_neoformat) then - table.insert(disabled_plugins, 'neoformat') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'sbdchd/neoformat', - disable = (disabled_files and true or disabled_neoformat) - } - -- Autopairs - -- can be disabled to use your own autopairs - local disabled_autopairs = has_value(g.doom_disabled_plugins, 'autopairs') - if disabled_files and (not disabled_autopairs) then - table.insert(disabled_plugins, 'autopairs') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'windwp/nvim-autopairs', - disable = (disabled_files and true or disabled_autopairs) - } - -- Indent Lines - local disabled_indent_lines = has_value(g.doom_disabled_plugins, 'indentlines') - if disabled_files and (not disabled_indent_lines) then - table.insert(disabled_plugins, 'indentlines') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'Yggdroot/indentLine', - disable = (disabled_files and true or disabled_indent_lines) - } - -- EditorConfig support - local disabled_editorconfig = has_value(g.doom_disabled_plugins, 'editorconfig') - if disabled_files and (not disabled_editorconfig) then - table.insert(disabled_plugins, 'editorconfig') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'editorconfig/editorconfig-vim', - disable = (disabled_files and true or disabled_editorconfig) - } - -- Tree-Sitter - local disabled_treesitter = has_value(g.doom_disabled_plugins, 'treesitter') - if disabled_files and (not disabled_treesitter) then - table.insert(disabled_plugins, 'treesitter') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - disable = (disabled_files and true or disabled_treesitter) - } - -- Comments - -- can be disabled to use your own comments plugin - local disabled_kommentary = has_value(g.doom_disabled_plugins, 'kommentary') - if disabled_files and (not disabled_kommentary) then - table.insert(disabled_plugins, 'kommentary') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'b3nj5m1n/kommentary', - disable = (disabled_files and true or disabled_kommentary) - } - - -----[[-------------]]----- - --- Web Related --- - -----]]-------------[[----- - -- Fastest colorizer without external dependencies! - local disabled_colorizer = has_value(g.doom_disabled_plugins, 'colorizer') - if disabled_web and (not disabled_colorizer) then - table.insert(disabled_plugins, 'colorizer') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'norcalli/nvim-colorizer.lua', - disable = (disabled_web and true or disabled_colorizer) - } - -- HTTP Client support - -- Depends on bayne/dot-http to work! - local disabled_restclient = has_value(g.doom_disabled_plugins, 'restclient') - if disabled_web and (not disabled_restclient) then - table.insert(disabled_plugins, 'restclient') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'bayne/vim-dot-http', - disable = (disabled_web and true or disabled_restclient) - } - -- Emmet plugin - local disabled_emmet = has_value(g.doom_disabled_plugins, 'emmet') - if disabled_web and (not disabled_emmet) then - table.insert(disabled_plugins, 'emmet') - nvim_set_var('doom_disabled_plugins', disabled_plugins) - end - use { - 'mattn/emmet-vim', - disable = (disabled_web and true or disabled_emmet) - } - -----[[----------------]]----- - --- Custom Plugins --- - -----]]----------------[[----- - -- If there are custom plugins - for _, plugin in ipairs(g.doom_custom_plugins) do - packer.use(plugin) - end -end) diff --git a/lua/plugins/configs/auto-session.lua b/lua/plugins/configs/auto-session.lua new file mode 100644 index 0000000..f68f0fa --- /dev/null +++ b/lua/plugins/configs/auto-session.lua @@ -0,0 +1,10 @@ +require('auto-session').setup({ + -- Sets the log level of the plugin (debug, info, error) + logLevel = 'info', + -- Root dir where sessions will be stored (/home/user/.config/nvim/sessions/) + auto_session_root_dir = fn.stdpath('data') .. '/sessions/', + -- Enables/disables auto save/restore + auto_session_enabled = g.doom_autosave_sessions, + -- Enable keeping track and loading of the last session + auto_session_enable_last_session = g.doom_autoload_last_session, +}) diff --git a/lua/configs/autopairs.lua b/lua/plugins/configs/autopairs.lua similarity index 100% rename from lua/configs/autopairs.lua rename to lua/plugins/configs/autopairs.lua diff --git a/lua/plugins/configs/lsp.lua b/lua/plugins/configs/lsp.lua new file mode 100644 index 0000000..b949547 --- /dev/null +++ b/lua/plugins/configs/lsp.lua @@ -0,0 +1,180 @@ +-- taken from https://github.com/neovim/nvim-lspconfig#keybindings-and-completion +local nvim_lsp = require('lspconfig') + +-- Snippets support +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +-- Signature help +require('lsp_signature').on_attach() + +-- Vscode-like pictograms on completion +require('lspkind').init({ + with_text = true, + symbol_map = { + Text = '', + Method = 'ƒ', + Function = '', + Constructor = '', + Variable = '', + Class = '', + Interface = 'ﰮ', + Module = '', + Property = '', + Unit = '', + Value = '', + Enum = '了', + Keyword = '', + Snippet = '﬌', + Color = '', + File = '', + Folder = '', + EnumMember = '', + Constant = '', + Struct = '', + }, +}) + +local on_attach = function(client, bufnr) + local function buf_set_option(...) + api.nvim_buf_set_option(bufnr, ...) + end + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + -- Mappings. + local opts = { silent = true } + map( + 'n', + 'ga', + 'lua vim.lsp.buf.code_action()', + opts + ) + map( + 'n', + 'gD', + 'lua vim.lsp.buf.declaration()', + opts + ) + map('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + map('n', 'K', 'lua vim.lsp.buf.hover()', opts) + map( + 'n', + 'gi', + 'lua vim.lsp.buf.implementation()', + opts + ) + map( + 'n', + '', + 'lua vim.lsp.buf.signature_help()', + opts + ) + map( + 'n', + 'wa', + 'lua vim.lsp.buf.add_workspace_folder()', + opts + ) + map( + 'n', + 'wr', + 'lua vim.lsp.buf.remove_workspace_folder()', + opts + ) + map( + 'n', + 'wl', + 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', + opts + ) + map( + 'n', + 'D', + 'lua vim.lsp.buf.type_definition()', + opts + ) + map( + 'n', + 'rn', + 'lua vim.lsp.buf.rename()', + opts + ) + map('n', 'gr', 'lua vim.lsp.buf.references()', opts) + map( + 'n', + 'e', + 'lua vim.lsp.diagnostic.show_line_diagnostics()', + opts + ) + map( + 'n', + '[d', + 'lua vim.lsp.diagnostic.goto_prev()', + opts + ) + map( + 'n', + ']d', + 'lua vim.lsp.diagnostic.goto_next()', + opts + ) + map( + 'n', + 'q', + 'lua vim.lsp.diagnostic.set_loclist()', + opts + ) + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + map( + 'n', + 'f', + 'lua vim.lsp.buf.formatting()', + opts + ) + elseif client.resolved_capabilities.document_range_formatting then + map( + 'n', + 'f', + 'lua vim.lsp.buf.range_formatting()', + opts + ) + end + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + api.nvim_exec( + [[ + hi LspReferenceRead ctermbg=237 guibg=LightYellow + hi LspReferenceText ctermbg=237 guibg=LightYellow + hi LspReferenceWrite ctermbg=237 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 + +--[[-----------------]] +-- +-- LSP Setup -- +-- ]]-----------------[[-- +-- https://github.com/kabouzeid/nvim-lspinstall#advanced-configuration-recommended +local function setup_servers() + -- Provide the missing :LspInstall + require('lspinstall').setup() + local servers = require('lspinstall').installed_servers() + for _, server in pairs(servers) do + nvim_lsp[server].setup({}) + end +end + +setup_servers() + +-- Automatically reload after `:LspInstall ` so we don't have to restart neovim +require('lspinstall').post_install_hook = function() + setup_servers() -- reload installed servers + cmd('bufdo e') -- this triggers the FileType autocmd that starts the server +end diff --git a/lua/plugins/configs/nvim-colorizer.lua b/lua/plugins/configs/nvim-colorizer.lua new file mode 100644 index 0000000..803caeb --- /dev/null +++ b/lua/plugins/configs/nvim-colorizer.lua @@ -0,0 +1,6 @@ +-- https://github.com/norcalli/nvim-colorizer.lua#customization +require('colorizer').setup({ + '*', -- Highlight all files, but customize some others. + css = { rgb_fn = true }, -- Enable parsing rgb(...) functions in css. + html = { names = false }, -- Disable parsing "names" like Blue or Gray +}) diff --git a/lua/plugins/configs/nvim-compe.lua b/lua/plugins/configs/nvim-compe.lua new file mode 100644 index 0000000..c990694 --- /dev/null +++ b/lua/plugins/configs/nvim-compe.lua @@ -0,0 +1,29 @@ +--- nvim-compe configuration +-- https://github.com/hrsh7th/nvim-compe#lua-config +require('compe').setup({ + enabled = true, + autocomplete = true, + debug = false, + min_length = 2, + preselect = 'enable', + throttle_time = 80, + source_timeout = 200, + incomplete_delay = 400, + max_abbr_width = 100, + max_kind_width = 100, + max_menu_width = 100, + 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, + }, +}) diff --git a/lua/configs/nvim-focus.lua b/lua/plugins/configs/nvim-focus.lua similarity index 72% rename from lua/configs/nvim-focus.lua rename to lua/plugins/configs/nvim-focus.lua index 25ccb11..ecdf7a3 100644 --- a/lua/configs/nvim-focus.lua +++ b/lua/plugins/configs/nvim-focus.lua @@ -6,4 +6,4 @@ focus.enable = true focus.width = 60 focus.height = 20 -- Set which filetypes focus will not resize -focus.excluded_filetypes = {'NvimTree', 'Vista', 'Minimap', 'terminal'} +focus.excluded_filetypes = { 'NvimTree', 'Vista', 'Minimap', 'terminal' } diff --git a/lua/plugins/configs/nvim-format.lua b/lua/plugins/configs/nvim-format.lua new file mode 100644 index 0000000..426e967 --- /dev/null +++ b/lua/plugins/configs/nvim-format.lua @@ -0,0 +1,115 @@ +require('format').setup({ + ['*'] = { + -- remove trailing whitespaces + { + cmd = { + "sed -i 's/[ \t]*$//'", + }, + }, + }, + vim = { + { + cmd = { + function(file) + return string.format( + 'stylua --config-path ~/.config/stylua/stylua.toml %s', + file + ) + end, + }, + start_pattern = '^lua << EOF$', + end_pattern = '^EOF$', + }, + }, + vimwiki = { + { + cmd = { 'prettier -w --parser babel' }, + start_pattern = '^{{{javascript$', + end_pattern = '^}}}$', + }, + }, + lua = { + { + cmd = { + function(file) + return string.format( + 'stylua --config-path ~/.config/stylua/stylua.toml %s', + file + ) + end, + }, + }, + }, + python = { + { + cmd = { + 'yapf -i', + }, + }, + }, + go = { + { + cmd = { + 'gofmt -w', + 'goimports -w', + }, + tempfile_postfix = '.tmp', + }, + }, + javascript = { + { + cmd = { + 'prettier -w', + './node_modules/.bin/eslint --fix', + }, + }, + }, + typescript = { + { + cmd = { 'prettier -w --parser typescript' }, + }, + }, + html = { + { + cmd = { 'prettier -w --parser html' }, + }, + }, + markdown = { + { + cmd = { 'prettier -w --parser markdown' }, + }, + { + cmd = { + 'yapf -i', + }, + start_pattern = '^```python$', + end_pattern = '^```$', + target = 'current', + }, + }, + css = { + { + cmd = { 'prettier -w --parser css' }, + }, + }, + scss = { + { + cmd = { 'prettier -w --parser scss' }, + }, + }, + json = { + { + cmd = { 'prettier -w --parser json' }, + }, + }, + toml = { + { + cmd = { 'prettier -w --parser toml' }, + }, + }, + yaml = { + { + cmd = { 'prettier -w --parser yaml' }, + }, + }, +}) diff --git a/lua/plugins/configs/nvim-gitsigns.lua b/lua/plugins/configs/nvim-gitsigns.lua new file mode 100644 index 0000000..12d8e43 --- /dev/null +++ b/lua/plugins/configs/nvim-gitsigns.lua @@ -0,0 +1,67 @@ +require('gitsigns').setup({ + signs = { + add = { + hl = 'GitSignsAdd', + text = '│', + numhl = 'GitSignsAddNr', + linehl = 'GitSignsAddLn', + }, + change = { + hl = 'GitSignsChange', + text = '│', + numhl = 'GitSignsChangeNr', + linehl = 'GitSignsChangeLn', + }, + delete = { + hl = 'GitSignsDelete', + text = '_', + numhl = 'GitSignsDeleteNr', + linehl = 'GitSignsDeleteLn', + }, + topdelete = { + hl = 'GitSignsDelete', + text = '‾', + numhl = 'GitSignsDeleteNr', + linehl = 'GitSignsDeleteLn', + }, + changedelete = { + hl = 'GitSignsChange', + text = '~', + numhl = 'GitSignsChangeNr', + linehl = 'GitSignsChangeLn', + }, + }, + numhl = false, + linehl = false, + keymaps = { + -- Default keymap options + noremap = true, + buffer = true, + + ['n ]c'] = { + expr = true, + "&diff ? ']c' : 'lua require\"gitsigns\".next_hunk()'", + }, + ['n [c'] = { + expr = true, + "&diff ? '[c' : 'lua require\"gitsigns\".prev_hunk()'", + }, + + ['n gS'] = 'lua require"gitsigns".stage_hunk()', + ['n gu'] = 'lua require"gitsigns".undo_stage_hunk()', + ['n gr'] = 'lua require"gitsigns".reset_hunk()', + ['n gR'] = 'lua require"gitsigns".reset_buffer()', + ['n gh'] = 'lua require"gitsigns".preview_hunk()', + ['n gb'] = 'lua require"gitsigns".blame_line()', + + -- Text objects + ['o ih'] = ':lua require"gitsigns".select_hunk()', + ['x ih'] = ':lua require"gitsigns".select_hunk()', + }, + watch_index = { interval = 1000 }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + use_decoration_api = true, + use_internal_diff = true, -- If luajit is present +}) diff --git a/lua/plugins/configs/nvim-pears.lua b/lua/plugins/configs/nvim-pears.lua new file mode 100644 index 0000000..0734c1a --- /dev/null +++ b/lua/plugins/configs/nvim-pears.lua @@ -0,0 +1,34 @@ +local R = require('pears.rule') + +require('pears').setup(function(conf) + conf.pair('(', ')') + conf.pair('{', '}') + conf.pair('[', ']') + conf.pair("'", { + close = "'", + should_expand = R.all_of( + -- Don't expand a quote if it comes after an alpha character + R.not_(R.start_of_context('[a-zA-Z]')), + -- Only expand when in a treesitter "string" node + R.child_of_node('string') + ), + }) + conf.pair('"', { + close = '"', + should_expand = R.all_of( + -- Don't expand a quote if it comes after an alpha character + R.not_(R.start_of_context('[a-zA-Z]')), + -- Only expand when in a treesitter "string" node + R.child_of_node('string') + ), + }) + conf.preset('tag_matching') + -- Completion integration with nvim-compe + conf.on_enter(function(pears_handle) + if fn.pumvisible() == 1 and fn.complete_info().selected ~= -1 then + return fn['compe#confirm']('') + else + pears_handle() + end + end) +end) diff --git a/lua/plugins/configs/nvim-telescope.lua b/lua/plugins/configs/nvim-telescope.lua new file mode 100644 index 0000000..c43fb6d --- /dev/null +++ b/lua/plugins/configs/nvim-telescope.lua @@ -0,0 +1,46 @@ +-- https://github.com/nvim-telescope/telescope.nvim#telescope-defaults +-- Required to close with ESC in insert mode +local actions = require('telescope.actions') +local telescope = require('telescope') + +telescope.setup({ + defaults = { + mappings = { i = { [''] = actions.close } }, + vimgrep_arguments = { + 'rg', + '--pretty', + '--with-filename', + '--column', + '--smart-case', + }, + prompt_position = 'bottom', + prompt_prefix = '>', + initial_mode = 'insert', + selection_strategy = 'reset', + sorting_strategy = 'descending', + layout_strategy = 'horizontal', + layout_defaults = { + -- TODO add builtin options. + }, + file_sorter = require('telescope.sorters').get_fuzzy_file, + file_ignore_patterns = {}, + generic_sorter = require('telescope.sorters').get_generic_fuzzy_sorter, + shorten_path = true, + winblend = 0, + width = 0.75, + preview_cutoff = 80, + results_height = 1, + results_width = 0.8, + border = {}, + borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, + color_devicons = true, + use_less = true, + set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil, + file_previewer = require('telescope.previewers').vim_buffer_cat.new, + grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, + qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new, + + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require('telescope.previewers').buffer_previewer_maker, + }, +}) diff --git a/lua/plugins/configs/nvim-toggleterm.lua b/lua/plugins/configs/nvim-toggleterm.lua new file mode 100644 index 0000000..0558d8e --- /dev/null +++ b/lua/plugins/configs/nvim-toggleterm.lua @@ -0,0 +1,20 @@ +require('toggleterm').setup({ + size = g.doom_terminal_height, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + start_in_insert = true, + persist_size = true, + direction = g.doom_terminal_direction, + float_opts = { + border = 'curved', + width = g.doom_terminal_width, + height = g.doom_terminal_height, + winblend = 0, + highlights = { + border = 'Special', + background = 'Normal', + }, + }, +}) diff --git a/lua/configs/nvim-tree.lua b/lua/plugins/configs/nvim-tree.lua similarity index 52% rename from lua/configs/nvim-tree.lua rename to lua/plugins/configs/nvim-tree.lua index e8d9174..4824330 100644 --- a/lua/configs/nvim-tree.lua +++ b/lua/plugins/configs/nvim-tree.lua @@ -1,4 +1,4 @@ -local tree_cb = require'nvim-tree.config'.nvim_tree_callback +local tree_cb = require('nvim-tree.config').nvim_tree_callback -- Empty by default vim.g.nvim_tree_ignore = { '.git', 'node_modules', '.cache', '__pycache__' } @@ -28,62 +28,58 @@ vim.g.nvim_tree_group_empty = 1 -- If false, do not show the icons for one of 'git' 'folder' and 'files' -- true by default, notice that if 'files' is 1, it will only display -- if nvim-web-devicons is installed and on your runtimepath -vim.g.nvim_tree_show_icons = { - git = 1, - folders = 1, - files = 1, -} +vim.g.nvim_tree_show_icons = { git = 1, folders = 1, files = 1 } -- You can edit keybindings be defining this variable -- You don't have to define all keys. -- NOTE: the 'edit' key will wrap/unwrap a folder and open a file vim.g.nvim_tree_bindings = { - -- default mappings - [""] = tree_cb("edit"), - ["o"] = tree_cb("edit"), - ["<2-LeftMouse>"] = tree_cb("edit"), - [""] = tree_cb("cd"), - ["<2-RightMouse>"] = tree_cb("cd"), - [""] = tree_cb("cd"), - [""] = tree_cb("vsplit"), - [""] = tree_cb("split"), - [""] = tree_cb("tabnew"), - [""] = tree_cb("close_node"), - [""] = tree_cb("close_node"), - [""] = tree_cb("preview"), - ["I"] = tree_cb("toggle_ignored"), - ["H"] = tree_cb("toggle_dotfiles"), - ["R"] = tree_cb("refresh"), - ["a"] = tree_cb("create"), - ["d"] = tree_cb("remove"), - ["r"] = tree_cb("rename"), - [""] = tree_cb("full_rename"), - ["x"] = tree_cb("cut"), - ["c"] = tree_cb("copy"), - ["p"] = tree_cb("paste"), - ["[c"] = tree_cb("prev_git_item"), - ["]c"] = tree_cb("next_git_item"), - ["-"] = tree_cb("dir_up"), - ["q"] = tree_cb("close") + -- default mappings + [''] = tree_cb('edit'), + ['o'] = tree_cb('edit'), + ['<2-LeftMouse>'] = tree_cb('edit'), + [''] = tree_cb('cd'), + ['<2-RightMouse>'] = tree_cb('cd'), + [''] = tree_cb('cd'), + [''] = tree_cb('vsplit'), + [''] = tree_cb('split'), + [''] = tree_cb('tabnew'), + [''] = tree_cb('close_node'), + [''] = tree_cb('close_node'), + [''] = tree_cb('preview'), + ['I'] = tree_cb('toggle_ignored'), + ['H'] = tree_cb('toggle_dotfiles'), + ['R'] = tree_cb('refresh'), + ['a'] = tree_cb('create'), + ['d'] = tree_cb('remove'), + ['r'] = tree_cb('rename'), + [''] = tree_cb('full_rename'), + ['x'] = tree_cb('cut'), + ['c'] = tree_cb('copy'), + ['p'] = tree_cb('paste'), + ['[c'] = tree_cb('prev_git_item'), + [']c'] = tree_cb('next_git_item'), + ['-'] = tree_cb('dir_up'), + ['q'] = tree_cb('close'), } -- default will show icon by default if no icon is provided -- default shows no icon by default vim.g.nvim_tree_icons = { - default = "", - symlink = "", - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★" - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - } + default = '', + symlink = '', + git = { + unstaged = '✗', + staged = '✓', + unmerged = '', + renamed = '➜', + untracked = '★', + }, + folder = { + default = '', + open = '', + empty = '', + empty_open = '', + symlink = '', + symlink_open = '', + }, } diff --git a/lua/plugins/configs/nvim-zen.lua b/lua/plugins/configs/nvim-zen.lua new file mode 100644 index 0000000..922a785 --- /dev/null +++ b/lua/plugins/configs/nvim-zen.lua @@ -0,0 +1,42 @@ +require('true-zen').setup({ + true_false_commands = false, + cursor_by_mode = false, + before_minimalist_mode_shown = false, + before_minimalist_mode_hidden = false, + after_minimalist_mode_shown = false, + after_minimalist_mode_hidden = false, + bottom = { + hidden_laststatus = 0, + hidden_ruler = false, + hidden_showmode = false, + hidden_showcmd = false, + hidden_cmdheight = 1, + + shown_laststatus = 2, + shown_ruler = true, + shown_showmode = false, + shown_showcmd = false, + shown_cmdheight = 1, + }, + top = { hidden_showtabline = 0, shown_showtabline = 2 }, + left = { + hidden_number = false, + hidden_relativenumber = false, + hidden_signcolumn = 'no', + + shown_number = true, + shown_relativenumber = false, + shown_signcolumn = 'no', + }, + ataraxis = { + just_do_it_for_me = true, + left_padding = 40, + right_padding = 40, + top_padding = 0, + bottom_padding = 0, + custome_bg = '', + disable_bg_configuration = true, + }, + focus = { margin_of_error = 5 }, + integrations = { integration_galaxyline = true }, +}) diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua new file mode 100644 index 0000000..47cebc7 --- /dev/null +++ b/lua/plugins/configs/statusline.lua @@ -0,0 +1,226 @@ +-- Extracted from https://github.com/glepnir/galaxyline.nvim/blob/main/example/eviline.lua +-- Credits goes to its author (glepnir) :) +local gl = require('galaxyline') +local colors = require('galaxyline.theme').default +local condition = require('galaxyline.condition') +local gls = gl.section + +gl.short_line_list = { 'NvimTree', 'vista', 'dbui', 'packer' } + +gls.left[1] = { + RainbowRed = { + provider = function() + return '▊ ' + end, + highlight = { colors.blue, colors.bg }, + }, +} +gls.left[2] = { + ViMode = { + provider = function() + -- auto change color according the vim mode + local mode_color = { + n = colors.red, + i = colors.green, + v = colors.blue, + [''] = colors.blue, + V = colors.blue, + c = colors.magenta, + no = colors.red, + s = colors.orange, + S = colors.orange, + [''] = colors.orange, + ic = colors.yellow, + R = colors.violet, + Rv = colors.violet, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.red, + t = colors.red, + } + vim.api.nvim_command( + 'hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()] + ) + return ' ' + end, + highlight = { colors.red, colors.bg, 'bold' }, + }, +} +gls.left[3] = { + FileSize = { + provider = 'FileSize', + condition = condition.buffer_not_empty, + highlight = { colors.fg, colors.bg }, + }, +} +gls.left[4] = { + FileIcon = { + provider = 'FileIcon', + condition = condition.buffer_not_empty, + highlight = { + require('galaxyline.provider_fileinfo').get_file_icon_color, + colors.bg, + }, + }, +} +gls.left[5] = { + FileName = { + provider = 'FileName', + condition = condition.buffer_not_empty, + highlight = { colors.magenta, colors.bg, 'bold' }, + }, +} +gls.left[6] = { + LineInfo = { + provider = 'LineColumn', + separator = ' ', + separator_highlight = { 'NONE', colors.bg }, + highlight = { colors.fg, colors.bg }, + }, +} +gls.left[7] = { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = { 'NONE', colors.bg }, + highlight = { colors.fg, colors.bg, 'bold' }, + }, +} +gls.left[8] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = { colors.red, colors.bg }, + }, +} +gls.left[9] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = { colors.yellow, colors.bg }, + }, +} +gls.left[10] = { + DiagnosticHint = { + provider = 'DiagnosticHint', + icon = '  ', + highlight = { colors.cyan, colors.bg }, + }, +} +gls.left[11] = { + DiagnosticInfo = { + provider = 'DiagnosticInfo', + icon = '  ', + highlight = { colors.blue, colors.bg }, + }, +} + +gls.mid[1] = { + ShowLspClient = { + provider = 'GetLspClient', + condition = function() + local tbl = { ['dashboard'] = true, [''] = true } + if tbl[vim.bo.filetype] then + return false + end + return true + end, + icon = ' LSP: ', + highlight = { colors.cyan, colors.bg, 'bold' }, + }, +} + +gls.right[1] = { + FileEncode = { + provider = 'FileEncode', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = { 'NONE', colors.bg }, + highlight = { colors.green, colors.bg, 'bold' }, + }, +} +gls.right[2] = { + FileFormat = { + provider = 'FileFormat', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = { 'NONE', colors.bg }, + highlight = { colors.green, colors.bg, 'bold' }, + }, +} +gls.right[3] = { + GitIcon = { + provider = function() + return '  ' + end, + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = { 'NONE', colors.bg }, + highlight = { colors.violet, colors.bg, 'bold' }, + }, +} +gls.right[4] = { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + highlight = { colors.violet, colors.bg, 'bold' }, + }, +} +gls.right[5] = { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width, + icon = '  ', + highlight = { colors.green, colors.bg }, + }, +} +gls.right[6] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = ' 柳', + highlight = { colors.orange, colors.bg }, + }, +} +gls.right[7] = { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width, + icon = '  ', + highlight = { colors.red, colors.bg }, + }, +} +gls.right[8] = { + RainbowBlue = { + provider = function() + return ' ▊' + end, + highlight = { colors.blue, colors.bg }, + }, +} + +gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = { 'NONE', colors.bg }, + highlight = { colors.blue, colors.bg, 'bold' }, + }, +} +gls.short_line_left[2] = { + SFileName = { + provider = 'SFileName', + condition = condition.buffer_not_empty, + highlight = { colors.fg, colors.bg, 'bold' }, + }, +} + +gls.short_line_right[1] = { + BufferIcon = { + provider = 'BufferIcon', + highlight = { colors.fg, colors.bg }, + }, +} diff --git a/lua/plugins/configs/symbols.lua b/lua/plugins/configs/symbols.lua new file mode 100644 index 0000000..869731b --- /dev/null +++ b/lua/plugins/configs/symbols.lua @@ -0,0 +1,14 @@ +g.symbols_outline = { + highlight_hovered_item = true, + show_guides = true, + position = 'left', + keymaps = { + close = '', + goto_location = '', + focus_location = 'o', + hover_symbol = '', + rename_symbol = 'r', + code_actions = 'a', + }, + lsp_blacklist = {}, +} diff --git a/lua/configs/tree-sitter.lua b/lua/plugins/configs/tree-sitter.lua similarity index 64% rename from lua/configs/tree-sitter.lua rename to lua/plugins/configs/tree-sitter.lua index ace7339..ab3cac8 100644 --- a/lua/configs/tree-sitter.lua +++ b/lua/plugins/configs/tree-sitter.lua @@ -4,8 +4,9 @@ local ts = require('nvim-treesitter.configs') maintained languages modules instead of a list of languages. You also need to set highlight to true, otherwise the plugin will be disabled. --]] -ts.setup { - -- NOTE: Place your languages here! - ensure_installed = vim.g.doom_ts_parsers, - highlight = { enabled = true } -} +ts.setup({ + -- NOTE: Place your languages here! + ensure_installed = vim.g.doom_ts_parsers, + highlight = { enabled = true }, + indent = { enabled = true }, +}) diff --git a/lua/plugins/configs/which-key.lua b/lua/plugins/configs/which-key.lua new file mode 100644 index 0000000..edbe09b --- /dev/null +++ b/lua/plugins/configs/which-key.lua @@ -0,0 +1,30 @@ +require('which-key').setup({ + plugins = { marks = false, registers = false }, + presets = { + operators = false, + motions = false, + text_objects = false, + windows = false, + nav = false, + z = false, + g = false, + }, + icons = { + breadcrumb = '»', -- symbol used in the command line area that shows your active key combo + separator = '➜', -- symbol used between a key and it's label + group = '+', -- symbol prepended to a group + }, + window = { + border = 'none', -- none, single, double, shadow + position = 'bottom', -- bottom, top + margin = { 1, 0, 0, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 1, 1, 1, 1 }, -- extra window padding [top, right, bottom, left] + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + }, + hidden = { '', '^:', '^ ' }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible +}) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..4424f06 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,374 @@ +-- Manage vim global variables +local nvim_set_var = api.nvim_set_var + +----- Plugins modules +-- Essentials / (Plugin manager, vimpeccable, treesitter, sessions) +-- UI Related / (All look-and-feel plugins) +-- Fuzzy Search ! (Fuzzy searching) +-- Git Integration + (Some git plugins like LazyGit) +-- Completion + (Built-in LSP configurations) +-- File-related + (EditorConfig, formatting, Tree-sitter, etc) +-- Web-related + (Colorizer, emmet, rest client) +-- +-- Legend: +-- ! : The group and its plugins cannot be disabled +-- / : The group cannot be disabled but some of its plugins can be +-- + : The group and its plugins can be disabled +-- +-- NOTES: +-- 1. You can disable an entire group or just some or their plugins based on +-- the legend, please refer to our documentation to learn how to do it. +-- 2. We do not provide other LSP integration like coc.nvim, +-- please refer to our FAQ to see why. + +--- Set disabled plugins modules and plugins +local disabled_plugins = {} +--- Disabled modules +local disabled_git = has_value(g.doom_disabled_modules, 'git') +local disabled_lsp = has_value(g.doom_disabled_modules, 'lsp') +local disabled_files = has_value(g.doom_disabled_modules, 'files') +local disabled_web = has_value(g.doom_disabled_modules, 'web') + +local packer = require('packer') +return packer.startup(function() + -----[[------------]]----- + --- Essentials --- + -----]]------------[[----- + -- Plugins manager + use('wbthomason/packer.nvim') + + -- Auxiliar functions for using Lua in Neovim + use('svermeulen/vimpeccable') + + -- Tree-Sitter + local disabled_treesitter = + has_value(g.doom_disabled_plugins, 'treesitter') + if disabled_files and not disabled_treesitter then + table.insert(disabled_plugins, 'treesitter') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + disable = (disabled_files and true or disabled_treesitter), + }) + + -- Sessions + use({ + 'rmagatti/auto-session', + requires = { 'rmagatti/session-lens' }, + }) + + -----[[------------]]----- + --- UI Related --- + -----]]------------[[----- + -- Fancy start screen + -- cannot be disabled + use({ 'glepnir/dashboard-nvim', disabled = false }) + + -- Colorschemes + -- cannot be disabled at the moment + use({ + 'sainnhe/sonokai', + 'sainnhe/edge', + 'sainnhe/everforest', + 'wadackel/vim-dogrun', + 'joshdick/onedark.vim', + 'ajmwagar/vim-deus', + }) + + -- File tree + local disabled_tree = has_value(g.doom_disabled_plugins, 'tree') + if disabled_tree then + table.insert(disabled_plugins, 'tree') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'kyazdani42/nvim-tree.lua', + requires = { 'kyazdani42/nvim-web-devicons' }, + disabled = disabled_tree, + }) + + -- Statusline + -- can be disabled to use your own statusline + local disabled_statusline = + has_value(g.doom_disabled_plugins, 'statusline') + if disabled_statusline then + table.insert(disabled_plugins, 'statusline') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'glepnir/galaxyline.nvim', + disabled = disabled_statusline, + }) + + -- Tabline + -- can be disabled to use your own tabline + local disabled_tabline = has_value(g.doom_disabled_plugins, 'tabline') + if disabled_tabline then + table.insert(disabled_plugins, 'tabline') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ 'romgrk/barbar.nvim', disabled = disabled_tabline }) + + -- Better splits + -- NOTE: we are using this specific branch because the main still does not have + -- the ignore filetypes feature, thanks to its owner per adding it <3 + local disabled_focus = has_value(g.doom_disabled_plugins, 'focus') + if disabled_focus then + table.insert(disabled_plugins, 'focus') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'beauwilliams/focus.nvim', + branch = 'cust_filetypes', + disabled = disabled_focus, + }) + + -- Better terminal + -- can be disabled to use your own terminal plugin + local disabled_terminal = has_value(g.doom_disabled_plugins, 'terminal') + if disabled_terminal then + table.insert(disabled_plugins, 'terminal') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'akinsho/nvim-toggleterm.lua', + disabled = disabled_terminal, + }) + + -- Viewer & finder for LSP symbols and tags + local disabled_tagbar = has_value(g.doom_disabled_plugins, 'tagbar') + if disabled_tagbar then + table.insert(disabled_plugins, 'tagbar') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'simrat39/symbols-outline.nvim', + disabled = disabled_tagbar, + }) + + -- Minimap + -- Depends on wfxr/code-minimap to work! + local disabled_minimap = has_value(g.doom_disabled_plugins, 'minimap') + if disabled_minimap then + table.insert(disabled_plugins, 'minimap') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ 'wfxr/minimap.vim', disabled = disabled_minimap }) + + -- Keybindings menu like Emacs's guide-key + -- cannot be disabled + use({ 'folke/which-key.nvim', disabled = false }) + + -- Distraction free environment + local disabled_zen = has_value(g.doom_disabled_plugins, 'zen') + if disabled_zen then + table.insert(disabled_plugins, 'zen') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ 'kdav5758/TrueZen.nvim', disabled = disabled_zen }) + + -----[[--------------]]----- + --- Fuzzy Search --- + -----]]--------------[[----- + use({ + 'nvim-telescope/telescope.nvim', + requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } }, + disable = false, + }) + + -----[[-------------]]----- + --- GIT RELATED --- + -----]]-------------[[----- + -- Git gutter better alternative, written in Lua + -- can be disabled to use your own git gutter plugin + local disabled_gitsigns = has_value(g.doom_disabled_plugins, 'gitsigns') + if disabled_git and not disabled_gitsigns then + table.insert(disabled_plugins, 'gitsigns') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'lewis6991/gitsigns.nvim', + disable = (disabled_git and true or disabled_gitsigns), + }) + + -- LazyGit integration + local disabled_lazygit = has_value(g.doom_disabled_plugins, 'lazygit') + if disabled_git and not disabled_lazygit then + table.insert(disabled_plugins, 'lazygit') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'kdheepak/lazygit.nvim', + requires = { 'nvim-lua/plenary.nvim' }, + disable = (disabled_git and true or disabled_lazygit), + }) + + -----[[------------]]----- + --- Completion --- + -----]]------------[[----- + -- Built-in LSP Config + -- NOTE: It should not be disabled if you are going to use LSP! + local disabled_lspconfig = + has_value(g.doom_disabled_plugins, 'lspconfig') + if disabled_lsp and not disabled_lspconfig then + table.insert(disabled_plugins, 'lspconfig') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'neovim/nvim-lspconfig', + disable = (disabled_completion and true or disabled_lspconfig), + }) + + -- Completion plugin + -- can be disabled to use your own completion plugin + local disabled_compe = has_value(g.doom_disabled_plugins, 'compe') + if disabled_lsp and not disabled_compe then + table.insert(disabled_plugins, 'compe') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'hrsh7th/nvim-compe', + requires = { + { 'ray-x/lsp_signature.nvim' }, + { 'onsails/lspkind-nvim' }, + { 'norcalli/snippets.nvim' }, + }, + disable = (disabled_completion and true or disabled_compe), + }) + + -- provides the missing `:LspInstall` for `nvim-lspconfig`. + local disabled_lspinstall = + has_value(g.doom_disabled_plugins, 'lspinstall') + if disabled_lsp and not disabled_lspinstall then + table.insert(disabled_plugins, 'lspinstall') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use('kabouzeid/nvim-lspinstall') + + -----[[--------------]]----- + --- File Related --- + -----]]--------------[[----- + -- Write / Read files without permissions (e.g. /etc files) without having + -- to use `sudo nvim /path/to/file` + local disabled_suda = has_value(g.doom_disabled_plugins, 'suda') + if disabled_files and not disabled_suda then + table.insert(disabled_plugins, 'suda') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'lambdalisue/suda.vim', + disable = (disabled_files and true or disabled_suda), + }) + + -- File formatting + -- can be disabled to use your own file formatter + local disabled_formatter = + has_value(g.doom_disabled_plugins, 'formatter') + if disabled_files and not disabled_formatter then + table.insert(disabled_plugins, 'formatter') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'lukas-reineke/format.nvim', + disable = (disabled_files and true or disabled_formatter), + }) + + -- Autopairs + -- can be disabled to use your own autopairs + local disabled_autopairs = + has_value(g.doom_disabled_plugins, 'autopairs') + if disabled_files and not disabled_autopairs then + table.insert(disabled_plugins, 'autopairs') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'steelsojka/pears.nvim', + disable = (disabled_files and true or disabled_autopairs), + }) + + -- Indent Lines + local disabled_indent_lines = + has_value(g.doom_disabled_plugins, 'indentlines') + if disabled_files and not disabled_indent_lines then + table.insert(disabled_plugins, 'indentlines') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'Yggdroot/indentLine', + disable = (disabled_files and true or disabled_indent_lines), + }) + + -- EditorConfig support + local disabled_editorconfig = + has_value(g.doom_disabled_plugins, 'editorconfig') + if disabled_files and not disabled_editorconfig then + table.insert(disabled_plugins, 'editorconfig') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'editorconfig/editorconfig-vim', + disable = (disabled_files and true or disabled_editorconfig), + }) + + -- Comments + -- can be disabled to use your own comments plugin + local disabled_kommentary = + has_value(g.doom_disabled_plugins, 'kommentary') + if disabled_files and not disabled_kommentary then + table.insert(disabled_plugins, 'kommentary') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'b3nj5m1n/kommentary', + disable = (disabled_files and true or disabled_kommentary), + }) + + -----[[-------------]]----- + --- Web Related --- + -----]]-------------[[----- + -- Fastest colorizer without external dependencies! + local disabled_colorizer = + has_value(g.doom_disabled_plugins, 'colorizer') + if disabled_web and not disabled_colorizer then + table.insert(disabled_plugins, 'colorizer') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'norcalli/nvim-colorizer.lua', + disable = (disabled_web and true or disabled_colorizer), + }) + + -- HTTP Client support + -- Depends on bayne/dot-http to work! + local disabled_restclient = + has_value(g.doom_disabled_plugins, 'restclient') + if disabled_web and not disabled_restclient then + table.insert(disabled_plugins, 'restclient') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'bayne/vim-dot-http', + disable = (disabled_web and true or disabled_restclient), + }) + + -- Emmet plugin + local disabled_emmet = has_value(g.doom_disabled_plugins, 'emmet') + if disabled_web and not disabled_emmet then + table.insert(disabled_plugins, 'emmet') + nvim_set_var('doom_disabled_plugins', disabled_plugins) + end + use({ + 'mattn/emmet-vim', + disable = (disabled_web and true or disabled_emmet), + }) + + -----[[----------------]]----- + --- Custom Plugins --- + -----]]----------------[[----- + -- If there are custom plugins then also require them + for _, plug in pairs(g.doom_custom_plugins) do + custom_plugins(plug) + end +end)