diff options
| -rw-r--r-- | .config/nvim/colors/ocean.lua | 7 | ||||
| -rw-r--r-- | .config/nvim/init.lua | 70 | ||||
| -rw-r--r-- | .config/nvim/plugin/autosave.lua | 30 | ||||
| -rw-r--r-- | .config/nvim/plugin/autosave.vim | 21 | ||||
| -rw-r--r-- | .config/nvim/plugin/leaf.vim | 8 | ||||
| -rw-r--r-- | TODO | 2 |
6 files changed, 74 insertions, 64 deletions
diff --git a/.config/nvim/colors/ocean.lua b/.config/nvim/colors/ocean.lua index 289b075..342f26e 100644 --- a/.config/nvim/colors/ocean.lua +++ b/.config/nvim/colors/ocean.lua @@ -278,10 +278,3 @@ link('sqlKeyword', 'SyntaxStatement2') --- Utilities {{{1 - -vim.cmd([[ -command! -bar - \ OceanGetHighlightGroupName - \ echo synIDattr(synID(line('.'), col('.'), v:false), 'name') -]]) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 056dd5e..8ffe9bd 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -644,12 +644,15 @@ function vimrc.fn.smart_open(command) end end - -vim.cmd([[ -command! -nargs=+ -complete=command - \ SmartOpen - \ call v:lua.vimrc.fn.smart_open(<q-args>) -]]) +vim.api.nvim_create_user_command( + 'SmartOpen', + function(opts) vimrc.fn.smart_open(opts.args) end, + { + desc = 'Smartly open a new buffer', + nargs = '+', + complete = 'command', + } +) @@ -733,11 +736,13 @@ function vimrc.fn.open_scratch() end end -vim.cmd([[ -command! - \ Scratch - \ call v:lua.vimrc.fn.open_scratch() -]]) +vim.api.nvim_create_user_command( + 'Scratch', + function() vimrc.fn.open_scratch() end, + { + desc = 'Open a *scratch* buffer', + } +) vimrc.map('n', '<Space>s', '<Cmd>Scratch<CR>', { silent = true }) @@ -844,11 +849,15 @@ vimrc.map('x', 's', '<Nop>') -- Note: directly calling `g/^/m` will overwrite the current search pattern with -- '^' and highlight it, which is not expected. -- :h :keeppatterns -vim.cmd([[ -command! -bar -range=% - \ Reverse - \ keeppatterns <line1>,<line2>g/^/m<line1>-1 -]]) +vim.api.nvim_create_user_command( + 'Reverse', + 'keeppatterns <line1>,<line2>g/^/m<line1>-1', + { + desc = 'Reverse lines', + bar = true, + range = '%', + } +) @@ -870,11 +879,15 @@ end -- If the current buffer is empty, open a file with the current window; -- otherwise open a new tab. -vim.cmd([[ -command! -bar -complete=file -nargs=* - \ SmartTabEdit - \ call v:lua.vimrc.fn.smart_tabedit(<q-mods>, <q-args>) -]]) +vim.api.nvim_create_user_command( + 'SmartTabEdit', + function(opts) vimrc.fn.smart_tabedit(opts.mods, opts.args) end, + { + desc = 'Smartly open a file', + nargs = '*', + complete = 'file', + } +) @@ -1687,11 +1700,16 @@ nnoremap <silent> <Plug>(my-insert-blank-lines-before) G.rg_window_location = 'silent! echo' G.rg_jump_to_first = true -vim.cmd([[ -command! -bang -nargs=* -complete=file -bar - \ RG - \ Rg<bang> <args> -]]) +vim.api.nvim_create_user_command( + 'RG', + 'Rg<bang> <args>', + { + bang = true, + bar = true, + nargs = '*', + complete = 'file', + } +) -- rust {{{2 diff --git a/.config/nvim/plugin/autosave.lua b/.config/nvim/plugin/autosave.lua new file mode 100644 index 0000000..6725195 --- /dev/null +++ b/.config/nvim/plugin/autosave.lua @@ -0,0 +1,30 @@ +if vim.g.loaded_autosave then + return +end + +vim.api.nvim_create_user_command( + 'AutosaveEnable', + function() require('autosave').enable() end, + { + desc = '[Autosave] enable autosaving', + bar = true, + } +) +vim.api.nvim_create_user_command( + 'AutosaveDisable', + function() require('autosave').disable() end, + { + desc = '[Autosave] disable autosaving', + bar = true, + } +) +vim.api.nvim_create_user_command( + 'AutosaveToggle', + function() require('autosave').toggle() end, + { + desc = '[Autosave] toggle autosaving', + bar = true, + } +) + +vim.g.loaded_autosave = true diff --git a/.config/nvim/plugin/autosave.vim b/.config/nvim/plugin/autosave.vim deleted file mode 100644 index ab8a227..0000000 --- a/.config/nvim/plugin/autosave.vim +++ /dev/null @@ -1,21 +0,0 @@ -scriptencoding utf-8 - -if exists('g:loaded_autosave') - finish -endif - - -command! -bar - \ AutosaveEnable - \ lua require('autosave').enable() - -command! -bar - \ AutosaveDisable - \ lua require('autosave').disable() - -command! -bar - \ AutosaveToggle - \ lua require('autosave').toggle() - - -let g:loaded_autosave = 1 diff --git a/.config/nvim/plugin/leaf.vim b/.config/nvim/plugin/leaf.vim index 5d0d580..bc19053 100644 --- a/.config/nvim/plugin/leaf.vim +++ b/.config/nvim/plugin/leaf.vim @@ -9,14 +9,6 @@ nmap <Space> <Nop> nmap <Space>l (leaf) nnoremap (leaf) <Nop> -nnoremap (leaf)i <Cmd>SmartTabEdit ~/leaves/INBOX.leaf<CR> -nnoremap (leaf)t <Cmd>SmartTabEdit ~/leaves/TODO.leaf<CR> -nnoremap (leaf)c <Cmd>SmartTabEdit ~/leaves/CALENDAR.leaf<CR> -nnoremap (leaf)p <Cmd>SmartTabEdit ~/leaves/PROJECTS.leaf<CR> -nnoremap (leaf)s <Cmd>SmartTabEdit ~/leaves/SOMEDAY.leaf<CR> -nnoremap (leaf)r <Cmd>SmartTabEdit ~/leaves/REFS.leaf<CR> -nnoremap (leaf)A <Cmd>SmartTabEdit ~/leaves/ARCHIVES.leaf<CR> - nnoremap (leaf)l <Cmd>SmartTabEdit ~/leaves/INBOX.leaf <Bar>normal G<CR> @@ -2,8 +2,6 @@ nvim 0.7 https://github.com/neovim/neovim/releases/tag/v0.7.0 keymap - highlight - nvim_{add,del}_user_command newsboat Share "urls" file between machines without opening the content |
