nvim: update

This commit is contained in:
2023-01-14 23:01:17 +02:00
parent 6859e4ed76
commit e74b90556f
9 changed files with 234 additions and 145 deletions

View File

@@ -3,15 +3,22 @@
-- Description: Personal neovim configuration
local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g
local command = vim.api.nvim_create_user_command
require('impatient') -- Should be at the top
require('filetypes').config()
cmd [[packadd packer.nvim]]
local packer = require 'packer'
local packer = require('packer')
local use = packer.use
-- NB: Difference between config and setup (https://github.com/wbthomason/packer.nvim#specifying-plugins)
--
-- `config` - Specifies code to run after this plugin is loaded.
--
-- The setup key implies opt = true
-- `setup` - Specifies code to run before this plugin is loaded. The code is ran even if
-- the plugin is waiting for other conditions (ft, cond...) to be met.
packer.startup(function()
-- Lua
use { 'wbthomason/packer.nvim', opt = true }
@@ -19,10 +26,10 @@ packer.startup(function()
use 'nvim-lua/plenary.nvim'
use { 'shaunsingh/nord.nvim',
config = function()
require('plugins/nord').config()
require('plugins.nord').config()
end,
setup = function()
require('plugins/nord').setup()
require('plugins.nord').setup()
end
}
use {
@@ -31,7 +38,17 @@ packer.startup(function()
event = { 'BufRead', 'BufNewFile' },
config = function()
require('plugins/treesitter').config()
end
end,
requires = {
{
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter'
},
{
'nvim-treesitter/playground',
cmd = 'TSPlaygroundToggle',
}
}
}
use 'nvim-tree/nvim-tree.lua'
use 'numtostr/comment.nvim'
@@ -49,13 +66,13 @@ packer.startup(function()
end
}
use "jose-elias-alvarez/null-ls.nvim"
-- TODO: make sense of it
-- use "jose-elias-alvarez/null-ls.nvim"
-- Vimscript
use 'junegunn/vim-easy-align'
use 'christoomey/vim-tmux-navigator'
use 'airblade/vim-gitgutter'
use 'lewis6991/gitsigns.nvim'
-- tpope
use 'tpope/vim-surround'
@@ -68,12 +85,13 @@ packer.startup(function()
use 'vim-test/vim-test'
use 'benmills/vimux'
-- TODO: find lua replacement / or learn :grep / cfdo
use 'dyng/ctrlsf.vim'
use 'AndrewRadev/splitjoin.vim'
use 'andrewradev/splitjoin.vim'
use {
'VonHeikemen/lsp-zero.nvim',
'vonheikemen/lsp-zero.nvim',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'},
@@ -95,125 +113,20 @@ packer.startup(function()
}
use { "dstein64/vim-startuptime", cmd = "StartupTime" }
-- EXPERIMENTAL: trying out different plugins
use { 'phaazon/hop.nvim' }
end)
require('builtins')
require 'plugins/gitgutter'
require 'plugins/lsp'
require 'plugins/nord'
require 'plugins/nvim-tree'
require 'plugins/comment'
require 'plugins/mason'
require 'plugins/null-ls'
require 'plugins/telescope'
cmd('au TextYankPost * lua vim.highlight.on_yank { timeout = 250 }')
g.ruby_host_prog = 'asdf exec neovim-ruby-host'
opt.smartindent = true -- Autoindenting when starting a new line
opt.completeopt = {'menu', 'menuone', 'noselect'}
opt.tabstop = 2 -- Tab counts as 2 columns
opt.shiftwidth = 2 -- Numbers of spaces to (auto)indent
opt.expandtab = true -- Tabs to spaces
opt.clipboard = 'unnamedplus' -- Share clipboard with the OS
opt.number = true -- Display line numbers
opt.fillchars = {
vert = '', -- alternatives │
eob = ' ', -- suppress ~ at EndOfBuffer
msgsep = '',
diff = '',
fold = ' ',
foldopen = '',
foldsep = '',
foldclose = '',
}
opt.synmaxcol = 500 -- Do not try to highlight lines longer than 500 characters
opt.lazyredraw = true -- Do not redraw while running macros
opt.showmatch = true -- Show matching braces
opt.matchtime = 2 -- Show matching braces for 2 tenths of second
opt.showmode = true -- Shows when you are in insert mode
opt.title = true -- Show title in console status bar
opt.laststatus = 3 -- Single status line
opt.wrap = false -- Dont wrap lines
opt.scrolloff = 5 -- Keep 5 rows on the screen when scrolling
opt.sidescrolloff = 15 -- Horizontal scrolloff
opt.visualbell = false -- No visual bell
opt.backup = false -- No backups
opt.writebackup = false -- No backups
opt.swapfile = false -- No backups
opt.mouse = 'a' -- Support mouse (for proper mouse highlight)
opt.list = true -- List mode
opt.listchars = { trail = '·', tab = '->' }
opt.timeoutlen = 1000 -- Delay for mappings
opt.ttimeoutlen = 0 -- Delay between modes
opt.shellcmdflag = '-ilc' -- Enables aliases from .bashrc in :! commands
opt.termguicolors = true -- 24-bit RGB color
if vim.fn.executable('rg') > 0 then
vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]]
end
-- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes
opt.diffopt = vim.opt.diffopt
+ {
'vertical',
'iwhite',
'hiddenoff',
'foldcolumn:0',
'context:4',
'algorithm:histogram',
'indent-heuristic',
}
opt.shortmess = {
t = true, -- truncate file messages at start
A = true, -- ignore annoying swap file messages
o = true, -- file-read message overwrites previous
O = true, -- file-read message overwrites previous
T = true, -- truncate non-file messages in middle
f = true, -- (file x of x) instead of just (x of x
F = true, -- Don't give file info when editing a file, NOTE: this breaks autocommand messages
s = true,
I = true, -- disable welcome message (:intro)
a = true, -- shortmess for everything
c = true,
W = true, -- Don't show [w] or written when writing
}
-- ignore when autocompleting
opt.wildignore = {
'*.aux', '*.out', '*.toc', '*.o', '*.obj',
'*.dll', '*.jar', '*.pyc', '*.rbc', '*.class',
'*.gif', '*.ico', '*.jpg', '*.jpeg', '*.png',
'*.avi', '*.wav', '*.*~', '*~ ', '*.swp',
'.lock', '.DS_Store', 'tags.lock'
}
-- vim-test
g['test#strategy'] = 'neovim'
-- CtrlSF
g.ctrlsf_ackprg = 'rg'
g.ctrlsf_regex_pattern = 1
g.ctrlsf_case_sensitive = 'smart'
g.ctrlsf_default_root = 'project'
g.ctrlsf_context = '-B 1 -A 1'
g.ctrlsf_position = 'bottom'
g.ctrlsf_winsize = '40%'
g.ctrlsf_mapping = {
next = 'n',
prev = 'N',
}
local function trim_trailing_whitespace()
local pos = vim.api.nvim_win_get_cursor(0)
vim.cmd [[silent keepjumps keeppatterns %s/\s\+$//e]]
vim.api.nvim_win_set_cursor(0, pos)
end
command('TrimWhitespace', trim_trailing_whitespace, {})
-- vim.cmd("set shell='bash -l'")
require('plugins.gitgutter')
require('plugins.lsp')
require('plugins.nvim-tree')
require('plugins.comment')
require('plugins.gitsigns')
-- require('plugins.mason')
-- require('plugins.null-ls')
require('plugins.hop')
require('util')
require('settings')
require('mappings')

View File

@@ -0,0 +1 @@
require('gitsigns').setup()

View File

@@ -0,0 +1,17 @@
-- place this in one of your configuration file(s)
local hop = require('hop')
local directions = require('hop.hint').HintDirection
vim.keymap.set('', 'f', function()
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true })
end, {remap=true})
vim.keymap.set('', 'F', function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true })
end, {remap=true})
vim.keymap.set('', 't', function()
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true, hint_offset = -1 })
end, {remap=true})
vim.keymap.set('', 'T', function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 })
end, {remap=true})
require'hop'.setup { keys = 'etovxqpdygfblzhckisuran' }

