From 29811e0f2396ebbb0738b7fb0f3b5c20f9eaa291 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 18 Apr 2023 01:14:01 +0100 Subject: [PATCH 01/16] nvim/options: disable default LazyVim options Thanks to @folke for the workaround. https://github.com/LazyVim/LazyVim/issues/566 --- nvim/init.lua | 1 + nvim/lua/config/options.lua | 21 +-------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index bc3ed51..5f7a282 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -2,4 +2,5 @@ vim.cmd([[ source $XDG_CONFIG_HOME/vim/vimrc ]]) -- bootstrap lazy.nvim, LazyVim and your plugins +package.loaded["lazyvim.config.options"] = true require("config.lazy") diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua index 1bc95c8..60c4ad3 100644 --- a/nvim/lua/config/options.lua +++ b/nvim/lua/config/options.lua @@ -2,26 +2,7 @@ local opt = vim.opt --- FIXME: There's currently no way to disable LazyVim's default options, so --- reset the ones from vimrc. --- See https://github.com/LazyVim/LazyVim/issues/566 --- 1. settings that are overriden in LazyVim options -opt.clipboard = "" -- Sync with system clipboard -opt.completeopt = "menu,menuone,noselect" -opt.formatoptions:append("jcrnqlt") -- see vimrc for details -opt.formatoptions:remove("o") -- see vimrc for details -opt.number = false -opt.relativenumber = false -opt.scrolloff = 5 -opt.shiftwidth = 4 -opt.tabstop = 8 -opt.sidescrolloff = 1 -opt.splitbelow = false -opt.splitright = true -opt.timeoutlen = 1000 - --- FIXME: --- 2. settings I might want to include when disabling options works +-- Some settings taken from LazyVim's default options opt.pumblend = 10 -- Popup blend opt.pumheight = 10 -- Maximum number of entries in a popup opt.showmode = false -- Dont show mode since we have a statusline -- 2.49.0 From 7b35ef0be6b73cdd1e895d3955482a2fa43b7776 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 18 Apr 2023 01:19:47 +0100 Subject: [PATCH 02/16] nvim/ui: do not grep with g on dashboard It's really surprising. --- nvim/lua/plugins/ui.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index 42f2db7..f988ed4 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua @@ -82,7 +82,6 @@ return { dashboard.button("f", " " .. " Find file", ":Telescope find_files "), dashboard.button("n", " " .. " New file", ":ene startinsert "), dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), - dashboard.button("g", " " .. " Find text", ":Telescope live_grep "), dashboard.button("c", " " .. " Config", ":e $MYVIMRC "), dashboard.button("s", " " .. " Restore Session", [[:lua require("persistence").load() ]]), dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy"), -- 2.49.0 From b0951dca9a0e61cb14f0b80adfcf6c16f6e7fc82 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 18 Apr 2023 01:21:04 +0100 Subject: [PATCH 03/16] nvim/editor: load neo-tree eagerly If loaded lazily it won't open upon editing a directory. https://github.com/LazyVim/LazyVim/issues/572 --- nvim/lua/plugins/editor.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/nvim/lua/plugins/editor.lua b/nvim/lua/plugins/editor.lua index 8b26d41..7f30842 100644 --- a/nvim/lua/plugins/editor.lua +++ b/nvim/lua/plugins/editor.lua @@ -10,6 +10,7 @@ return { }, { "neo-tree.nvim", + lazy = false, opts = { filesystem = { -- TODO: review these -- 2.49.0 From 94003aad78cd3e6606b76416f63151d13ddc4e39 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 10:33:00 +0100 Subject: [PATCH 04/16] nvim/coding: use snippets from vim-snippets --- nvim/lua/plugins/coding.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index a2e1538..6194756 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -4,6 +4,14 @@ return { { "L3MON4D3/LuaSnip", -- disable luasnip bindings for and + dependencies = { + { + "honza/vim-snippets", + config = function() + require("luasnip.loaders.from_snipmate").lazy_load() + end, + }, + }, keys = function() return {} end, -- 2.49.0 From aeb0fcc4836a91549f1dc7a343181abe2ca861b0 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 10:34:02 +0100 Subject: [PATCH 05/16] nvim/editor: disable ff for telescope It's already muscle memory mapped to fswitch. --- nvim/lua/plugins/editor.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/nvim/lua/plugins/editor.lua b/nvim/lua/plugins/editor.lua index 7f30842..d1871fc 100644 --- a/nvim/lua/plugins/editor.lua +++ b/nvim/lua/plugins/editor.lua @@ -6,6 +6,7 @@ return { { "", false }, { "gc", false }, { "gs", false }, + { "ff", false }, -- fswitch }, }, { -- 2.49.0 From 12a2fe75d5dcc8df3f85fed9f23b248e65485996 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 10:35:11 +0100 Subject: [PATCH 06/16] nvim/editor: add snippet telescope plugin --- nvim/lua/plugins/editor.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nvim/lua/plugins/editor.lua b/nvim/lua/plugins/editor.lua index d1871fc..cea1326 100644 --- a/nvim/lua/plugins/editor.lua +++ b/nvim/lua/plugins/editor.lua @@ -7,8 +7,20 @@ return { { "gc", false }, { "gs", false }, { "ff", false }, -- fswitch + -- use for snippets below + { "ss", false }, }, }, + { + "benfowler/telescope-luasnip.nvim", + dependencies = { + "telescope.nvim", + }, + config = function() + require("telescope").load_extension("luasnip") + end, + keys = { { "ss", "Telescope luasnip", desc = "Snippets" } }, + }, { "neo-tree.nvim", lazy = false, -- 2.49.0 From b9bb56f915f21c31e54bffadf8923562cce749b9 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 10:38:46 +0100 Subject: [PATCH 07/16] nvim/ui: send long messages to split I don't think this is actually working. I don't care too much, see next commit. --- nvim/lua/plugins/ui.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index f988ed4..1b57307 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua @@ -18,7 +18,8 @@ return { opts = { presets = { command_palette = false, -- don't position the cmdline and popupmenu together - lsp_doc_border = true, -- add a border to hover docs and signature help + lsp_doc_border = true, + long_message_to_split = true, }, cmdline = { view = "cmdline", -- 2.49.0 From 934aac5bc527ae0282e279d789a606526d5ac368 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 10:39:27 +0100 Subject: [PATCH 08/16] nvim/ui: disable Noice It messes too much with existing notifications. --- nvim/lua/plugins/ui.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index 1b57307..ad86cee 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua @@ -14,6 +14,7 @@ return { }, { "noice.nvim", + enabled = false, ---@type NoiceConfig opts = { presets = { -- 2.49.0 From ec103556f2e0a25af006b0e3096cf00f10d24793 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 11:18:38 +0100 Subject: [PATCH 09/16] vim/cpp: set ycm bindings in c.vim only, cpp loads that file too --- vim/ftplugin/c.vim | 1 + vim/ftplugin/cpp.vim | 24 ------------------------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim index dc06376..0dca3bc 100644 --- a/vim/ftplugin/c.vim +++ b/vim/ftplugin/c.vim @@ -17,6 +17,7 @@ nnoremap d :vs:YcmCompleter GoTo nnoremap gD :YcmCompleter GoToReferences nnoremap fi :YcmCompleter FixIt +nnoremap fr :YcmCompleter RefactorRename " format with = call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') diff --git a/vim/ftplugin/cpp.vim b/vim/ftplugin/cpp.vim index 12c6443..ea6837f 100644 --- a/vim/ftplugin/cpp.vim +++ b/vim/ftplugin/cpp.vim @@ -45,30 +45,6 @@ let g:switch_const_definitions = nnoremap c :call switch#Switch({'definitions': g:switch_const_definitions}) -" Disable ale as we use ycm -let b:ale_enabled = 0 - -nnoremap gd :YcmCompleter GoTo -nnoremap d :vs:YcmCompleter GoTo -nnoremap gD :YcmCompleter GoToReferences - -nnoremap fi :YcmCompleter FixIt -nnoremap fr :YcmCompleter RefactorRename - -" format with = -call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') -map = (operator-ycmcompleter-format) -vnoremap = :YcmCompleter Format -" restore = mapping to g= -nnoremap g= = -vnoremap g= = - -" hover popup -let g:ycm_auto_hover = '' -let b:ycm_hover = { 'command': 'GetDoc', 'syntax': &filetype } -nmap gh (YCMHover) -nmap gH :YcmCompleter GetDoc - setlocal errorformat= " TODO I don't remember these errorformat or what they match, maybe CMake? {{{ setlocal errorformat+=\ %##%n\ %m\ %f:%l:%c -- 2.49.0 From 1bf3e02489c57abb439d7dc6aab5f9a94ec40eec Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 11:19:44 +0100 Subject: [PATCH 10/16] vim: only set ycm bindings if ycm is loaded --- vim/ftplugin/c.vim | 55 ++++++++++++++++++++++++----------------- vim/ftplugin/python.vim | 8 +++--- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim index 0dca3bc..a2e9e71 100644 --- a/vim/ftplugin/c.vim +++ b/vim/ftplugin/c.vim @@ -9,29 +9,38 @@ augroup fswitch au BufEnter *.c let b:fswitchlocs = 'reg:|source|include/**|' augroup END -" Disable ale as we use ycm -let b:ale_enabled = 0 - -nnoremap gd :YcmCompleter GoTo -nnoremap d :vs:YcmCompleter GoTo -nnoremap gD :YcmCompleter GoToReferences - -nnoremap fi :YcmCompleter FixIt -nnoremap fr :YcmCompleter RefactorRename - -" format with = -call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') -map = (operator-ycmcompleter-format) -vnoremap = :YcmCompleter Format -" restore = mapping to g= -nnoremap g= = -vnoremap g= = - -" hover popup -let g:ycm_auto_hover = '' -let b:ycm_hover = { 'command': 'GetDoc', 'syntax': &filetype } -nmap gh (YCMHover) -nmap gH :YcmCompleter GetDoc +if exists("g:loaded_youcompleteme") + " Disable ale as we use ycm + let b:ale_enabled = 0 + + nnoremap gd :YcmCompleter GoTo + nnoremap d :vs:YcmCompleter GoTo + nnoremap gD :YcmCompleter GoToReferences + + " replaced with ca (code action) in neovim + nnoremap fi :YcmCompleter FixIt + " replaced with cr (code rename) in neovim + nnoremap fr :YcmCompleter RefactorRename + + " format with = + call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') + map = (operator-ycmcompleter-format) + vnoremap = :YcmCompleter Format + " restore = mapping to g= + nnoremap g= = + vnoremap g= = + + " hover popup + let g:ycm_auto_hover = '' + let b:ycm_hover = { 'command': 'GetDoc', 'syntax': &filetype } + nmap gh (YCMHover) + nmap gH :YcmCompleter GetDoc +else + " I'm way to used to using = to format than to switch to gq + nnoremap = gq + nnoremap == gqq + vnoremap = gq +endif let b:tcomment_options = {'whitespace': 'no'} diff --git a/vim/ftplugin/python.vim b/vim/ftplugin/python.vim index c64e31f..83d8895 100644 --- a/vim/ftplugin/python.vim +++ b/vim/ftplugin/python.vim @@ -1,5 +1,7 @@ setlocal foldlevelstart=1 " at least show content of classes -nnoremap gd :YcmCompleter GoTo -nnoremap d :vs:YcmCompleter GoTo -nnoremap gD :YcmCompleter GoToReferences +if exists("g:loaded_youcompleteme") + nnoremap gd :YcmCompleter GoTo + nnoremap d :vs:YcmCompleter GoTo + nnoremap gD :YcmCompleter GoToReferences +endif -- 2.49.0 From 69767539adb7b1429528c30a81b771b3fe7d5967 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 11:20:56 +0100 Subject: [PATCH 11/16] vim: make help and man ftplugins consistent --- vim/ftplugin/help.vim | 4 +++- vim/ftplugin/man.vim | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/vim/ftplugin/help.vim b/vim/ftplugin/help.vim index c79df7a..3d477e2 100644 --- a/vim/ftplugin/help.vim +++ b/vim/ftplugin/help.vim @@ -2,6 +2,8 @@ setlocal textwidth=78 setlocal listchars-=extends:❯,precedes:❮ setlocal sidescroll=0 setlocal sidescrolloff=0 +setlocal signcolumn=no +setlocal winfixwidth wincmd L -vertical resize 78 +vertical resize 80 normal ze diff --git a/vim/ftplugin/man.vim b/vim/ftplugin/man.vim index bd6528a..00fb96d 100644 --- a/vim/ftplugin/man.vim +++ b/vim/ftplugin/man.vim @@ -1,8 +1,10 @@ setlocal nolist -setlocal textwidth=80 +setlocal textwidth=88 setlocal listchars-=extends:❯,precedes:❮ setlocal sidescroll=0 setlocal sidescrolloff=0 +setlocal winfixwidth +setlocal nowrap wincmd L -vertical resize 80 +vertical resize 88 normal ze -- 2.49.0 From 36a97bcfbaf0d7ecfdc03978346c44db453202ec Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 11:22:44 +0100 Subject: [PATCH 12/16] vim: don't reset shortmess and don't give file info --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 6cc50e7..f94553e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -293,7 +293,6 @@ endif set showcmd " Show (partial) command in status line. set ruler " show the cursor position all the time set confirm " Ask what to do when closing unsaved documents -set shortmess= " reset option set shortmess+=a " all abbreviations set shortmess+=o " overwrite file-written message set shortmess+=O " file-read message overrides previous @@ -302,6 +301,7 @@ set shortmess+=T " truncate other messages in the middle set shortmess+=W " don't give 'written' or '[w]' when writing a file set shortmess+=A " ignore swapfile warning set shortmess+=I " no splash screen +set shortmess+=F " don't give the file info when editing a file set shortmess+=c " don't give |ins-completion-menu| messages " editing text {{{2 -- 2.49.0 From e701ed226fd9bff7e5ac749fef8c7c939f82b15e Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 11:33:01 +0100 Subject: [PATCH 13/16] zsh: switch to nvim as default editor --- aliases | 2 +- zshenv | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aliases b/aliases index 721a3da..e7b0a12 100644 --- a/aliases +++ b/aliases @@ -32,7 +32,7 @@ if [[ -n "${VIM_TERMINAL}" ]]; then done } fi -alias vi='vim' +alias vi=nvim alias svi='sudo -e' #alias vp='vim PKGBUILD' # I have a script for that in ~/bin alias vs='vim SPLITBUILD' diff --git a/zshenv b/zshenv index 7a3b049..c184a18 100644 --- a/zshenv +++ b/zshenv @@ -28,9 +28,9 @@ fi # vim stuff [[ -d "$XDG_CACHE_HOME/vim/backup" ]] || mkdir -p "$XDG_CACHE_HOME"/vim/{backup,undo,view} -export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' -export EDITOR=vim -export VISUAL=vim +export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/"..(has("nvim")?"nvim/init.lua":"vim/vimrc") | source $MYVIMRC' +export EDITOR=nvim +export VISUAL=nvim # default browser export BROWSER=qutebrowser -- 2.49.0 From 4a1458d924b9f2a7d986d34238f931dc4eb5c29c Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 10:22:03 +0100 Subject: [PATCH 14/16] nvim: switch to nord colorscheme --- nvim/lua/plugins/colorscheme.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 nvim/lua/plugins/colorscheme.lua diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..216da0a --- /dev/null +++ b/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,32 @@ +---@type LazyPluginSpec +return { + { "LazyVim", opts = { colorscheme = "nord" } }, + { + -- this meta plugin can be used to install all colorschemes to test with telescope + name = "colorschemes", + dir = "", + lazy = true, + dependencies = { + { "shaunsingh/nord.nvim"}, + -- conflicts with above + -- { "gbprod/nord.nvim"}, + { + -- requires too much configuration to make look good + "rmehri01/onenord.nvim", + opts = function(_, opts) + local colors = require("onenord.colors").load() + opts = vim.tbl_extend("force", opts, { + custom_highlights = { + ["@parameter"] = { fg = colors.fg }, + ["@namespace"] = { fg = colors.fg }, + ["@type"] = { fg = colors.fg }, + ["@variable.builtin"] = { fg = colors.fg }, + }, + }) + return opts + end, + }, + { "folke/tokyonight.nvim" }, + }, + }, +} -- 2.49.0 From eaaa7107f38a6fb53662b06def96855900ab4ce2 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 2 May 2023 23:18:41 +0100 Subject: [PATCH 15/16] nvim/colorscheme: default to onenord Seems nord is a little broken when indent-blankline interracts with diff. --- nvim/lua/plugins/colorscheme.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua index 216da0a..b742b4b 100644 --- a/nvim/lua/plugins/colorscheme.lua +++ b/nvim/lua/plugins/colorscheme.lua @@ -1,15 +1,12 @@ ---@type LazyPluginSpec return { - { "LazyVim", opts = { colorscheme = "nord" } }, + { "LazyVim", opts = { colorscheme = "onenord" } }, { -- this meta plugin can be used to install all colorschemes to test with telescope name = "colorschemes", dir = "", lazy = true, dependencies = { - { "shaunsingh/nord.nvim"}, - -- conflicts with above - -- { "gbprod/nord.nvim"}, { -- requires too much configuration to make look good "rmehri01/onenord.nvim", @@ -27,6 +24,9 @@ return { end, }, { "folke/tokyonight.nvim" }, + { "shaunsingh/nord.nvim"}, + -- conflicts with above + -- { "gbprod/nord.nvim"}, }, }, } -- 2.49.0 From b4d8aa6b8678f3751cc262d9a93e585eae5577dd Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Wed, 3 May 2023 00:48:47 +0100 Subject: [PATCH 16/16] nvim/colorscheme: use catppuccin with nord overrides Maybe this is the better color. Although still quite colorful. --- nvim/lua/plugins/colorscheme.lua | 43 +++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua index b742b4b..613df5e 100644 --- a/nvim/lua/plugins/colorscheme.lua +++ b/nvim/lua/plugins/colorscheme.lua @@ -1,6 +1,10 @@ ---@type LazyPluginSpec return { - { "LazyVim", opts = { colorscheme = "onenord" } }, + { + "LazyVim", + opts = { colorscheme = "catppuccin-mocha" }, + dependencies = { "catppuccin" }, + }, { -- this meta plugin can be used to install all colorschemes to test with telescope name = "colorschemes", @@ -24,6 +28,43 @@ return { end, }, { "folke/tokyonight.nvim" }, + { + "catppuccin/nvim", + name = "catppuccin", + opts = { + color_overrides = { + -- https://github.com/catppuccin/nvim/discussions/323#discussioncomment-5760383 + mocha = { + rosewater = "#BF616A", + flamingo = "#BF616A", + pink = "#B48EAD", + mauve = "#B48EAD", + red = "#BF616A", + maroon = "#BF616A", + peach = "#D08770", + yellow = "#EBCB8B", + green = "#A3BE8C", + teal = "#88c0d0", + sky = "#88c0d0", + sapphire = "#88c0d0", + blue = "#81a1c1", + lavender = "#81a1c1", + text = "#ECEFF4", + subtext1 = "#E5E9F0", + subtext0 = "#D8DEE9", + overlay2 = "#8d9196", + overlay1 = "#81858b", + overlay0 = "#4C566A", + surface2 = "#434C5E", + surface1 = "#3B4252", + surface0 = "#292e39", + base = "#242933", + mantle = "#20242d", + crust = "#1c2028", + }, + }, + }, + }, { "shaunsingh/nord.nvim"}, -- conflicts with above -- { "gbprod/nord.nvim"}, -- 2.49.0