diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index 166eb4b..058625d 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -32,7 +32,7 @@ local function hi(group, guifg, guibg, attr, guisp) local sp = guisp ~= '' and 'guisp=' .. guisp or '' local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp - vim.cmd(hl) + vim.api.nvim_command(hl) end -- Set terminal colors @@ -172,14 +172,14 @@ local function highlight_syntax() hi('Todo', c.yellow, '', '', '') hi('Type', c.blue, '', '', '') hi('Typedef', c.blue, '', '', '') - vim.cmd('hi! link Annotation Decorator') - vim.cmd('hi! link Macro Define') - vim.cmd('hi! link PreCondit PreProc') - vim.cmd('hi! link Variable Identifier') + vim.api.nvim_command('hi! link Annotation Decorator') + vim.api.nvim_command('hi! link Macro Define') + vim.api.nvim_command('hi! link PreCondit PreProc') + vim.api.nvim_command('hi! link Variable Identifier') -- sql - vim.cmd('hi! link sqlKeyword Keyword') - vim.cmd('hi! link sqlSpecial Keyword') + vim.api.nvim_command('hi! link sqlKeyword Keyword') + vim.api.nvim_command('hi! link sqlSpecial Keyword') -- Diff hi('DiffAdd' , c.green , c.grey1, '', '') @@ -192,9 +192,9 @@ local function highlight_syntax() hi('diffFile', c.cyan, c.grey1, '', '') hi('diffLine', c.purple, c.grey1, '', '') hi('diffIndexLine', c.fg, c.grey1, '', '') - vim.cmd('hi! link diffAdded DiffAdd') - vim.cmd('hi! link diffRemoved DiffDelete') - vim.cmd('hi! link diffChanged DiffChange') + vim.api.nvim_command('hi! link diffAdded DiffAdd') + vim.api.nvim_command('hi! link diffRemoved DiffDelete') + vim.api.nvim_command('hi! link diffChanged DiffChange') end -- Treesitter @@ -241,13 +241,13 @@ local function highlight_treesitter() hi('TSURI', c.fg, '', '', '') hi('TSTag', c.blue, '', '', '') hi('TSTagDelimiter', c.fg, '', '', '') - vim.cmd('hi! link TSAnnotation Annotation') - vim.cmd('hi! link TSConstructor Function') - -- vim.cmd('hi! link TSError Error') - vim.cmd('hi! link TSFuncBuiltin Function') - vim.cmd('hi! link TSFunction Function') - vim.cmd('hi! link TSFuncMacro Function') - vim.cmd('hi! link TSVariable Variable') + vim.api.nvim_command('hi! link TSAnnotation Annotation') + vim.api.nvim_command('hi! link TSConstructor Function') + -- vim.api.nvim_command('hi! link TSError Error') + vim.api.nvim_command('hi! link TSFuncBuiltin Function') + vim.api.nvim_command('hi! link TSFunction Function') + vim.api.nvim_command('hi! link TSFuncMacro Function') + vim.api.nvim_command('hi! link TSVariable Variable') end -- LSP groups @@ -279,7 +279,7 @@ local function highlight_lsp() hi('LspReferenceText', c.fg, c.grey_bright, '', '') hi('LspReferenceRead', c.fg, c.grey_bright, '', '') hi('LspReferenceWrite', c.fg, c.grey_bright, '', '') - vim.cmd('hi! link LspCodeLens Comment') + vim.api.nvim_command('hi! link LspCodeLens Comment') end -- Specify groups for plugins @@ -344,7 +344,7 @@ local function highlight_plugins() hi('IndentBlanklineContextChar', c.grey1, '', '', '') -- vim-illuminate - vim.cmd('hi! link illuminatedWord Underline') + vim.api.nvim_command('hi! link illuminatedWord Underline') -- trouble.nvim hi('LspTroubleText', c.blue, '', 'bold', '') @@ -374,8 +374,8 @@ end -- Main function function M.highlight() -- Reset everything - vim.cmd('hi clear') - if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end + vim.api.nvim_command('hi clear') + if vim.fn.exists('syntax_on') then vim.api.nvim_command('syntax reset') end vim.o.background = 'dark' -- Load highlight groups diff --git a/home/.config/nvim/lua/colors/onedark.lua b/home/.config/nvim/lua/colors/onedark.lua index c9c91da..d797127 100644 --- a/home/.config/nvim/lua/colors/onedark.lua +++ b/home/.config/nvim/lua/colors/onedark.lua @@ -7,7 +7,7 @@ local function hi(group, guifg, guibg, attr, guisp) local sp = guisp ~= '' and 'guisp=' .. guisp or '' local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp - vim.cmd(hl) + vim.api.nvim_command(hl) end M.colors = { diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 98d1e08..fd157d2 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -66,14 +66,14 @@ wk.register({ [''] = { function() if vim.o.expandtab == true then - vim.cmd('set noexpandtab nosmarttab softtabstop& shiftwidth&') - vim.cmd('echomsg "Switched to indent with tabs"') + vim.api.nvim_command('set noexpandtab nosmarttab softtabstop& shiftwidth&') + vim.api.nvim_command('echomsg "Switched to indent with tabs"') else vim.opt.expandtab = true vim.opt.smarttab = true vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4 - vim.cmd('echomsg "Switched to indent with 4 spaces"') + vim.api.nvim_command('echomsg "Switched to indent with 4 spaces"') end end, 'Switch indent style' @@ -290,11 +290,11 @@ wk.register({ ------------------------ -- Filetype specified -- ------------------------ -vim.cmd(([[ +vim.api.nvim_command [[ autocmd FileType org lua whichkeyOrg() autocmd FileType markdown lua whichkeyMarkdown() autocmd FileType html lua whichkeyHtml() -]])) +]] _G.whichkeyOrg = function() wk.register({ diff --git a/home/.config/nvim/lua/modules/completion.lua b/home/.config/nvim/lua/modules/completion.lua index bee5d68..fbdecdb 100644 --- a/home/.config/nvim/lua/modules/completion.lua +++ b/home/.config/nvim/lua/modules/completion.lua @@ -4,13 +4,9 @@ function M.cmp_conf() local cmp = require('cmp') local luasnip = require('luasnip') - local check_back_space = function() - local col = vim.fn.col '.' - 1 - return col == 0 or vim.fn.getline('.'):sub(col, col):match '%s' ~= nil - end - - local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) + local has_words_before = function() + local cursor = vim.api.nvim_win_get_cursor(0) + return not vim.api.nvim_get_current_line():sub(1, cursor[2]):match('^%s$') end cmp.setup { @@ -73,14 +69,14 @@ function M.cmp_conf() -- Change choice nodes for luasnip [''] = cmp.mapping(function(fallback) if luasnip.choice_active() then - vim.fn.feedkeys(t('luasnip-prev-choice'), '') + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-prev-choice', true, true, true), '') else fallback() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) if luasnip.choice_active() then - vim.fn.feedkeys(t('luasnip-next-choice'), '') + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-next-choice', true, true, true), '') else fallback() end @@ -88,20 +84,18 @@ function M.cmp_conf() -- supertab-like mapping [''] = cmp.mapping(function(fallback) if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(t(''), 'n') - elseif luasnip.expand_or_jumpable() then - vim.fn.feedkeys(t('luasnip-expand-or-jump'), '') - elseif check_back_space() then - vim.fn.feedkeys(t(''), 'n') + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n', true) + elseif has_words_before() and luasnip.expand_or_jumpable() then + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '') else fallback() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(t(''), 'n') + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n', true) elseif luasnip.jumpable(-1) then - vim.fn.feedkeys(t('luasnip-jump-prev'), '') + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '', true) else fallback() end diff --git a/home/.config/nvim/lua/modules/editor.lua b/home/.config/nvim/lua/modules/editor.lua index 18cece7..5d3e706 100644 --- a/home/.config/nvim/lua/modules/editor.lua +++ b/home/.config/nvim/lua/modules/editor.lua @@ -62,7 +62,7 @@ function M.blankline_conf() } -- Refresh often, since it is lazy-loaded - -- vim.cmd('autocmd CursorMoved * IndentBlanklineRefresh') + -- vim.api.nvim_command('autocmd CursorMoved * IndentBlanklineRefresh') end function M.treesitter_conf() diff --git a/home/.config/nvim/lua/modules/lsp.lua b/home/.config/nvim/lua/modules/lsp.lua index 80536a1..1f425e0 100644 --- a/home/.config/nvim/lua/modules/lsp.lua +++ b/home/.config/nvim/lua/modules/lsp.lua @@ -226,7 +226,7 @@ function M.lint_conf() } -- TODO: custom cmds for linters installed with pip (using virtualenv) -- vint, pylint, flake8, pycodestyle, codespell - vim.cmd [[ au BufRead,BufWritePost * lua require('lint').try_lint() ]] + vim.api.nvim_command [[ au BufRead,BufWritePost * lua require('lint').try_lint() ]] end function M.dap_conf() diff --git a/home/.config/nvim/lua/modules/tools.lua b/home/.config/nvim/lua/modules/tools.lua index 166081c..56cff64 100644 --- a/home/.config/nvim/lua/modules/tools.lua +++ b/home/.config/nvim/lua/modules/tools.lua @@ -104,12 +104,12 @@ function M.zenmode_conf() } }, on_open = function() - vim.cmd('TSContextDisable') - vim.cmd('IndentBlanklineDisable') + vim.api.nvim_command('TSContextDisable') + vim.api.nvim_command('IndentBlanklineDisable') end, on_close = function() - vim.cmd('TSContextEnable') - -- vim.cmd('IndentBlanklineEnable') + vim.api.nvim_command('TSContextEnable') + -- vim.api.nvim_command('IndentBlanklineEnable') end } end @@ -202,11 +202,11 @@ function M.toggleterm_conf() end function M.wilder_conf() - vim.cmd [[ call wilder#setup({'modes': [':', '/', '?']}) ]] + vim.api.nvim_command [[ call wilder#setup({'modes': [':', '/', '?']}) ]] -- Doesn't work yet. Bugs in Neovim (see neovim/neovim#14809 and gelguy/wilder.nvim#53) -- so can't do multi-line config inside vim.cmd [[ ]] with \ --- vim.cmd [[ +-- vim.api.nvim_command [[ -- call wilder#set_option('renderer', wilder#renderer_mux({ -- \ ':': wilder#popupmenu_renderer({ -- \ 'highlighter': wilder#basic_highlighter(), @@ -221,7 +221,7 @@ function M.wilder_conf() -- \ })) -- ]] --- vim.cmd [[ +-- vim.api.nvim_command [[ -- call wilder#set_option('pipeline', [ -- \ wilder#branch( -- \ wilder#python_file_finder_pipeline({ diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 079b131..e68b71a 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -7,7 +7,7 @@ if fn.empty(fn.glob(packer_dir)) > 0 then end -- Require since we use 'packer' as opt -vim.cmd [[packadd packer.nvim]] +api.nvim_command [[packadd packer.nvim]] return require('packer').startup( function(use) @@ -46,7 +46,7 @@ return require('packer').startup( } use { 'akinsho/nvim-bufferline.lua', - event = 'BufRead', + event = {'BufRead', 'BufNewFile'}, config = ui.bufferline_conf } use { diff --git a/home/.local/bin/news b/home/.local/bin/news deleted file mode 100755 index 4b8a6b5..0000000 --- a/home/.local/bin/news +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -curl "getnews.tech/$1"