modules: move tui, gui, cli to programs

This commit is contained in:
Charlie Root 2024-08-16 13:44:44 +02:00
commit 47a79eea64
106 changed files with 3 additions and 47 deletions

View file

@ -0,0 +1,8 @@
-- luacheck: ignore
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = 'gitconfig*,.gitconfig*',
callback = function()
vim.bo.filetype = 'gitconfig'
end,
once = false,
})

View file

@ -0,0 +1,8 @@
-- luacheck: ignore
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = '*.graphql,*.graphqls,*.gql',
callback = function()
vim.bo.filetype = 'graphql'
end,
once = false,
})

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

View file

@ -0,0 +1,30 @@
; extends
; inject sql into any const string with word query in the name
; e.g. const query = `SELECT * FROM users WHERE name = 'John'`;
(const_spec
name: (identifier) @_name (#match? @_name "[Qq]uery")
value: (expression_list
(raw_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql"))
; inject sql in single line strings
(call_expression
(selector_expression
field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind"))
(argument_list
(raw_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql")
)
; inject sql in multi line strings
(call_expression
(selector_expression
field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind"))
(argument_list
(interpreted_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql")
)

View file

@ -0,0 +1,2 @@
;; extends
(( jsx_text ) @injection.content (#set! injection.language "markdown") )

View file

@ -0,0 +1,5 @@
;extends
(fenced_code_block (code_fence_content) @class.inner) @class.outer
(paragraph) @function.outer @function.inner

View file

@ -0,0 +1,12 @@
;extends
[
(shortcut_link)
] @nospell
(strikethrough
(emphasis_delimiter)
(strikethrough
(emphasis_delimiter)
(emphasis_delimiter))
(emphasis_delimiter))@markup.doublestrikethrough

View file

@ -0,0 +1,9 @@
((jsx_section)
@injection.content
(#set! injection.language "tsx")
(#set! injection.include-children))
((markdown_section)
@injection.content
(#set! injection.language "markdown")
(#set! injection.combined))

View file

@ -0,0 +1,14 @@
;extends
(macro_invocation
(scoped_identifier
path: (identifier) @path (#eq? @path "sqlx")
name: (identifier) @name (#match? @name "^query.*")
)
(token_tree
(raw_string_literal) @injection.content
(#set! injection.language "sql")
(#set! injection.include-children)
)
(#offset! @injection.content 0 3 0 -2)
)

View file

@ -0,0 +1,5 @@
;; extends
((ident) @constant
(#eq? @constant "lambda")
(#set! conceal "λ")
)