diff options
Diffstat (limited to '.config/nvim/after')
38 files changed, 45 insertions, 480 deletions
diff --git a/.config/nvim/after/ftdetect/c.lua b/.config/nvim/after/ftdetect/c.lua new file mode 100644 index 0000000..a518a11 --- /dev/null +++ b/.config/nvim/after/ftdetect/c.lua @@ -0,0 +1,6 @@ +vim.api.nvim_create_autocmd({'BufRead', 'BufNewFile'}, { + pattern = '*.[ch]', + callback = function() + vim.bo.filetype = 'c' + end, +}) diff --git a/.config/nvim/after/ftdetect/c.vim b/.config/nvim/after/ftdetect/c.vim deleted file mode 100644 index 609b487..0000000 --- a/.config/nvim/after/ftdetect/c.vim +++ /dev/null @@ -1 +0,0 @@ -au BufRead,BufNewFile *.[ch] set ft=c diff --git a/.config/nvim/after/ftdetect/nroff.lua b/.config/nvim/after/ftdetect/nroff.lua new file mode 100644 index 0000000..592f620 --- /dev/null +++ b/.config/nvim/after/ftdetect/nroff.lua @@ -0,0 +1,6 @@ +vim.api.nvim_create_autocmd({'BufRead', 'BufNewFile'}, { + pattern = '*.[1-7]', + callback = function() + vim.bo.filetype = 'nroff' + end, +}) diff --git a/.config/nvim/after/ftdetect/nroff.vim b/.config/nvim/after/ftdetect/nroff.vim deleted file mode 100644 index f1c3d67..0000000 --- a/.config/nvim/after/ftdetect/nroff.vim +++ /dev/null @@ -1 +0,0 @@ -au BufRead,BufNewFile *.[1-7] setf nroff diff --git a/.config/nvim/after/ftplugin/c.lua b/.config/nvim/after/ftplugin/c.lua index 7f8d336..6058e31 100644 --- a/.config/nvim/after/ftplugin/c.lua +++ b/.config/nvim/after/ftplugin/c.lua @@ -1,3 +1,14 @@ -local lib = require('mango.lib') +vim.bo.commentstring = '/* %s */' -lib.set_tab_width(4, true) +vim.keymap.set('v', '<localleader>=', ":'<'>!clang-format -style=file -<CR>", { + desc = 'Format the current selection with Clang Format', +}) + +vim.keymap.set('n', 'K', function() + vim.cmd [[ + execute "silent !man -Tpdf '" . expand('<cword>') . "' | zathura - &" + ]] +end, { + buffer = 0, + desc = 'View the manual page for the word under the cursor', +}) diff --git a/.config/nvim/after/ftplugin/css.lua b/.config/nvim/after/ftplugin/css.lua deleted file mode 100644 index 01efc8f..0000000 --- a/.config/nvim/after/ftplugin/css.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(8, true) diff --git a/.config/nvim/after/ftplugin/ebnf.lua b/.config/nvim/after/ftplugin/ebnf.lua index b1bb817..264b539 100644 --- a/.config/nvim/after/ftplugin/ebnf.lua +++ b/.config/nvim/after/ftplugin/ebnf.lua @@ -1,2 +1 @@ -require('Comment.ft').ebnf = { '(*%s*)', '(*%s*)' } -vim.bo.commentstring = '(*%s*)' +vim.bo.commentstring = '(* %s *)' diff --git a/.config/nvim/after/ftplugin/gitcommit.lua b/.config/nvim/after/ftplugin/gitcommit.lua index 9aa3038..21934e4 100644 --- a/.config/nvim/after/ftplugin/gitcommit.lua +++ b/.config/nvim/after/ftplugin/gitcommit.lua @@ -1 +1 @@ -vim.opt_local.expandtab = true +vim.bo.expandtab = true diff --git a/.config/nvim/after/ftplugin/gitrebase.lua b/.config/nvim/after/ftplugin/gitrebase.lua index 948ee30..00ee21a 100644 --- a/.config/nvim/after/ftplugin/gitrebase.lua +++ b/.config/nvim/after/ftplugin/gitrebase.lua @@ -1,6 +1,5 @@ -local ts_utils = require('nvim-treesitter.ts_utils') - local function map(lhs, rhs) + local ts_utils = require('nvim-treesitter.ts_utils') vim.keymap.set('n', lhs, function() local node = ts_utils.get_node_at_cursor() if node == nil then @@ -22,7 +21,8 @@ local function map(lhs, rhs) }) end +map('d', 'drop') +map('f', 'fixup') map('p', 'pick') map('r', 'reword') map('s', 'squash') -map('f', 'fixup') diff --git a/.config/nvim/after/ftplugin/go.lua b/.config/nvim/after/ftplugin/go.lua deleted file mode 100644 index 7f8d336..0000000 --- a/.config/nvim/after/ftplugin/go.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(4, true) diff --git a/.config/nvim/after/ftplugin/gsp.lua b/.config/nvim/after/ftplugin/gsp.lua deleted file mode 100644 index 50a85a4..0000000 --- a/.config/nvim/after/ftplugin/gsp.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(2, true) diff --git a/.config/nvim/after/ftplugin/help.lua b/.config/nvim/after/ftplugin/help.lua new file mode 100644 index 0000000..0b15270 --- /dev/null +++ b/.config/nvim/after/ftplugin/help.lua @@ -0,0 +1,8 @@ +vim.api.nvim_create_autocmd('BufWinEnter', { + desc = 'Open (neo)vim help pages in a vertical split', + group = vim.api.nvim_create_augroup('mango-vert-help', { clear = true }), + buffer = 0, + callback = function() + vim.cmd.wincmd 'L' + end, +}) diff --git a/.config/nvim/after/ftplugin/html.lua b/.config/nvim/after/ftplugin/html.lua deleted file mode 100644 index 50a85a4..0000000 --- a/.config/nvim/after/ftplugin/html.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(2, true) diff --git a/.config/nvim/after/ftplugin/htmldjango.lua b/.config/nvim/after/ftplugin/htmldjango.lua deleted file mode 120000 index d805bec..0000000 --- a/.config/nvim/after/ftplugin/htmldjango.lua +++ /dev/null @@ -1 +0,0 @@ -html.lua
\ No newline at end of file diff --git a/.config/nvim/after/ftplugin/lex.lua b/.config/nvim/after/ftplugin/lex.lua deleted file mode 100644 index 7f8d336..0000000 --- a/.config/nvim/after/ftplugin/lex.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(4, true) diff --git a/.config/nvim/after/ftplugin/lua.lua b/.config/nvim/after/ftplugin/lua.lua deleted file mode 100644 index 7f8d336..0000000 --- a/.config/nvim/after/ftplugin/lua.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(4, true) diff --git a/.config/nvim/after/ftplugin/mail.lua b/.config/nvim/after/ftplugin/mail.lua index 599950a..72f99e9 100644 --- a/.config/nvim/after/ftplugin/mail.lua +++ b/.config/nvim/after/ftplugin/mail.lua @@ -1,5 +1,2 @@ -local lib = require('mango.lib') - -lib.set_tab_width(2, true) -vim.opt_local.expandtab = true -vim.opt_local.textwidth = 73 +vim.bo.expandtab = true +vim.bo.textwidth = 73 diff --git a/.config/nvim/after/ftplugin/make.lua b/.config/nvim/after/ftplugin/make.lua deleted file mode 100644 index 01efc8f..0000000 --- a/.config/nvim/after/ftplugin/make.lua +++ /dev/null @@ -1,3 +0,0 @@ -local lib = require('mango.lib') - -lib.set_tab_width(8, true) diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua index 1b0dfd2..3469231 100644 --- a/.config/nvim/after/ftplugin/markdown.lua +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -1,2 +1,2 @@ -vim.opt_local.textwidth = 80 -vim.opt_local.expandtab = true +vim.bo.expandtab = true +vim.bo.textwidth = 80 diff --git a/.config/nvim/after/ftplugin/nroff.lua b/.config/nvim/after/ftplugin/nroff.lua index 484a35d..1532c29 100644 --- a/.config/nvim/after/ftplugin/nroff.lua +++ b/.config/nvim/after/ftplugin/nroff.lua @@ -1 +1 @@ -vim.opt_local.textwidth = 73 +vim.bo.textwidth = 73 diff --git a/.config/nvim/after/ftplugin/python.lua b/.config/nvim/after/ftplugin/python.lua index a97fe2e..c37615b 100644 --- a/.config/nvim/after/ftplugin/python.lua +++ b/.config/nvim/after/ftplugin/python.lua @@ -1,2 +1 @@ -vim.opt_local.textwidth = 100 -vim.opt_local.expandtab = false +vim.bo.expandtab = false diff --git a/.config/nvim/after/ftplugin/query.lua b/.config/nvim/after/ftplugin/query.lua index 9aa3038..21934e4 100644 --- a/.config/nvim/after/ftplugin/query.lua +++ b/.config/nvim/after/ftplugin/query.lua @@ -1 +1 @@ -vim.opt_local.expandtab = true +vim.bo.expandtab = true diff --git a/.config/nvim/after/ftplugin/rust.lua b/.config/nvim/after/ftplugin/rust.lua deleted file mode 100644 index a97fe2e..0000000 --- a/.config/nvim/after/ftplugin/rust.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.opt_local.textwidth = 100 -vim.opt_local.expandtab = false diff --git a/.config/nvim/after/plugin/colors.lua b/.config/nvim/after/plugin/colors.lua deleted file mode 100644 index 779c60d..0000000 --- a/.config/nvim/after/plugin/colors.lua +++ /dev/null @@ -1,14 +0,0 @@ -local nohl = { bg = "surface" } - -require('rose-pine').setup { - styles = { - transparency = true, - }, - highlight_groups = { - Pmenu = nohl, - StatusLine = nohl, - StatusLineNC = nohl, - }, -} - -vim.cmd.colorscheme('rose-pine') diff --git a/.config/nvim/after/plugin/comment.lua b/.config/nvim/after/plugin/comment.lua deleted file mode 100644 index 933d7b7..0000000 --- a/.config/nvim/after/plugin/comment.lua +++ /dev/null @@ -1 +0,0 @@ -require('Comment').setup {} diff --git a/.config/nvim/after/plugin/emmet.lua b/.config/nvim/after/plugin/emmet.lua deleted file mode 100644 index 56e67db..0000000 --- a/.config/nvim/after/plugin/emmet.lua +++ /dev/null @@ -1 +0,0 @@ -vim.g.user_emmet_install = false diff --git a/.config/nvim/after/plugin/fugitive.lua b/.config/nvim/after/plugin/fugitive.lua deleted file mode 100644 index 6e1b92d..0000000 --- a/.config/nvim/after/plugin/fugitive.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', '<leader>gs', vim.cmd.Git) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua deleted file mode 100644 index e0684e2..0000000 --- a/.config/nvim/after/plugin/lsp.lua +++ /dev/null @@ -1,49 +0,0 @@ -local conf = require('lspconfig') - -conf.clangd.setup { - cmd = {'clangd', '-header-insertion=never'} -} -conf.gopls.setup {} -conf.rust_analyzer.setup {} -conf.lua_ls.setup { - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - }, - diagnostics = { - globals = { - 'vim', - 'require', - }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true), - }, - telemetry = { - enable = false, - }, - }, - }, -} - -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('MangoLspConfig', {}), - callback = function(ev) - local function remap(mode, map, fn) - vim.keymap.set(mode, map, fn, { buffer = ev.buf }) - end - - vim.diagnostic.disable() - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - remap('n', 'K', vim.lsp.buf.hover) - remap('n', 'gd', vim.lsp.buf.definition) - remap('n', 'gi', vim.lsp.buf.implementation) - remap('n', 'gr', vim.lsp.buf.rename) - remap('n', 'gt', vim.lsp.buf.type_definition) - remap('n', 'g=', function() vim.lsp.buf.format { async = true } end) - remap('n', ']d', vim.diagnostic.goto_prev) - remap('n', '[d', vim.diagnostic.goto_next) - remap('n', '<leader>la', vim.lsp.buf.code_action) - end, -}) diff --git a/.config/nvim/after/plugin/luasnip.lua b/.config/nvim/after/plugin/luasnip.lua deleted file mode 100644 index 5486aab..0000000 --- a/.config/nvim/after/plugin/luasnip.lua +++ /dev/null @@ -1,202 +0,0 @@ -local ls = require('luasnip') -local ts_utils = require('nvim-treesitter.ts_utils') -local ts_locals = require('nvim-treesitter.locals') - -local c = ls.choice_node -local d = ls.dynamic_node -local f = ls.function_node -local i = ls.insert_node -local s = ls.s -local sn = ls.snippet_node -local t = ls.text_node -local fmt = require('luasnip.extras.fmt').fmt - -local function same(index) - return f(function(args) - return args[1] - end, { index }) -end - -ls.config.set_config { - history = true, - updateevents = 'TextChanged,TextChangedI', -} - -ls.add_snippets('lua', { - s('req', fmt([[local {} = require('{}')]], { - f(function(name) - local xs = vim.split(name[1][1], '.', { plain = true }) - return xs[#xs] or '' - end, { 1 }), - i(1), - })), -}) - -local function is_ptr(str) - return string.find(str, '*', 1, true) ~= nil -end - -local function is_num(str) - return vim.regex( - '\\v^(' - .. 'u?int(8|16|32|64)?' - .. '|byte' - .. '|complex(64|128)' - .. '|float(32|64)' - .. '|rune' - .. '|uintptr' - .. ')$' - ):match_str(str) ~= nil -end - -local transforms = { - bool = 'false', - string = '""', - error = 'err', - [is_num] = '0', - [is_ptr] = 'nil', -} - -local transform = function(text) - local condition_matches = function(condition, ...) - if type(condition) == 'string' then - return condition == text - else - return condition(...) - end - end - - for condition, result in pairs(transforms) do - if condition_matches(condition, text) then - return t(result) - end - end - - return t(text .. '{}') -end - -local handlers = { - parameter_list = function(node) - local result = {} - - local count = node:named_child_count() - for idx = 0, count - 1 do - local matching_node = node:named_child(idx) - local type_node = matching_node:field('type')[1] - table.insert(result, transform( - vim.treesitter.get_node_text(type_node, 0) - )) - if idx ~= count - 1 then - table.insert(result, t({ ', ' })) - end - end - - return result - end, - - type_identifier = function(node) - local text = vim.treesitter.get_node_text(node, 0) - return { transform(text) } - end, -} - -local function_node_types = { - function_declaration = true, - method_declaration = true, - func_literal = true, -} - -local function go_result_type() - local cursor_node = ts_utils.get_node_at_cursor() - if cursor_node == nil then - print('Unable to find position') - return t('') - end - local scope = ts_locals.get_scope_tree(cursor_node, 0) - - local function_node - for _, v in ipairs(scope) do - if function_node_types[v:type()] then - function_node = v - break - end - end - - if not function_node then - print('Not inside of a function') - return t('') - end - - local query = vim.treesitter.query.parse('go', [[ - [ - (method_declaration result: (_) @id) - (function_declaration result: (_) @id) - (func_literal result: (_) @id) - ] - ]]) - for _, node in query:iter_captures(function_node, 0) do - if handlers[node:type()] then - return handlers[node:type()](node) - end - end -end - -ls.add_snippets('go', { - s( - 'ife', - fmt( - [[ - if err != nil { - return <> - } - ]], - { - d(1, function() - return sn(nil, go_result_type()) - end), - }, - { - delimiters = '<>', - } - ) - ), -}) - - -ls.add_snippets('c', { - s( - 'gu', - fmt( - [[ - #ifndef {}_H - #define {}_H - - {} - - #endif /* !{}_H */ - ]], - { i(1), same(1), i(0), same(1), } - ) - ), -}) - -vim.keymap.set({ 'i', 's' }, '<C-l>', function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end -end) -vim.keymap.set('i', '<C-h>', function() - if ls.jumpable(-1) then - ls.jump(-1) - end -end) -vim.keymap.set('i', '<C-k>', function() - if ls.choice_active() then - ls.change_choice(-1) - end -end) -vim.keymap.set('i', '<C-j>', function() - if ls.choice_active() then - ls.change_choice(1) - end -end) diff --git a/.config/nvim/after/plugin/nvim-cmp.lua b/.config/nvim/after/plugin/nvim-cmp.lua deleted file mode 100644 index 399d5a3..0000000 --- a/.config/nvim/after/plugin/nvim-cmp.lua +++ /dev/null @@ -1,32 +0,0 @@ -local capabilities = require('cmp_nvim_lsp').default_capabilities() -local cmp = require('cmp') -local conf = require('lspconfig') -local snip = require('luasnip') - -conf['clangd'].setup { capabilities = capabilities } -conf['gopls'].setup { capabilities = capabilities } -conf['lua_ls'].setup { capabilities = capabilities } -conf['rust_analyzer'].setup { capabilities = capabilities } -cmp.setup { - snippet = { - expand = function(args) - snip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - ['<C-k>'] = cmp.mapping.select_prev_item(), - ['<C-j>'] = cmp.mapping.select_next_item(), - ['<C-e>'] = cmp.mapping.abort(), - ['<CR>'] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'path' }, - { name = 'luasnip' }, - }, { - { name = 'buffer', length = 5 }, - }), - experimental = { - ghost_text = true, - } -} diff --git a/.config/nvim/after/plugin/sort-motion.lua b/.config/nvim/after/plugin/sort-motion.lua deleted file mode 100644 index d408de8..0000000 --- a/.config/nvim/after/plugin/sort-motion.lua +++ /dev/null @@ -1 +0,0 @@ -vim.g.sort_motion_flags = 'l' diff --git a/.config/nvim/after/plugin/surround.lua b/.config/nvim/after/plugin/surround.lua deleted file mode 100644 index 605b1eb..0000000 --- a/.config/nvim/after/plugin/surround.lua +++ /dev/null @@ -1,27 +0,0 @@ -require('nvim-surround').setup { - surrounds = { - ['’'] = { - add = { '‘', '’' }, - find = '‘[^‘’]*’', - delete = '^(‘)().-(’)()$' - }, - - ['‘'] = { - add = { '‘ ', ' ’' }, - find = '‘[^‘’]*’', - delete = '^(‘ *)().-( *’)()$' - }, - - ['”'] = { - add = { '“', '”' }, - find = '“[^“”]*”', - delete = '^(“)().-(”)()$' - }, - - ['“'] = { - add = { '“ ', ' ”' }, - find = '“[^“”]*”', - delete = '^(“ *)().-( *”)()$' - }, - } -} diff --git a/.config/nvim/after/plugin/treesitter-context.lua b/.config/nvim/after/plugin/treesitter-context.lua deleted file mode 100644 index 27af4e8..0000000 --- a/.config/nvim/after/plugin/treesitter-context.lua +++ /dev/null @@ -1,8 +0,0 @@ -require('treesitter-context').setup { - enable = true, - max_lines = 2, - multiline_threshold = 2, - line_numbers = true, - trim_scope = 'inner', - mode = 'cursor', -} diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua deleted file mode 100644 index e441371..0000000 --- a/.config/nvim/after/plugin/treesitter.lua +++ /dev/null @@ -1,89 +0,0 @@ -local config = require('nvim-treesitter.parsers').get_parser_configs() -config.gsp = { - install_info = { - url = 'https://git.sr.ht/~mango/tree-sitter-gsp', - files = {'src/parser.c'}, - }, - filetype = 'gsp', -} - -require('nvim-treesitter.configs').setup { - ensure_installed = { - 'c', - 'gsp', - 'vim', - 'vimdoc', - }, - - sync_install = false, - auto_install = true, - - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - - incremental_selection = { - enable = true, - keymaps = { - init_selection = '<C-Space>', - node_incremental = '<C-Space>', - node_decremental = '<C-s>', - } - }, - - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['ab'] = '@block.outer', - ['ib'] = '@block.inner', - ['ac'] = '@comment.outer', - ['ic'] = '@comment.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['an'] = '@node.outer', - ['in'] = '@node.inner', - ['at'] = '@text.outer', - ['it'] = '@text.outer', - }, - }, - move = { - enable = true, - set_jumps = true, - goto_next_start = { - [']c'] = '@comment.outer', - [']f'] = '@function.outer', - [']b'] = '@block.outer', - [']n'] = '@node.outer', - [']t'] = '@text.outer', - }, - goto_next_end = { - [']C'] = '@comment.outer', - [']F'] = '@function.outer', - [']B'] = '@block.outer', - [']N'] = '@node.outer', - [']T'] = '@text.outer', - }, - goto_previous_start = { - ['[c'] = '@comment.outer', - ['[f'] = '@function.outer', - ['[b'] = '@block.outer', - ['[n'] = '@node.outer', - ['[t'] = '@text.outer', - }, - goto_previous_end = { - ['[C'] = '@comment.outer', - ['[F'] = '@function.outer', - ['[B'] = '@block.outer', - ['[N'] = '@node.outer', - ['[T'] = '@text.outer', - }, - }, - }, - - indent = { - enable = true, - }, -} diff --git a/.config/nvim/after/plugin/undotree.lua b/.config/nvim/after/plugin/undotree.lua deleted file mode 100644 index a346462..0000000 --- a/.config/nvim/after/plugin/undotree.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle) diff --git a/.config/nvim/after/syntax/c.vim b/.config/nvim/after/syntax/c.vim deleted file mode 100644 index a2c7c43..0000000 --- a/.config/nvim/after/syntax/c.vim +++ /dev/null @@ -1 +0,0 @@ -hi link @lsp.type.macro Macro diff --git a/.config/nvim/after/syntax/diff.vim b/.config/nvim/after/syntax/diff.vim deleted file mode 100644 index e086592..0000000 --- a/.config/nvim/after/syntax/diff.vim +++ /dev/null @@ -1,3 +0,0 @@ -hi link @text.diff.add DiffAdd -hi link @text.diff.delete DiffDelete -hi link @attribute diffLine diff --git a/.config/nvim/after/syntax/yacc.vim b/.config/nvim/after/syntax/yacc.vim deleted file mode 100644 index fe6603e..0000000 --- a/.config/nvim/after/syntax/yacc.vim +++ /dev/null @@ -1,5 +0,0 @@ -syn match yaccDefines '^%\(debug\|header\|output\)\>' -syn match yaccKey '^\s*%\(nterm\|precedence\)\>' contained -syn match yaccType '<[a-zA-Z_][a-zA-Z0-9_]*\s*\*>' contains=yaccBrkt contained -syn match yaccString '"[^"]*"' contained -syn match yaccVar '@\(\$\|\d\+\)' containedin=cParen,cPreProc,cMulti contained |