diff options
Diffstat (limited to '')
| -rw-r--r-- | .config/nvim/lua/config/diagnostics.lua (renamed from .vim/plugin/diagnostics.lua) | 14 | ||||
| -rw-r--r-- | .config/nvim/lua/config/options.lua (renamed from .vim/plugin/options.lua) | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/config/statuscolumn.lua (renamed from .vim/plugin/statuscolumn.lua) | 0 | ||||
| -rw-r--r-- | .config/nvim/lua/config/statusline.lua (renamed from .vim/plugin/statusline.lua) | 0 | ||||
| -rw-r--r-- | .config/nvim/lua/config/undo.lua (renamed from .vim/plugin/undo.lua) | 0 | ||||
| -rw-r--r-- | .vim/plugin/_globals.lua | 3 | ||||
| -rw-r--r-- | .vim/plugin/auto.lua | 38 | ||||
| -rw-r--r-- | .vim/plugin/darkmode.lua | 47 | ||||
| -rw-r--r-- | .vim/plugin/hardmode.lua | 10 | ||||
| -rw-r--r-- | .vim/plugin/keymaps.lua | 49 | ||||
| -rw-r--r-- | .vim/plugin/syncbg.lua | 73 | ||||
| -rw-r--r-- | .vim/plugin/termopen.lua | 72 |
12 files changed, 10 insertions, 300 deletions
diff --git a/.vim/plugin/diagnostics.lua b/.config/nvim/lua/config/diagnostics.lua index 93ee621..6314b83 100644 --- a/.vim/plugin/diagnostics.lua +++ b/.config/nvim/lua/config/diagnostics.lua @@ -1,10 +1,10 @@ vim.diagnostic.config({ signs = { text = { - [vim.diagnostic.severity.ERROR] = '✗', - [vim.diagnostic.severity.WARN] = '▷', - [vim.diagnostic.severity.INFO] = 'ℹ', - [vim.diagnostic.severity.HINT] = '🞶', + [vim.diagnostic.severity.ERROR] = '', + [vim.diagnostic.severity.WARN] = '', + [vim.diagnostic.severity.INFO] = '', + [vim.diagnostic.severity.HINT] = '', }, linehl = { -- [vim.diagnostic.severity.ERROR] = 'Search', @@ -44,7 +44,9 @@ end, { desc = 'diagnostic: prev' }) vim.keymap.set('n', 'DD', vim.diagnostic.open_float, { desc = 'diagnostic: current line' }) -vim.keymap.set('n', '<leader>td', function() +vim.keymap.set('n', '<leader>d', '<nop>', { desc = "diagnostics" }) +vim.keymap.set('n', '<leader>dd', vim.diagnostic.open_float, { desc = 'diagnostic: current line' }) +vim.keymap.set('n', '<leader>dv', function() -- NOTE: this can be used to switch between multiple sets of diagnostics display -- currently it only toggles virtual_text local visible = vim.diagnostic.config().virtual_text @@ -58,6 +60,6 @@ vim.keymap.set('n', '<leader>td', function() end end, { desc = 'diagnostic: toggle visibility' }) -vim.keymap.set('n', '<leader>tD', function() +vim.keymap.set('n', '<leader>da', function() vim.diagnostic.enable(not vim.diagnostic.is_enabled()) end, { desc = 'diagnostic: toggle all' }) diff --git a/.vim/plugin/options.lua b/.config/nvim/lua/config/options.lua index dba726a..073835f 100644 --- a/.vim/plugin/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -15,13 +15,13 @@ opt.listchars:append({ trail = '¬', tab = '> ', -- space = '·', - lead = '·', + -- lead = '·', }) opt.showbreak = '↪ ' -- show indicator and wrap text at 80 chars opt.colorcolumn = '+1' -opt.textwidth = 79 +opt.textwidth = 80 opt.wrap = true opt.conceallevel = 2 diff --git a/.vim/plugin/statuscolumn.lua b/.config/nvim/lua/config/statuscolumn.lua index 06e8988..06e8988 100644 --- a/.vim/plugin/statuscolumn.lua +++ b/.config/nvim/lua/config/statuscolumn.lua diff --git a/.vim/plugin/statusline.lua b/.config/nvim/lua/config/statusline.lua index fed6d33..fed6d33 100644 --- a/.vim/plugin/statusline.lua +++ b/.config/nvim/lua/config/statusline.lua diff --git a/.vim/plugin/undo.lua b/.config/nvim/lua/config/undo.lua index aed6195..aed6195 100644 --- a/.vim/plugin/undo.lua +++ b/.config/nvim/lua/config/undo.lua diff --git a/.vim/plugin/_globals.lua b/.vim/plugin/_globals.lua deleted file mode 100644 index 5bf99a4..0000000 --- a/.vim/plugin/_globals.lua +++ /dev/null @@ -1,3 +0,0 @@ -_G.feedkeys = function(keys) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(keys, true, false, true), 'n', true) -end diff --git a/.vim/plugin/auto.lua b/.vim/plugin/auto.lua deleted file mode 100644 index 98f0ef1..0000000 --- a/.vim/plugin/auto.lua +++ /dev/null @@ -1,38 +0,0 @@ -local augroup = vim.api.nvim_create_augroup -local autocmd = vim.api.nvim_create_autocmd - -do - local group = augroup('EasyQuit', { clear = true }) - autocmd('FileType', { - pattern = { - 'help', - 'qf', - 'dap-float', - 'gitsigns-blame', - 'git', - }, - callback = function() - vim.keymap.set('n', 'q', '<cmd>close<cr>', { silent = true, buffer = 0 }) - end, - group = group, - }) - autocmd('FileType', { - pattern = { 'gitgraph' }, - callback = function() - vim.keymap.set('n', 'q', '<cmd>bdel!<cr>', { silent = true, buffer = 0 }) - end, - group = group, - }) - autocmd('FileType', { - pattern = { 'DiffviewFiles' }, - callback = function() - vim.keymap.set('n', 'q', '<cmd>tabclose<cr>', { silent = true, buffer = 0 }) - end, - group = group, - }) - -- autocmd('TermClose', { - -- pattern = { 'term://*' }, - -- command = [[ if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif ]], - -- group = group, - -- }) -end diff --git a/.vim/plugin/darkmode.lua b/.vim/plugin/darkmode.lua deleted file mode 100644 index 6ffd06f..0000000 --- a/.vim/plugin/darkmode.lua +++ /dev/null @@ -1,47 +0,0 @@ --- this plugin registers registers and autocommand that switches colorschemes on UIEnter based on --- the system's preference for dark/light mode - -local state = { enabled = true } - -if not state.enabled then - return -end - -local set_darkmode = function(enabled) - if enabled then - vim.opt.background = 'dark' - vim.cmd.colorscheme(vim.g.darkmode_colorscheme_dark or 'default') - else - vim.opt.background = 'light' - vim.cmd.colorscheme(vim.g.darkmode_colorscheme_light or 'default') - end -end - --- returns if system is configured to use darkmode -local discover = function() - require('plenary.job') - :new({ - command = 'porta', - args = { 'settings', 'org.freedesktop.appearance', 'color-scheme' }, - enable_recording = true, - on_exit = vim.schedule_wrap(function(job, exitcode) - local darkmode_enabled = true - local res = job:result() - if exitcode == 0 and #res then - darkmode_enabled = not (res[1] == 'prefer-light') - end - set_darkmode(darkmode_enabled) - end), - }) - :start() -end - --- setup autogroup -local aug = vim.api.nvim_create_augroup('darkmode', { clear = true }) - --- setup color-scheme detection via desktop portal apis -vim.api.nvim_create_autocmd({ 'UIEnter', 'VimResume' }, { callback = discover, group = aug }) -vim.api.nvim_create_autocmd({ 'Signal' }, { pattern = 'SIGUSR1', callback = discover, group = aug }) - --- fix ColorColumn not being defined -vim.api.nvim_set_hl(0, 'ColorColumn', { link = 'CursorColumn', force = true }) diff --git a/.vim/plugin/hardmode.lua b/.vim/plugin/hardmode.lua deleted file mode 100644 index f18a5ef..0000000 --- a/.vim/plugin/hardmode.lua +++ /dev/null @@ -1,10 +0,0 @@ --- hard mode means we're not using the arrow keys! - -local bail = function() - vim.cmd([[silent! echohl ErrorMsg | echo "HARD MODE: hjkl operation only" | echohl None]]) -end - -vim.keymap.set({ 'v', 'i' }, '<up>', bail) -vim.keymap.set({ 'v', 'i' }, '<down>', bail) -vim.keymap.set({ 'v', 'i' }, '<left>', bail) -vim.keymap.set({ 'v', 'i' }, '<right>', bail) diff --git a/.vim/plugin/keymaps.lua b/.vim/plugin/keymaps.lua deleted file mode 100644 index f7cdf20..0000000 --- a/.vim/plugin/keymaps.lua +++ /dev/null @@ -1,49 +0,0 @@ -local set = vim.keymap.set - -set('n', 'gb', '<cmd>bnext<cr>', { desc = 'Next buffer' }) -set('n', 'gB', '<cmd>bprevious<cr>', { desc = 'Prev buffer' }) -set( - 'n', - 'g<bs>', - '<cmd>lua vim.notify("Use <lt>C-o> and <lt>C-i>!", vim.log.levels.WARN)<cr>', - { desc = 'Last buffer' } -) - -set('n', ';yp', function() - local payload = (vim.fn.expand('%:p') .. ':' .. vim.fn.line('.')) - vim.fn.setreg('+', payload) - vim.notify(payload) -end, { desc = 'Yank current buffer path and line number' }) - -set('n', ';yP', function() - local payload = vim.fn.expand('%:p') - vim.fn.setreg('+', payload) - vim.notify(payload) -end, { desc = 'Yank current buffer path' }) - -set('n', ';yn', function() - local payload = vim.fs.basename(vim.fn.expand('%:p')) - vim.fn.setreg('+', payload) - vim.notify(payload) -end, { desc = 'Yank current buffer name' }) - -set('t', '<esc>', [[ <c-\><c-n> ]], { desc = 'Terminal: Exit INSERT mode' }) - -set('v', '<', '<gv', { desc = 'indent' }) -set('v', '>', '>gv', { desc = 'outdent' }) - -set('n', '<s-esc>', '<cmd>nohlsearch<cr>', { desc = 'Clear search highlights' }) --- set('n', '<tab>', '<cmd>normal! za<cr>', { desc = 'Toggle fold under cursor' }) -set('n', '<s-tab>', '<cmd>normal! zA<cr>', { desc = 'Toggle fold under cursor (recursive)' }) - -set('n', '<a-j>', '<cmd>cnext<cr>', { desc = 'Next in quickfix' }) -set('n', '<a-k>', '<cmd>cprev<cr>', { desc = 'Prev in quickfix' }) - -set('n', '<leader><bs>', '@:', { desc = 'Rerun last command' }) - -set( - 'n', - 'gx', - '<cmd>lua vim.ui.open(vim.fn.expand("<cfile>"))<cr>', - { desc = 'Open file under cursor' } -) diff --git a/.vim/plugin/syncbg.lua b/.vim/plugin/syncbg.lua deleted file mode 100644 index c11bef6..0000000 --- a/.vim/plugin/syncbg.lua +++ /dev/null @@ -1,73 +0,0 @@ --- this plugin registers two autocmds that trigger when openeing and closing the editor, setting the --- background of the terminal to the color used by our colorscheme using CSI control codes. - -local state = { enabled = false } - -if not state.enabled then - return -end - -local set_bg = function(clear) - if not (state.tty and state.normal) then - return - end - if clear then - -- emit CSI to unset custom background - os.execute('printf "\\033]111\\007" > ' .. state.tty) - else - -- emit CSI to change terminal background to Normal.bg - os.execute( - 'printf "\\033]11;' .. string.format('#%06x', state.normal.bg) .. '\\007" > ' .. state.tty - ) - -- set colorscheme Normal.bg to NONE, making it transparent - vim.cmd([[hi Normal ctermbg=NONE guibg=NONE]]) - end -end - -local discover = function() - if not state.tty then - -- get tty handle - local ok, tty_handle = pcall(io.popen, 'tty') - if (not ok) or tty_handle == nil then - return - end - local tty = tty_handle:read('*l') - tty_handle:close() - if tty:find('not a tty') then - return - end - state.tty = tty - end - - if not state.normal then - -- get colorscheme Normal highlight - local normal = vim.api.nvim_get_hl(0, { name = 'Normal', create = false }) - if normal.bg == nil then - return - end - -- cache old value for use with VimResume - state.normal = normal - end - - -- vim.notify('syncbg: ' .. vim.inspect(state), vim.log.levels.DEBUG) -end - --- setup autogroup -local aug = vim.api.nvim_create_augroup('syncbg', { clear = true }) - --- register update hook -vim.api.nvim_create_autocmd({ 'ColorScheme', 'UIEnter', 'VimResume' }, { - group = aug, - callback = vim.schedule_wrap(function() - discover() - set_bg(false) - end), -}) - --- register reset hook -vim.api.nvim_create_autocmd({ 'UILeave' }, { - group = aug, - callback = vim.schedule_wrap(function() - set_bg(true) - end), -}) diff --git a/.vim/plugin/termopen.lua b/.vim/plugin/termopen.lua deleted file mode 100644 index 951857f..0000000 --- a/.vim/plugin/termopen.lua +++ /dev/null @@ -1,72 +0,0 @@ -local function termopen(opts) - opts = opts or {} - - -- setup the buffer - local buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = buf }) - vim.api.nvim_set_option_value('modifiable', false, { buf = buf }) - - -- setup keymappings - vim.keymap.set('n', 'q', '<cmd>close<cr>', { buffer = buf }) - vim.keymap.set('n', '<esc>', '<cmd>close<cr>', { buffer = buf }) - - -- setup the window - local w = math.ceil(vim.o.columns * 1.0) - local h = math.ceil(vim.o.lines * 0.4) - local win = vim.api.nvim_open_win(buf, true, { - style = 'minimal', - relative = 'editor', - width = w, - height = h, - row = math.ceil(vim.o.lines - h), - col = vim.o.columns, - border = { ' ', '─', ' ', ' ', ' ', '─', ' ', ' ' }, - }) - vim.api.nvim_set_current_win(win) - - -- spawn the command - if #opts.cmd == 0 then - opts.cmd = { vim.env.SHELL } - end - vim.fn.termopen(opts.cmd, { - on_exit = function() - -- if vim.api.nvim_win_is_valid(win) then - -- vim.api.nvim_win_close(win, true) - -- end - end, - }) - - -- put into insert mode - vim.cmd.startinsert() -end - --- provide user commands -vim.api.nvim_create_user_command('Termopen', function(a) - termopen({ cmd = a.fargs }) -end, { nargs = '*' }) - --- alias -vim.api.nvim_create_user_command('T', function(a) - termopen({ cmd = a.fargs }) -end, { nargs = '*' }) - --- helper to spawn &makeprg -vim.api.nvim_create_user_command('Make', function(a) - if vim.opt_local.makeprg == nil then - vim.ui.input({ prompt = 'Enter makeprg: ' }, function(input) - vim.opt_local.makeprg = input - end) - end - - local cmd = vim.split(vim.opt_local.makeprg:get(), ' ') - cmd = vim.tbl_map(function(p) - p, _ = string.gsub(p, [[%$%*]], a.args) - p, _ = vim.fn.expand(p) - return p - end, cmd) - termopen({ cmd = cmd }) -end, { nargs = '*' }) - --- setup keymappings -vim.keymap.set('n', '<leader><leader>m', '<cmd>Make<cr>', { desc = 'Run :Make' }) -vim.keymap.set('n', '<leader><leader>t', '<cmd>Termopen<cr>', { desc = 'Run :Termopen' }) |