working nvf!

This commit is contained in:
Charlie Root 2024-07-06 17:14:45 +02:00
commit 2a80c2bac1
53 changed files with 330 additions and 172 deletions

View file

@ -0,0 +1,4 @@
-- luacheck: ignore
vim.filetype.add({
filename = { ['.envrc'] = 'bash' },
})

View file

@ -0,0 +1,2 @@
-- luacheck: ignore
vim.opt_local.textwidth = 80

View file

@ -0,0 +1,5 @@
-- luacheck: ignore
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 0
vim.opt_local.expandtab = false
vim.opt_local.list = false

View file

@ -0,0 +1,14 @@
vim.keymap.set('n', '<leader>jf', '<cmd>%!jq<cr>', { noremap = true, silent = true, desc = 'Format with jq' })
vim.keymap.set('n', '<leader>jm', '<cmd>%!jq -c<cr>', { noremap = true, silent = true, desc = 'Minify with jq' })
-- add comma to the end of the line on new line
vim.keymap.set('n', 'o', function()
local line = vim.api.nvim_get_current_line()
local should_add_comma = string.find(line, '[^,{[]$')
if should_add_comma then
return 'A,<cr>'
else
return 'o'
end
end, { buffer = true, expr = true })

View file

@ -0,0 +1,13 @@
-- luacheck: ignore
local opts = { noremap = true, silent = true, buffer = 0 }
local wincmd = vim.b.pager and 'q' or 'c'
vim.keymap.set('n', 'q', '<cmd>lclose<CR><C-W>' .. wincmd, opts)
vim.keymap.set('n', '<Leader>o', function()
-- TODO: can this be done in a floating window?
require('man').show_toc()
end, opts)
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
.. (vim.b.undo_ftplugin ~= nil and ' | ' or '')
.. 'sil! nunmap <buffer> <Leader>o'
.. ' | sil! nunmap <buffer> q'

View file

@ -0,0 +1,30 @@
-- luacheck: ignore
vim.opt_local.textwidth = 80
local CR = vim.api.nvim_replace_termcodes('<cr>', true, true, true)
local function toggle_checkbox()
local cursor = vim.api.nvim_win_get_cursor(0)
local lineno = cursor[1]
local line = vim.api.nvim_buf_get_lines(0, lineno - 1, lineno, false)[1] or ''
if string.find(line, '%[ %]') then
line = line:gsub('%[ %]', '%[x%]')
else
line = line:gsub('%[x%]', '%[ %]')
end
vim.api.nvim_buf_set_lines(0, lineno - 1, lineno, false, { line })
vim.api.nvim_win_set_cursor(0, cursor)
pcall(vim.fn['repeat#set'], ':ToggleCheckbox' .. CR)
end
vim.api.nvim_create_user_command(
'ToggleCheckbox',
toggle_checkbox,
vim.tbl_extend('force', { desc = 'toggle checkboxes' }, {})
)
vim.keymap.set('n', '<leader>op', toggle_checkbox, {
noremap = true,
silent = true,
desc = 'Toggle checkbox',
buffer = 0,
})

View file

@ -0,0 +1,2 @@
-- luacheck: ignore
vim.wo.wrap = true

View file

@ -0,0 +1,2 @@
-- luacheck: ignore
vim.opt_local.shiftwidth = 2