View File

@@ -108,4 +108,3 @@ vim.diagnostic.config({
severity_sort = false,
float = true,
})

View File

@@ -1,3 +1,4 @@
-- TODO: figure this out
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
require("null-ls").setup({
sources = {

View File

@@ -26,6 +26,31 @@ function M.config()
autopairs = { enable = true },
autotag = { enable = true },
incremental_selection = { enable = true },
textobjects = { -- syntax-aware textobjects
select = {
enable = true,
disable = {},
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['aC'] = '@class.outer',
['iC'] = '@class.inner',
['ac'] = '@conditional.outer',
['ic'] = '@conditional.inner',
['ab'] = '@block.outer',
['ib'] = '@block.inner',
['al'] = '@loop.outer',
['il'] = '@loop.inner',
['is'] = '@statement.inner',
['as'] = '@statement.outer',
['am'] = '@call.outer',
['im'] = '@call.inner',
['ad'] = '@comment.outer',
['id'] = '@comment.inner',
},
},
}
}
end

View File

@@ -0,0 +1,102 @@
local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g
local command = vim.api.nvim_create_user_command
cmd('au TextYankPost * lua vim.highlight.on_yank { timeout = 250 }')
g.ruby_host_prog = 'asdf exec neovim-ruby-host'
opt.smartindent = true -- Autoindenting when starting a new line
opt.completeopt = {'menu', 'menuone', 'noselect'}
opt.tabstop = 2 -- Tab counts as 2 columns
opt.shiftwidth = 2 -- Numbers of spaces to (auto)indent
opt.expandtab = true -- Tabs to spaces
opt.clipboard = 'unnamedplus' -- Share clipboard with the OS
opt.number = true -- Display line numbers
opt.fillchars = {
vert = '', -- alternatives │
eob = ' ', -- suppress ~ at EndOfBuffer
msgsep = '',
diff = '',
fold = ' ',
foldopen = '',
foldsep = '',
foldclose = '',
}
opt.synmaxcol = 500 -- Do not try to highlight lines longer than 500 characters
opt.lazyredraw = true -- Do not redraw while running macros
opt.showmatch = true -- Show matching braces
opt.matchtime = 2 -- Show matching braces for 2 tenths of second
opt.showmode = true -- Shows when you are in insert mode
opt.title = true -- Show title in console status bar
opt.laststatus = 3 -- Single status line
opt.wrap = false -- Dont wrap lines
opt.scrolloff = 5 -- Keep 5 rows on the screen when scrolling
opt.sidescrolloff = 15 -- Horizontal scrolloff
opt.visualbell = false -- No visual bell
opt.backup = false -- No backups
opt.writebackup = false -- No backups
opt.swapfile = false -- No backups
opt.mouse = 'a' -- Support mouse (for proper mouse highlight)
opt.list = true -- List mode
opt.listchars = { trail = '·', tab = '->' }
opt.timeoutlen = 1000 -- Delay for mappings
opt.ttimeoutlen = 0 -- Delay between modes
opt.shellcmdflag = '-ilc' -- Enables aliases from .bashrc in :! commands
opt.termguicolors = true -- 24-bit RGB color
if vim.fn.executable('rg') > 0 then
vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]]
end
-- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes
opt.diffopt = vim.opt.diffopt
+ {
'vertical',
'iwhite',
'hiddenoff',
'foldcolumn:0',
'context:4',
'algorithm:histogram',
'indent-heuristic',
}
opt.shortmess = {
t = true, -- truncate file messages at start
A = true, -- ignore annoying swap file messages
o = true, -- file-read message overwrites previous
O = true, -- file-read message overwrites previous
T = true, -- truncate non-file messages in middle
f = true, -- (file x of x) instead of just (x of x
F = true, -- Don't give file info when editing a file, NOTE: this breaks autocommand messages
s = true,
I = true, -- disable welcome message (:intro)
a = true, -- shortmess for everything
c = true,
W = true, -- Don't show [w] or written when writing
}
-- ignore when autocompleting
opt.wildignore = {
'*.aux', '*.out', '*.toc', '*.o', '*.obj',
'*.dll', '*.jar', '*.pyc', '*.rbc', '*.class',
'*.gif', '*.ico', '*.jpg', '*.jpeg', '*.png',
'*.avi', '*.wav', '*.*~', '*~ ', '*.swp',
'.lock', '.DS_Store', 'tags.lock'
}
-- vim-test
g['test#strategy'] = 'neovim'
-- CtrlSF
g.ctrlsf_ackprg = 'rg'
g.ctrlsf_regex_pattern = 1
g.ctrlsf_case_sensitive = 'smart'
g.ctrlsf_default_root = 'project'
g.ctrlsf_context = '-B 1 -A 1'
g.ctrlsf_position = 'bottom'
g.ctrlsf_winsize = '40%'
g.ctrlsf_mapping = {
next = 'n',
prev = 'N',
}

View File

@@ -0,0 +1,6 @@
local function trim_trailing_whitespace()
local pos = vim.api.nvim_win_get_cursor(0)
vim.cmd [[silent keepjumps keeppatterns %s/\s\+$//e]]
vim.api.nvim_win_set_cursor(0, pos)
end
vim.api.nvim_create_user_command('TrimWhitespace', trim_trailing_whitespace, {})

View File

@@ -119,11 +119,21 @@ _G.packer_plugins = {
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/friendly-snippets",
url = "https://github.com/rafamadriz/friendly-snippets"
},
["gitsigns.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
url = "https://github.com/lewis6991/gitsigns.nvim"
},
["glow.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/glow.nvim",
url = "https://github.com/ellisonleao/glow.nvim"
},
["hop.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/hop.nvim",
url = "https://github.com/phaazon/hop.nvim"
},
["impatient.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/impatient.nvim",
@@ -132,7 +142,7 @@ _G.packer_plugins = {
["lsp-zero.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim",
url = "https://github.com/VonHeikemen/lsp-zero.nvim"
url = "https://github.com/vonheikemen/lsp-zero.nvim"
},
["mason-lspconfig.nvim"] = {
loaded = true,
@@ -145,17 +155,12 @@ _G.packer_plugins = {
url = "https://github.com/williamboman/mason.nvim"
},
["nord.nvim"] = {
config = { "\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins/nord\frequire\0" },
config = { "\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins.nord\frequire\0" },
loaded = true,
needs_bufread = false,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nord.nvim",
url = "https://github.com/shaunsingh/nord.nvim"
},
["null-ls.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/null-ls.nvim",
url = "https://github.com/jose-elias-alvarez/null-ls.nvim"
},
["nvim-cmp"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/nvim-cmp",
@@ -172,6 +177,7 @@ _G.packer_plugins = {
url = "https://github.com/nvim-tree/nvim-tree.lua"
},
["nvim-treesitter"] = {
after = { "nvim-treesitter-textobjects" },
config = { "\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\23plugins/treesitter\frequire\0" },
loaded = false,
needs_bufread = false,
@@ -179,12 +185,29 @@ _G.packer_plugins = {
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-treesitter-textobjects"] = {
load_after = {
["nvim-treesitter"] = true
},
loaded = false,
needs_bufread = false,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-textobjects",
url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"
},
["packer.nvim"] = {
loaded = false,
needs_bufread = false,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
playground = {
commands = { "TSPlaygroundToggle" },
loaded = false,
needs_bufread = true,
only_cond = false,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/playground",
url = "https://github.com/nvim-treesitter/playground"
},
["plenary.nvim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/plenary.nvim",
@@ -193,7 +216,7 @@ _G.packer_plugins = {
["splitjoin.vim"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/splitjoin.vim",
url = "https://github.com/AndrewRadev/splitjoin.vim"
url = "https://github.com/andrewradev/splitjoin.vim"
},
["telescope-fzf-native.nvim"] = {
cond = { true },
@@ -221,11 +244,6 @@ _G.packer_plugins = {
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-fugitive",
url = "https://github.com/tpope/vim-fugitive"
},
["vim-gitgutter"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-gitgutter",
url = "https://github.com/airblade/vim-gitgutter"
},
["vim-rails"] = {
loaded = true,
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-rails",
@@ -306,14 +324,14 @@ try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K
time([[Setup for telescope.nvim]], false)
-- Setup for: nord.nvim
time([[Setup for nord.nvim]], true)
try_loadstring("\27LJ\2\n:\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\17plugins/nord\frequire\0", "setup", "nord.nvim")
try_loadstring("\27LJ\2\n:\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\17plugins.nord\frequire\0", "setup", "nord.nvim")
time([[Setup for nord.nvim]], false)
time([[packadd for nord.nvim]], true)
vim.cmd [[packadd nord.nvim]]
time([[packadd for nord.nvim]], false)
-- Config for: nord.nvim
time([[Config for nord.nvim]], true)
try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins/nord\frequire\0", "config", "nord.nvim")
try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins.nord\frequire\0", "config", "nord.nvim")
time([[Config for nord.nvim]], false)
-- Conditional loads
time([[Conditional loading of telescope-fzf-native.nvim]], true)
@@ -322,11 +340,18 @@ time([[Conditional loading of telescope-fzf-native.nvim]], false)
-- Command lazy-loads
time([[Defining lazy-load commands]], true)
pcall(vim.api.nvim_create_user_command, 'TSPlaygroundToggle', function(cmdargs)
require('packer.load')({'playground'}, { cmd = 'TSPlaygroundToggle', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
end,
{nargs = '*', range = true, bang = true, complete = function()
require('packer.load')({'playground'}, {}, _G.packer_plugins)
return vim.fn.getcompletion('TSPlaygroundToggle ', 'cmdline')
end})
pcall(vim.api.nvim_create_user_command, 'StartupTime', function(cmdargs)
require('packer.load')({'vim-startuptime'}, { cmd = 'StartupTime', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
end,
{nargs = '*', range = true, bang = true, complete = function()
require('packer.load')({'vim-startuptime'}, { cmd = 'StartupTime' }, _G.packer_plugins)
require('packer.load')({'vim-startuptime'}, {}, _G.packer_plugins)
return vim.fn.getcompletion('StartupTime ', 'cmdline')
end})
time([[Defining lazy-load commands]], false)