neovim: configure packer.nvim + add iswap.nvim

This commit is contained in:
FollieHiyuki 2021-09-28 16:43:50 +07:00
parent a8e3fb728b
commit dfcfbd004a
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
15 changed files with 670 additions and 523 deletions

View File

@ -1,2 +1,3 @@
setlocal spell
setlocal wrap
" setlocal nonumber norelativenumber

View File

@ -1,2 +1,3 @@
setlocal spell
setlocal wrap
" setlocal nonumber norelativenumber

View File

@ -2,7 +2,7 @@ local async
async = vim.loop.new_async(vim.schedule_wrap(function()
require('plugins')
require('mappings')
require('events').load_autocmds()
require('autocmd')
async:close()
end))

View File

@ -0,0 +1,49 @@
local definitions = {
-- ':h hex-editing'
binary = {
{'BufReadPre' , '*.bin,*.exe', 'let &bin=1'},
{'BufReadPost' , '*.bin,*.exe', 'if &bin | %!xxd'},
{'BufReadPost' , '*.bin,*.exe', 'set ft=xxd | endif'},
{'BufWritePre' , '*.bin,*.exe', 'if &bin | %!xxd -r'},
{'BufWritePre' , '*.bin,*.exe', 'endif'},
{'BufWritePost', '*.bin,*.exe', 'if &bin | %!xxd'},
{'BufWritePost', '*.bin,*.exe', 'set nomod | endif'}
},
-- Auto-hide UI elements in specific buffers
buf = {
{'BufEnter', 'term://*', 'setlocal norelativenumber nonumber'},
-- {'BufEnter,BufWinEnter,WinEnter,CmdwinEnter', '*', [[if bufname('%') == 'NvimTree' | set laststatus=0 | else | set laststatus=2 | endif]]}
},
wins = {
-- Equalize window dimensions when resizing vim window
{'VimResized', '*', 'tabdo wincmd ='},
-- Force writing shada on leaving nvim
{'VimLeave', '*', [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread'
{'FocusGained', '* checktime'}
},
ft = {
{'BufNewFile,BufRead', '*.md,*.mkd', 'setfiletype markdown'},
{'BufNewFile,BufRead', '*.toml', 'setfiletype toml'},
{'BufNewFile,BufRead', '*.rasi', 'setfiletype css'},
{'BufNewFile,BufRead', 'vifmrc,*.vifm', 'setfiletype vim'},
{'BufNewFile,BufRead', '*.log,*_log,*.LO,G*_LOG', 'setfiletype log'}
},
yank = {
{'TextYankPost', [[* silent! lua vim.highlight.on_yank({higroup='IncSearch', timeout=300})]]}
}
}
for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup ' .. group_name)
vim.api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
vim.api.nvim_command(command)
end
vim.api.nvim_command('augroup END')
end

View File

@ -297,22 +297,15 @@ local function highlight_plugins()
hi('rainbowcol6', c.blue, '', 'bold', '')
hi('rainbowcol7', c.purple, '', 'bold', '')
-- todo-comments
hi('TodoDefault', c.fg, '', 'bold', '')
hi('TodoError', c.red, '', 'bold', '')
hi('TodoWarn', c.yellow, '', 'bold', '')
hi('TodoInfo', c.blue, '', 'bold', '')
hi('TodoHint', c.cyan, '', 'bold', '')
-- hop.nvim
hi('HopNextKey', c.red, '', 'bold', '')
hi('HopNextKey1', c.cyan, '', 'bold', '')
hi('HopNextKey2', c.dark_blue, '', '', '')
hi('HopUnmatched', c.grey3, '', '', '')
vim.api.nvim_command('hi! link HopUnmatched LineNr')
-- vim-eft
hi('EftChar' , c.orange, '', 'bold,underline', '')
hi('EftSubChar', c.grey3, '', 'bold,underline', '')
hi('EftChar', c.orange, '', 'bold,underline', '')
vim.api.nvim_command('hi! link EftSubChar LineNr')
-- dashboard-nvim / alpha-nvim
hi('DashboardHeader' , c.blue , '', 'bold' , '')

View File

@ -1,86 +0,0 @@
local plug_dir = vim.fn.stdpath('config') .. '/lua'
local M = {}
function M.packer_compile()
local file = vim.fn.expand('%:p')
if file:match(plug_dir) then
vim.api.nvim_command('source <afile> | PackerCompile')
end
end
function M.nvim_create_augroups(definitions)
for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup ' .. group_name)
vim.api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
vim.api.nvim_command(command)
end
vim.api.nvim_command('augroup END')
end
end
function M.load_autocmds()
local definitions = {
plugins = {
-- Wrap lines in preview window
-- {"User TelescopePreviewerLoaded", [[setlocal wrap]]},
-- Re-compile packer on config changed
{"BufWritePost", "*.lua", "lua require('events').packer_compile()"},
-- Register binding for ToggleTerm inside term mode
{"TermEnter", "term://*toggleterm#*", "tnoremap <silent><C-\\> <C-\\><C-n>:ToggleTerm<CR>"}
},
-- Edit binary files in hex with xxd (:%!xxd and :%!xxd -r)
-- or using nvim -b to edit files using xxd-format
binary = {
{"BufReadPre" , "*.bin,*.exe", "let &bin=1"},
{"BufReadPost" , "*.bin,*.exe", "if &bin | %!xxd"},
{"BufReadPost" , "*.bin,*.exe", "set ft=xxd | endif"},
{"BufWritePre" , "*.bin,*.exe", "if &bin | %!xxd -r"},
{"BufWritePre" , "*.bin,*.exe", "endif"},
{"BufWritePost", "*.bin,*.exe", "if &bin | %!xxd"},
{"BufWritePost", "*.bin,*.exe", "set nomod | endif"}
},
buf = {
-- Auto-spelling in doc files
{"BufNewFile,BufRead", "*.md,*.mkd", "setlocal spell"},
{"BufNewFile,BufRead", "*.tex", "setlocal spell"},
-- Auto-hide numbers, statusline in specific buffers
-- {"BufEnter", "term://*", "setlocal norelativenumber nonumber"},
-- {"BufEnter", "term://*", "set laststatus=0"},
-- {"BufEnter,BufWinEnter,WinEnter,CmdwinEnter", "*", [[if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif]]}
},
wins = {
-- Equalize window dimensions when resizing vim window
{"VimResized", "*", [[tabdo wincmd =]]},
-- Force writing shada on leaving nvim
{"VimLeave", "*", [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread'
{"FocusGained", "* checktime"}
},
ft = {
{"BufNewFile,BufRead", "*.md,*.mkd", "setfiletype markdown"},
{"BufNewFile,BufRead", "*.toml", "setfiletype toml"},
{"BufNewFile,BufRead", "*.rasi", "setfiletype css"},
{"BufNewFile,BufRead", "vifmrc,*.vifm", "setfiletype vim"},
{"BufNewFile,BufRead", "*.log,*_log,*.LO,G*_LOG", "setfiletype log"}
},
yank = {
{"TextYankPost", [[* silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=300})]]}
}
}
M.nvim_create_augroups(definitions)
end
return M

View File

@ -52,10 +52,10 @@ wk.register({
L = {'$', 'End of the line'},
-- Easier moving between windows
['<C-h>'] = {'<C-w>h', 'Go to the left window'},
['<C-l>'] = {'<C-w>l', 'Go to the right window'},
['<C-j>'] = {'<C-w>j', 'Go to the down window'},
['<C-k>'] = {'<C-w>k', 'Go to the up window'},
-- ['<C-h>'] = {'<C-w>h', 'Go to the left window'},
-- ['<C-l>'] = {'<C-w>l', 'Go to the right window'},
-- ['<C-j>'] = {'<C-w>j', 'Go to the down window'},
-- ['<C-k>'] = {'<C-w>k', 'Go to the up window'},
['<C-q>'] = {'<C-w>q', 'Quit a window'},
-- Copy the whole buffer
@ -133,7 +133,11 @@ wk.register({
-- Normal mode (with leader key) --
-----------------------------------
wk.register({
a = {':EasyAlign<CR>', 'Align'},
a = {
name = 'Action',
a = {':EasyAlign<CR>', 'Align elements'},
s = {':ISwapWith<CR>', 'Swap elements'}
},
b = {
name = 'Buffer/Tab',
@ -315,7 +319,10 @@ wk.register({
-- Visual mode (with leader key) --
-----------------------------------
wk.register({
a = {':EasyAlign<CR>', 'Range align'},
a = {
name = 'Action',
a = {':EasyAlign<CR>', 'Range align'}
},
d = {
name = 'DAP',

View File

@ -54,7 +54,7 @@ function M.cmp_conf()
nvim_lsp = '[LSP]',
-- cmp_tabnine = '[TN]',
latex_symbols = '[TEX]',
tmux = '[TMUX]',
-- tmux = '[TMUX]',
orgmode = '[ORG]'
})[entry.source.name]
@ -121,7 +121,7 @@ function M.cmp_conf()
-- {name = 'cmp_tabnine'},
{name = 'conjure'},
{name = 'latex_symbols'},
{name = 'tmux'},
-- {name = 'tmux'},
{name = 'orgmode'}
}
}

View File

@ -66,6 +66,7 @@ function M.treesitter_conf()
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
['af'] = '@function.outer',
['if'] = '@function.inner',
@ -98,6 +99,34 @@ function M.treesitter_conf()
}
end
function M.iswap_conf()
require('iswap').setup {
-- The keys that will be used as a selection, in order
-- ('asdfghjklqwertyuiopzxcvbnm' by default)
-- keys = 'qwertyuiop',
-- Grey out the rest of the text when making a selection
-- (enabled by default)
-- grey = 'disable',
-- Highlight group for the sniping value (asdf etc.)
-- default 'Search'
-- hl_snipe = 'ErrorMsg',
-- Highlight group for the visual selection of terms
-- default 'Visual'
-- hl_selection = 'WarningMsg',
-- Highlight group for the greyed background
-- default 'Comment'
hl_grey = 'LineNr',
-- Automatically swap with only two arguments
-- default nil
autoswap = true
}
end
function M.rainbow_conf()
require('nvim-treesitter.configs').setup {
rainbow = {

View File

@ -228,11 +228,11 @@ end
-- exclude = {'org'}, -- list of file types to exclude highlighting
-- },
-- colors = {
-- error = {'TodoError', 'Red'},
-- warning = {'TodoWarn', 'Yellow'},
-- info = {'TodoInfo', 'Blue'},
-- hint = {'TodoHint', 'Cyan'},
-- default = {'TodoDefault', 'White'}
-- error = {'LspDiagnosticsDefaultError', 'Red'},
-- warning = {'LspDiagnosticsDefaultWarning', 'Yellow'},
-- info = {'LspDiagnosticsDefaultInformation', 'Blue'},
-- hint = {'LspDiagnosticsDefaultHint', 'Cyan'},
-- default = {'Normal', 'White'}
-- },
-- search = {
-- command = 'rg',

View File

@ -0,0 +1,65 @@
local fn, api = vim.fn, vim.api
-- Require since we use 'packer' as opt
api.nvim_command('packadd packer.nvim')
local present, packer = pcall(require, 'packer')
if not present then
local packer_dir = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
print('Cloning packer ...')
-- remove packer_dir before cloning
fn.delete(packer_dir, 'rf')
fn.system {'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_dir}
api.nvim_command('packadd packer.nvim')
present, packer = pcall(require, 'packer')
if present then
print('Pakcer cloned successfully.')
else
error('Git clone error for packer!')
end
end
local util = require('packer.util')
packer.init {
compile_path = util.join_paths(fn.stdpath('data'), 'site', 'plugin', 'packer_compiled.lua'),
auto_clean = true,
compile_on_sync = true,
auto_reload_compiled = true,
git = {
-- default_url_format = 'https://github.com/%s',
clone_timeout = 120
},
display = {
-- open_fn = function()
-- return util.float {border = 'single'}
-- end,
open_cmd = '60vnew \\[packer\\]',
working_sym = '',
error_sym = '',
done_sym = '',
removed_sym = '-',
moved_sym = '',
header_sym = '',
show_all_info = true,
prompt_boder = 'single'
},
-- profile = {enable = true, threshold = 1},
luarocks = {python_cmd = 'python3'}
}
-- Re-compile packer on config changed
_G.packer_compile_on_save = function()
local file = fn.expand('%:p')
local filename = fn.expand('%:p:t')
local config_dir = fn.stdpath('config') .. '/lua'
if file:match(config_dir) and filename ~= 'pack.lua' then
vim.api.nvim_command('source <afile> | PackerCompile')
end
end
api.nvim_command('autocmd BufWritePost *.lua lua packer_compile_on_save()')
return packer

View File

@ -46,6 +46,9 @@ function M.telescope_conf()
require('telescope').load_extension('projects')
require('telescope').load_extension('project')
require('telescope').load_extension('fzf')
-- wrap lines inside preview pane
vim.api.nvim_command('autocmd User TelescopePreviewerLoaded setlocal wrap')
end
function M.octo_conf()

View File

@ -1,403 +1,404 @@
local fn,api = vim.fn,vim.api
local packer_dir = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
local packer = require('modules.pack')
if fn.empty(fn.glob(packer_dir)) > 0 then
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_dir})
api.nvim_command('packadd packer.nvim')
end
-- This is recommended when using `luafile <afile>` a lot
-- packer.reset()
-- Require since we use 'packer' as opt
api.nvim_command [[packadd packer.nvim]]
return packer.startup(function(use)
use {'wbthomason/packer.nvim', opt = true}
return require('packer').startup(
function(use)
use {'wbthomason/packer.nvim', opt = true}
---------------------------------
-- Plugins used by many others --
---------------------------------
use {'kyazdani42/nvim-web-devicons', module = 'nvim-web-devicons'}
use {'nvim-lua/plenary.nvim', module = 'plenary'}
use {'nvim-lua/popup.nvim', module = 'popup'}
---------------------------------
-- Plugins used by many others --
---------------------------------
use {'kyazdani42/nvim-web-devicons', module = 'nvim-web-devicons'}
use {'nvim-lua/plenary.nvim', module = 'plenary'}
use {'nvim-lua/popup.nvim', module = 'popup'}
--------
-- UI --
--------
local ui = require('modules.ui')
use {
'goolord/alpha-nvim',
event = 'VimEnter',
config = ui.dashboard_conf
}
use {
'famiu/feline.nvim',
wants = 'nvim-web-devicons',
config = ui.statusline_conf
}
use {
'akinsho/bufferline.nvim',
event = {'BufRead', 'BufNewFile'},
config = ui.bufferline_conf
}
use {
'kyazdani42/nvim-tree.lua',
cmd = 'NvimTreeToggle',
setup = ui.nvimtree_conf,
-- FIX: when all the options are migrated to setup()
config = function()
require('nvim-tree').setup {
open_on_setup = false,
auto_close = true,
hijack_cursor = true,
update_cwd = true,
lsp_diagnostics = true,
view = {
auto_resize = false
}
--------
-- UI --
--------
local ui = require('modules.ui')
use {
'goolord/alpha-nvim',
event = 'VimEnter',
config = ui.dashboard_conf
}
use {
'famiu/feline.nvim',
wants = 'nvim-web-devicons',
config = ui.statusline_conf
}
use {
'akinsho/bufferline.nvim',
event = {'BufRead', 'BufNewFile'},
config = ui.bufferline_conf
}
use {
'kyazdani42/nvim-tree.lua',
cmd = 'NvimTreeToggle',
setup = ui.nvimtree_conf,
-- FIX: when all the options are migrated to setup()
config = function()
require('nvim-tree').setup {
open_on_setup = false,
auto_close = true,
hijack_cursor = true,
update_cwd = true,
lsp_diagnostics = true,
view = {
auto_resize = false
}
end
}
use {
'folke/which-key.nvim',
event = 'VimEnter',
config = ui.whichkey_conf
}
use {
'lewis6991/gitsigns.nvim',
event = {'BufRead', 'BufNewFile'},
wants = 'plenary.nvim',
config = ui.gitsigns_conf
}
}
end
}
use {
'folke/which-key.nvim',
event = 'VimEnter',
config = ui.whichkey_conf
}
use {
'lewis6991/gitsigns.nvim',
event = {'BufRead', 'BufNewFile'},
wants = 'plenary.nvim',
config = ui.gitsigns_conf
}
------------
-- Editor --
------------
local editor = require('modules.editor')
use {
'norcalli/nvim-colorizer.lua',
cmd = 'ColorizerToggle',
config = editor.colorizer_conf
}
use {
'RRethy/vim-illuminate',
event = {'BufReadPre', 'BufNewFile'}
}
use {
'lukas-reineke/indent-blankline.nvim',
after = 'nvim-treesitter',
config = editor.blankline_conf
}
use { -- TODO: config (lua -> fennel) + learn clojure, fennel, guile scheme
'Olical/conjure',
ft = {'clojure', 'fennel', 'scheme'},
requires = {{'Olical/aniseed', config = editor.aniseed_conf}}
}
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
event = 'BufRead',
config = editor.treesitter_conf
}
use {
'p00f/nvim-ts-rainbow',
after = 'nvim-treesitter',
-- Putting config into `treesitter_conf` doesn't work for some reason
config = editor.rainbow_conf
}
use {
'romgrk/nvim-treesitter-context',
after = 'nvim-treesitter'
}
use {
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter'
}
use {
'andymass/vim-matchup',
after = 'nvim-treesitter',
config = editor.matchup_conf
}
use {
'machakann/vim-sandwich',
keys = 's'
}
use {
'phaazon/hop.nvim',
cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'},
config = editor.hop_conf
}
use {
'hrsh7th/vim-eft',
event = {'BufRead', 'BufNewFile'},
setup = editor.eft_conf
}
use {
'junegunn/vim-easy-align',
cmd = 'EasyAlign'
}
use {
'terrortylor/nvim-comment',
keys = 'gc',
config = editor.comment_conf
}
use {
'editorconfig/editorconfig-vim',
ft = {'go', 'rust', 'python', 'c', 'cpp', 'javascript', 'typescript', 'vim', 'zig'}
}
use { -- TODO: move to nvim-parinfer (lua)
'eraserhd/parinfer-rust',
run = 'cargo build --release',
ft = {'clojure', 'lisp', 'scheme', 'fennel'}
}
use {
'ahmedkhalf/project.nvim',
event = 'BufEnter',
config = editor.project_conf
}
------------
-- Editor --
------------
local editor = require('modules.editor')
use {
'norcalli/nvim-colorizer.lua',
cmd = 'ColorizerToggle',
config = editor.colorizer_conf
}
use {
'RRethy/vim-illuminate',
event = {'BufReadPre', 'BufNewFile'}
}
use {
'lukas-reineke/indent-blankline.nvim',
after = 'nvim-treesitter',
config = editor.blankline_conf
}
use { -- TODO: config (lua -> fennel) + learn clojure, fennel, guile scheme
'Olical/conjure',
ft = {'clojure', 'fennel', 'scheme'},
requires = {{'Olical/aniseed', config = editor.aniseed_conf}}
}
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
event = 'BufRead',
config = editor.treesitter_conf
}
use {
'p00f/nvim-ts-rainbow',
after = 'nvim-treesitter',
-- Putting config into `treesitter_conf` doesn't work for some reason
config = editor.rainbow_conf
}
use {
'romgrk/nvim-treesitter-context',
after = 'nvim-treesitter'
}
use {
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter'
}
use {
'mizlan/iswap.nvim',
cmd = {'ISwapWith', 'ISwap'},
wants = 'nvim-treesitter',
config = editor.iswap_conf
}
use {
'andymass/vim-matchup',
after = 'nvim-treesitter',
config = editor.matchup_conf
}
use {
'machakann/vim-sandwich',
keys = 's'
}
use {
'phaazon/hop.nvim',
cmd = {'HopChar1', 'HopChar2', 'HopWord', 'HopPattern', 'HopLine'},
config = editor.hop_conf
}
use {
'hrsh7th/vim-eft',
event = {'BufRead', 'BufNewFile'},
setup = editor.eft_conf
}
use {
'junegunn/vim-easy-align',
cmd = 'EasyAlign'
}
use {
'terrortylor/nvim-comment',
keys = 'gc',
config = editor.comment_conf
}
use {
'editorconfig/editorconfig-vim',
ft = {'go', 'rust', 'python', 'c', 'cpp', 'javascript', 'typescript', 'vim', 'zig'}
}
use { -- TODO: move to nvim-parinfer (lua)
'eraserhd/parinfer-rust',
run = 'cargo build --release',
ft = {'clojure', 'lisp', 'scheme', 'fennel'}
}
use {
'ahmedkhalf/project.nvim',
event = 'BufEnter',
config = editor.project_conf
}
---------
-- LSP --
---------
local lsp = require('modules.lsp')
use { -- TODO: scripts to install/update lsp servers
'neovim/nvim-lspconfig',
event = 'BufReadPre',
wants = 'lsp_signature.nvim',
requires = {{'ray-x/lsp_signature.nvim', opt = true}},
config = lsp.lsp_conf
}
use {
'nanotee/sqls.nvim',
ft = {'sql', 'mysql', 'plsql'},
wants = 'nvim-lspconfig',
config = lsp.sqls_conf
}
use {
'folke/trouble.nvim',
cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'},
config = lsp.trouble_conf
}
-- use { -- FIX: conflict highlights with hop.nvim
-- 'folke/todo-comments.nvim',
-- wants = 'plenary.nvim',
-- event = 'BufRead',
-- config = lsp.comments_conf
-- }
use {
'simrat39/symbols-outline.nvim',
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
setup = lsp.outline_conf
}
use { -- TODO: scripts to install/update linters
'mfussenegger/nvim-lint',
event = 'BufRead',
config = lsp.lint_conf
}
use { -- TODO: config, scripts to install/update dap servers
'rcarriga/nvim-dap-ui',
event = 'BufReadPre',
wants = 'nvim-dap',
requires = {{'mfussenegger/nvim-dap', config = lsp.dap_conf, opt = true}},
config = lsp.dapui_conf
}
---------
-- LSP --
---------
local lsp = require('modules.lsp')
use { -- TODO: scripts to install/update lsp servers
'neovim/nvim-lspconfig',
event = 'BufReadPre',
wants = 'lsp_signature.nvim',
requires = {{'ray-x/lsp_signature.nvim', opt = true}},
config = lsp.lsp_conf
}
use {
'nanotee/sqls.nvim',
ft = {'sql', 'mysql', 'plsql'},
wants = 'nvim-lspconfig',
config = lsp.sqls_conf
}
use {
'folke/trouble.nvim',
cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'},
config = lsp.trouble_conf
}
-- use { -- FIX: conflict highlights with hop.nvim
-- 'folke/todo-comments.nvim',
-- wants = 'plenary.nvim',
-- event = 'BufRead',
-- config = lsp.comments_conf
-- }
use {
'simrat39/symbols-outline.nvim',
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
setup = lsp.outline_conf
}
use { -- TODO: scripts to install/update linters
'mfussenegger/nvim-lint',
event = 'BufRead',
config = lsp.lint_conf
}
use { -- TODO: config, scripts to install/update dap servers
'rcarriga/nvim-dap-ui',
event = 'BufReadPre',
wants = 'nvim-dap',
requires = {{'mfussenegger/nvim-dap', config = lsp.dap_conf, opt = true}},
config = lsp.dapui_conf
}
----------------
-- Completion --
----------------
local completion = require('modules.completion')
use {
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
wants = 'LuaSnip',
requires = {{
'L3MON4D3/LuaSnip',
wants = 'friendly-snippets',
requires = {{'rafamadriz/friendly-snippets', opt = true}},
config = completion.snippets_conf,
opt = true
}},
config = completion.cmp_conf
}
use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp'}
use {'hrsh7th/cmp-path', after = 'nvim-cmp'}
use {'hrsh7th/cmp-buffer', after = 'nvim-cmp'}
-- use {'hrsh7th/cmp-calc', after = 'nvim-cmp'}
-- use {'f3fora/cmp-nuspell', after = 'nvim-cmp', rocks={'lua-nuspell'}}
use {'f3fora/cmp-spell', after = 'nvim-cmp'}
use {'hrsh7th/cmp-emoji', after = 'nvim-cmp'}
-- use {'ray-x/cmp-treesitter', after = {'nvim-cmp', 'nvim-treesitter'}}
use {'hrsh7th/cmp-nvim-lsp', after = {'nvim-cmp', 'nvim-lspconfig'}}
-- use {
-- 'tzachar/cmp-tabnine',
-- after = 'nvim-cmp',
-- run = './install.sh',
-- config = completion.tabnine_conf
-- }
use {'kdheepak/cmp-latex-symbols', after = {'nvim-cmp', 'vimtex'}}
use {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp'}
use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}}
use {
'windwp/nvim-autopairs',
after = 'nvim-cmp',
config = completion.autopairs_conf
}
-- use {
-- 'ms-jpq/coq_nvim',
-- branch = 'coq',
-- event = 'InsertEnter',
-- run = ':COQdeps',
-- wants = 'coq.artifacts',
-- requires = {{'ms-jpq/coq.artifacts', branch = 'artifacts', opt = true}},
-- setup = completion.coq_conf
-- }
use {
'windwp/nvim-ts-autotag',
ft = {
'html', 'javascript', 'javascriptreact', 'typescript',
'typescriptreact', 'vue', 'svelte'
},
wants = 'nvim-treesitter',
config = completion.autotag_conf
}
----------------
-- Completion --
----------------
local completion = require('modules.completion')
use {
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
wants = 'LuaSnip',
requires = {{
'L3MON4D3/LuaSnip',
wants = 'friendly-snippets',
requires = {{'rafamadriz/friendly-snippets', opt = true}},
config = completion.snippets_conf,
opt = true
}},
config = completion.cmp_conf
}
use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp'}
use {'hrsh7th/cmp-path', after = 'nvim-cmp'}
use {'hrsh7th/cmp-buffer', after = 'nvim-cmp'}
-- use {'hrsh7th/cmp-calc', after = 'nvim-cmp'}
-- use {'f3fora/cmp-nuspell', after = 'nvim-cmp', rocks={'lua-nuspell'}}
use {'f3fora/cmp-spell', after = 'nvim-cmp'}
use {'hrsh7th/cmp-emoji', after = 'nvim-cmp'}
-- use {'ray-x/cmp-treesitter', after = {'nvim-cmp', 'nvim-treesitter'}}
use {'hrsh7th/cmp-nvim-lsp', after = {'nvim-cmp', 'nvim-lspconfig'}}
-- use {
-- 'tzachar/cmp-tabnine',
-- after = 'nvim-cmp',
-- run = './install.sh',
-- config = completion.tabnine_conf
-- }
use {'kdheepak/cmp-latex-symbols', after = {'nvim-cmp', 'vimtex'}}
-- use {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp'}
use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}}
use {
'windwp/nvim-autopairs',
after = 'nvim-cmp',
config = completion.autopairs_conf
}
-- use {
-- 'ms-jpq/coq_nvim',
-- branch = 'coq',
-- event = 'InsertEnter',
-- run = ':COQdeps',
-- wants = 'coq.artifacts',
-- requires = {{'ms-jpq/coq.artifacts', branch = 'artifacts', opt = true}},
-- setup = completion.coq_conf
-- }
use {
'windwp/nvim-ts-autotag',
ft = {
'html', 'javascript', 'javascriptreact', 'typescript',
'typescriptreact', 'vue', 'svelte'
},
wants = 'nvim-treesitter',
config = completion.autotag_conf
}
-----------
-- Tools --
-----------
local tools = require('modules.tools')
use { -- TODO: watch out for fzf-lua
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
wants = {
'popup.nvim',
'plenary.nvim',
'telescope-symbols.nvim',
'telescope-project.nvim',
'telescope-fzf-native.nvim'
},
requires = {
{'nvim-telescope/telescope-symbols.nvim', opt = true},
{'nvim-telescope/telescope-project.nvim', opt = true},
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = true}
},
config = tools.telescope_conf
}
use { -- TODO: colors + config
'pwntester/octo.nvim',
cmd = 'Octo',
wants = 'telescope.nvim',
config = tools.octo_conf
}
use {
'TimUntersberger/neogit',
cmd = 'Neogit',
wants = {'diffview.nvim', 'plenary.nvim'},
requires = {{
'sindrets/diffview.nvim',
config = tools.diffview_conf,
opt = true
}},
config = tools.neogit_conf
}
use { -- TODO: replace with code_runner.nvim
'skywind3000/asynctasks.vim',
cmd = {
'AsyncTask',
'AsyncTaskEdit',
'AsyncTaskList',
'AsyncTaskMacro'
},
wants = 'asyncrun.vim',
requires = {{
'skywind3000/asyncrun.vim',
setup = tools.asynctasks_conf,
opt = true
}}
}
use {
'iamcco/markdown-preview.nvim',
run = 'cd app && yarn install',
ft = {'markdown', 'rmd'},
config = tools.markdown_preview_conf
}
use {
'turbio/bracey.vim',
run = 'npm install --prefix server',
cmd = 'Bracey'
}
use {
'folke/zen-mode.nvim',
cmd = 'ZenMode',
wants = 'twilight.nvim',
requires = {{'folke/twilight.nvim', opt = true}},
config = tools.zenmode_conf
}
use { -- shouldn't be lazy-loaded (global bindings don't work)
'kristijanhusak/orgmode.nvim',
ft = 'org',
config = tools.orgmode_conf
}
use { -- TODO: config
'lervag/vimtex',
ft = 'tex',
setup = tools.vimtext_conf
}
use {
'windwp/nvim-spectre',
event = {'BufRead', 'BufNewFile'},
wants = 'plenary.nvim',
config = tools.spectre_conf
}
use {
'echuraev/translate-shell.vim',
cmd = {'Trans', 'TransSelectDirection'},
config = tools.translate_conf
}
use {
'mbbill/undotree',
cmd = 'UndotreeToggle',
setup = tools.undotree_conf
}
use {
'akinsho/toggleterm.nvim',
cmd = 'ToggleTerm',
config = tools.toggleterm_conf
}
-- use {
-- 'gelguy/wilder.nvim',
-- run = ':UpdateRemotePlugins',
-- event = 'CmdlineEnter',
-- config = tools.wilder_conf
-- }
use {
'karb94/neoscroll.nvim',
event = 'WinScrolled',
config = tools.neoscroll_conf
}
use {
'michaelb/sniprun',
run = 'bash ./install.sh 1',
cmd = 'SnipRun',
config = tools.sniprun_conf
}
use {
'NTBBloodbath/rest.nvim',
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
wants = {'plenary.nvim', 'nvim-treesitter'},
run = ':TSInstall http',
config = tools.rest_conf
}
use { -- TODO: move to formater.nvim
'sbdchd/neoformat',
cmd = 'Neoformat'
}
use {
'folke/persistence.nvim',
event = 'BufEnter',
config = tools.session_conf
}
-- use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
-----------
-- Tools --
-----------
local tools = require('modules.tools')
use { -- TODO: watch out for fzf-lua
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
wants = {
'popup.nvim',
'plenary.nvim',
'telescope-symbols.nvim',
'telescope-project.nvim',
'telescope-fzf-native.nvim'
},
requires = {
{'nvim-telescope/telescope-symbols.nvim', opt = true},
{'nvim-telescope/telescope-project.nvim', opt = true},
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = true}
},
config = tools.telescope_conf
}
use { -- TODO: colors + config
'pwntester/octo.nvim',
cmd = 'Octo',
wants = 'telescope.nvim',
config = tools.octo_conf
}
use {
'TimUntersberger/neogit',
cmd = 'Neogit',
wants = {'diffview.nvim', 'plenary.nvim'},
requires = {{
'sindrets/diffview.nvim',
config = tools.diffview_conf,
opt = true
}},
config = tools.neogit_conf
}
use { -- TODO: replace with code_runner.nvim
'skywind3000/asynctasks.vim',
cmd = {
'AsyncTask',
'AsyncTaskEdit',
'AsyncTaskList',
'AsyncTaskMacro'
},
wants = 'asyncrun.vim',
requires = {{
'skywind3000/asyncrun.vim',
setup = tools.asynctasks_conf,
opt = true
}}
}
use {
'iamcco/markdown-preview.nvim',
run = 'cd app && yarn install',
ft = {'markdown', 'rmd'},
config = tools.markdown_preview_conf
}
use {
'turbio/bracey.vim',
run = 'npm install --prefix server',
cmd = 'Bracey'
}
use {
'folke/zen-mode.nvim',
cmd = 'ZenMode',
wants = 'twilight.nvim',
requires = {{'folke/twilight.nvim', opt = true}},
config = tools.zenmode_conf
}
use { -- shouldn't be lazy-loaded (global bindings don't work)
'kristijanhusak/orgmode.nvim',
ft = 'org',
config = tools.orgmode_conf
}
use { -- TODO: config
'lervag/vimtex',
ft = 'tex',
setup = tools.vimtext_conf
}
use {
'windwp/nvim-spectre',
event = {'BufRead', 'BufNewFile'},
wants = 'plenary.nvim',
config = tools.spectre_conf
}
use {
'echuraev/translate-shell.vim',
cmd = {'Trans', 'TransSelectDirection'},
config = tools.translate_conf
}
use {
'mbbill/undotree',
cmd = 'UndotreeToggle',
setup = tools.undotree_conf
}
use {
'akinsho/toggleterm.nvim',
cmd = 'ToggleTerm',
config = tools.toggleterm_conf
}
-- use {
-- 'gelguy/wilder.nvim',
-- run = ':UpdateRemotePlugins',
-- event = 'CmdlineEnter',
-- config = tools.wilder_conf
-- }
use {
'karb94/neoscroll.nvim',
event = 'WinScrolled',
config = tools.neoscroll_conf
}
use {
'michaelb/sniprun',
run = 'bash ./install.sh 1',
cmd = 'SnipRun',
config = tools.sniprun_conf
}
use {
'NTBBloodbath/rest.nvim',
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
wants = {'plenary.nvim', 'nvim-treesitter'},
run = ':TSInstall http',
config = tools.rest_conf
}
use { -- TODO: move to formater.nvim
'sbdchd/neoformat',
cmd = 'Neoformat'
}
use {
'folke/persistence.nvim',
event = 'BufEnter',
config = tools.session_conf
}
use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
-- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*,
-- nvim-bqf, nvim-comment-frame, nvim-revJ.lua
end
)
-- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*,
-- nvim-bqf, nvim-comment-frame, nvim-revJ.lua
-- Install plugins if missing
packer.install()
end)

104
home/.local/bin/doasedit Executable file
View File

@ -0,0 +1,104 @@
#!/usr/bin/env sh
# doasedit
# Link: git.io/doasedit
# Dependencies: opendoas <https://github.com/Duncaen/OpenDoas> or doas <https://cvsweb.openbsd.org/src/usr.bin/doas/>
# Author: Stanislav <git.io/monesonn>
# Description: doas equivalent to sudoedit.
# Licence: ISC
# Contribution: If you have some ideas, how to improve this script, feel free to make pull request or write an issue.
# Tips: Use this script with enabled persistence in doas.conf file, like:
#
# `permit persist :wheel`
#
# Also make sure that your doas.conf is owned by root with read-only permissions, like:
#
# # chown -c root:root /path/to/doas.conf && chmod 0400 path/to/doas.conf
#
# Throw error message.
err() {
printf "%s%s\n" "doasedit: " "${1}" >&2
exit "${2}"
}
# Catch arguments.
if [ -n "${2}" ]; then
err "expected only one argument" 1
elif [ -z "${1}" ]; then
err "no file path provided" 2
elif [ "$(id -u)" -eq 0 ]; then
err "doasedit: cannot be run as root" 3
elif [ -d "${1}" ]; then
err "${1} is a directory" 4
fi
# Safe shell options.
set -eu
# Reset doas password promt. If you want, feel free to comment this.
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
linux) doas -L ;;
esac
# Absolute path to the source file (file for editing).
src="$(doas readlink -f "${1}")"
# Filename for the source file.
filename="${src##*/}"
# If filename have suffix then also use it for a temporary file.
# It's kinda useful for editors, that have plugins or something else for certain file extensions.
[ "$filename" = "${filename##*.}" ] && filename_ext="" || filename_ext=".${filename##*.}"
# Be sure /tmp as tmp directory by setting TMPDIR env.
export TMPDIR=/tmp
# Create a temporary directory.
tmp_d=$(mktemp -d)
# Create a temporary file for the source file in a temporary directory.
tmp_f="${tmp_d}/${filename}$(xxd -l4 -ps /dev/urandom)${filename_ext}"
# File writeability condition.
if [ -w "$src" ]; then
err "$filename: editing files in a writable directory is not permitted" 5
fi
# Other conditions: if file exist, readable, etc.
if [ -f "${src}" ] && [ ! -r "${src}" ]; then
doas cat "${src}" > "${tmp_f}" || err "the file is not readable" 6
elif [ -r "${src}" ]; then
cat "${src}" > "${tmp_f}" || err "cannot transfer to content of the file to temporary one" 7
elif [ ! -f "${src}" ]; then
# Grant .rw-r--r-- permission for newly created files by default owned by root.
:> "${tmp_f}" && doas chmod -R 0644 "${tmp_f}" || err "cannot create new file" 8
else
err "unexpected script behaviour" 9
fi
# Create copy of the temporary file.
tmp_cf="${tmp_d}/${filename}$(xxd -l4 -ps /dev/urandom).copy"
# Hooks for recursive removing of a temporary directory.
trap 'rm -rf ${tmp_d}' EXIT HUP QUIT TERM INT ABRT
# Move the contents of a temporary file to its copy for later comparison.
cat "${tmp_f}" > "${tmp_cf}"
# Editing the file by the user using the default editor, if not specified, the vi is used.
${EDITOR:-vi} "${tmp_f}"
# Compare the temporary file and the temporary copy.
if cmp -s "${tmp_f}" "${tmp_cf}"; then
printf "%s\n" "doasedit: $filename unchanged"
exit 0
else
# Replace the source file with temporary, repeats three times if it fails.
for doas_tries in $(seq 1 3); do doas cp -f "${tmp_f}" "${src}" && break; done
printf "%s\n" "doasedit: $filename changes are accepted"
exit 0
fi

View File

@ -1,20 +0,0 @@
#!/bin/sh
if [ "$1" = "-h" ]; then
echo "Usage: pancomp [input_format] [input_file] [output_format] [output_file]"
exit 0
fi
if [ $# -ne 4 ]; then
echo "Bruh, I need 4 arguments."
exit 1
fi
pandoc \
--pdf-engine=xelatex \
-V 'mainfont:Iosevka Etoile' \
-V 'sansfont:Iosevka Aile' \
-V 'monofont:Iosevka' \
-V 'geometry:margin=1in' \
-f "$1" -t "$3" \
-o "$4" "$2"