working nvf!
This commit is contained in:
parent
5548480371
commit
2a80c2bac1
53 changed files with 330 additions and 172 deletions
8
modules/editors/nvf/runtime/after/ftdetect/gitconfig.lua
Normal file
8
modules/editors/nvf/runtime/after/ftdetect/gitconfig.lua
Normal 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,
|
||||
})
|
8
modules/editors/nvf/runtime/after/ftdetect/graphql.lua
Normal file
8
modules/editors/nvf/runtime/after/ftdetect/graphql.lua
Normal 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,
|
||||
})
|
4
modules/editors/nvf/runtime/after/ftplugin/envrc.lua
Normal file
4
modules/editors/nvf/runtime/after/ftplugin/envrc.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
-- luacheck: ignore
|
||||
vim.filetype.add({
|
||||
filename = { ['.envrc'] = 'bash' },
|
||||
})
|
2
modules/editors/nvf/runtime/after/ftplugin/gitcommit.lua
Normal file
2
modules/editors/nvf/runtime/after/ftplugin/gitcommit.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- luacheck: ignore
|
||||
vim.opt_local.textwidth = 80
|
5
modules/editors/nvf/runtime/after/ftplugin/go.lua
Normal file
5
modules/editors/nvf/runtime/after/ftplugin/go.lua
Normal 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
|
14
modules/editors/nvf/runtime/after/ftplugin/json.lua
Normal file
14
modules/editors/nvf/runtime/after/ftplugin/json.lua
Normal 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 })
|
13
modules/editors/nvf/runtime/after/ftplugin/man.lua
Normal file
13
modules/editors/nvf/runtime/after/ftplugin/man.lua
Normal 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'
|
30
modules/editors/nvf/runtime/after/ftplugin/markdown.lua
Normal file
30
modules/editors/nvf/runtime/after/ftplugin/markdown.lua
Normal 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,
|
||||
})
|
2
modules/editors/nvf/runtime/after/ftplugin/qf.lua
Normal file
2
modules/editors/nvf/runtime/after/ftplugin/qf.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- luacheck: ignore
|
||||
vim.wo.wrap = true
|
2
modules/editors/nvf/runtime/after/ftplugin/xml.lua
Normal file
2
modules/editors/nvf/runtime/after/ftplugin/xml.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- luacheck: ignore
|
||||
vim.opt_local.shiftwidth = 2
|
30
modules/editors/nvf/runtime/after/queries/go/injections.scm
Normal file
30
modules/editors/nvf/runtime/after/queries/go/injections.scm
Normal 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")
|
||||
)
|
|
@ -0,0 +1,2 @@
|
|||
;; extends
|
||||
(( jsx_text ) @injection.content (#set! injection.language "markdown") )
|
|
@ -0,0 +1,5 @@
|
|||
;extends
|
||||
|
||||
(fenced_code_block (code_fence_content) @class.inner) @class.outer
|
||||
|
||||
(paragraph) @function.outer @function.inner
|
|
@ -0,0 +1,12 @@
|
|||
;extends
|
||||
|
||||
[
|
||||
(shortcut_link)
|
||||
] @nospell
|
||||
|
||||
(strikethrough
|
||||
(emphasis_delimiter)
|
||||
(strikethrough
|
||||
(emphasis_delimiter)
|
||||
(emphasis_delimiter))
|
||||
(emphasis_delimiter))@markup.doublestrikethrough
|
|
@ -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))
|
|
@ -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)
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
;; extends
|
||||
((ident) @constant
|
||||
(#eq? @constant "lambda")
|
||||
(#set! conceal "λ")
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue