my experiments with nvim
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

dump

Signed-off-by: oppiliappan <me@oppi.li>

+401 -155
+28
ftplugin/cobol.vim
··· 1 + function! CobolFmt() 2 + " Save the current buffer to a temporary input file 3 + let l:input = tempname() 4 + let l:output = tempname() 5 + 6 + " Write the current buffer to the temporary input file 7 + silent! execute 'write!' fnameescape(l:input) 8 + 9 + " Run the formatter 10 + silent! execute '!./changeformat' shellescape(l:input) shellescape(l:output) "TOFIXED" 11 + 12 + 13 + " Check if the output file was successfully created 14 + if filereadable(l:output) 15 + " Replace the buffer content with the formatted output 16 + silent! execute '%delete _' 17 + silent! execute '0read ' . fnameescape(l:output) 18 + silent! execute 'normal! gg' 19 + " Clean up temporary files 20 + call delete(l:input) 21 + call delete(l:output) 22 + else 23 + " Notify the user if formatting failed 24 + echoerr "Formatter failed to produce output." 25 + call delete(l:input) 26 + endif 27 + endfunction 28 + set formatprg=rustfmt
+1
ftplugin/java.vim
··· 1 + set formatprg=google-java-format\ -
+15 -1
ftplugin/javascript.vim
··· 2 2 setlocal shiftwidth=2 3 3 setlocal softtabstop=2 4 4 setlocal formatoptions=croq 5 - setlocal expandtab 5 + setlocal noexpandtab 6 6 setlocal autoindent 7 7 setlocal smarttab 8 8 9 + function! s:RunBiome() 10 + let output = system("biome" . " " . "format" . " " . "--fix" . " " . bufname("%")) 11 + if v:shell_error != 0 12 + echom output 13 + elseif empty(output) 14 + call s:OverwriteBuffer(output) 15 + write 16 + endif 17 + endfunction 18 + 19 + augroup JsFmt 20 + autocmd! 21 + autocmd BufWritePost *.js | call s:RunBiome() | silent make! <afile> | silent redraw! 22 + augroup END
+1
ftplugin/json.vim
··· 1 + set formatprg=jq
+1
ftplugin/lhaskell.vim
··· 1 + /home/op/.config/nvim/ftplugin/haskell.vim
+1 -1
ftplugin/typescript.vim
··· 2 2 setlocal shiftwidth=2 3 3 setlocal softtabstop=2 4 4 setlocal formatoptions=croq 5 - setlocal expandtab 5 + setlocal noexpandtab 6 6 setlocal autoindent 7 7 setlocal smarttab
+11
lua/clipboard.lua
··· 1 + vim.g.clipboard = { 2 + name = 'OSC 52', 3 + copy = { 4 + ['+'] = require('vim.ui.clipboard.osc52').copy('+'), 5 + ['*'] = require('vim.ui.clipboard.osc52').copy('*'), 6 + }, 7 + paste = { 8 + ['+'] = require('vim.ui.clipboard.osc52').paste('+'), 9 + ['*'] = require('vim.ui.clipboard.osc52').paste('*'), 10 + }, 11 + }
+63 -53
lua/completions.lua
··· 1 - local cmp = require 'cmp' 2 - 3 - cmp.setup({ 4 - snippet = { 5 - expand = function(args) end, 6 - }, 7 - mapping = { 8 - ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), 9 - ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), 10 - ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), 11 - ['<C-y>'] = cmp.config.disable, 12 - ['<C-e>'] = cmp.mapping({ 13 - i = cmp.mapping.abort(), 14 - c = cmp.mapping.close(), 15 - }), 16 - ['<CR>'] = cmp.mapping.confirm({ select = true }), 17 - 18 - ['<C-n>'] = cmp.mapping(function(fallback) 19 - if cmp.visible() then 20 - cmp.select_next_item() 21 - else 22 - fallback() 23 - end 24 - end, { 'i', 's', 'c' }), 25 - 26 - ['<C-p>'] = cmp.mapping(function(fallback) 27 - if cmp.visible() then 28 - cmp.select_prev_item() 29 - else 30 - fallback() 31 - end 32 - end, { 'i', 's', 'c' }), 33 - }, 34 - sources = cmp.config.sources({ 35 - { name = 'nvim_lsp' }, 36 - }, { 37 - { name = 'buffer' }, 38 - }) 39 - }) 40 - 41 - cmp.setup.cmdline('/', { 42 - sources = { 43 - { name = 'buffer' } 44 - } 45 - }) 46 - 47 - cmp.setup.cmdline(':', { 48 - sources = cmp.config.sources({ 49 - { name = 'path' } 50 - }, { 51 - { name = 'cmdline' } 52 - }) 53 - }) 1 + -- local cmp = require 'cmp' 2 + -- 3 + -- cmp.setup({ 4 + -- snippet = { 5 + -- expand = function(args) end, 6 + -- }, 7 + -- window = { 8 + -- completion = cmp.config.window.bordered(), 9 + -- documentation = cmp.config.window.bordered(), 10 + -- }, 11 + -- view = { 12 + -- docs = { 13 + -- auto_open = false 14 + -- } 15 + -- }, 16 + -- mapping = { 17 + -- ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), 18 + -- ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), 19 + -- ['<CR>'] = cmp.mapping.confirm { 20 + -- select = false, 21 + -- behavior = cmp.ConfirmBehavior.Insert 22 + -- }, 23 + -- ['<Tab>'] = cmp.mapping(function(fallback) 24 + -- if cmp.visible() then 25 + -- cmp.select_next_item() 26 + -- else 27 + -- fallback() 28 + -- end 29 + -- end, { 'i', 's', 'c' }), 30 + -- ['<C-n>'] = cmp.mapping(function(fallback) 31 + -- if cmp.visible() then 32 + -- cmp.select_next_item() 33 + -- else 34 + -- fallback() 35 + -- end 36 + -- end, { 'i', 's', 'c' }), 37 + -- 38 + -- ['<C-p>'] = cmp.mapping(function(fallback) 39 + -- if cmp.visible() then 40 + -- cmp.select_prev_item() 41 + -- else 42 + -- fallback() 43 + -- end 44 + -- end, { 'i', 's', 'c' }), 45 + -- }, 46 + -- sources = cmp.config.sources({ 47 + -- { name = 'nvim_lsp' }, 48 + -- }) 49 + -- }) 50 + -- 51 + -- cmp.setup.cmdline('/', { 52 + -- sources = { 53 + -- { name = 'buffer' } 54 + -- } 55 + -- }) 56 + -- 57 + -- cmp.setup.cmdline(':', { 58 + -- sources = cmp.config.sources({ 59 + -- { name = 'path' } 60 + -- }, { 61 + -- { name = 'cmdline' } 62 + -- }) 63 + -- })
+72 -51
lua/lsp.lua
··· 1 - local nvim_lsp = require('lspconfig') 2 - local on_attach = function(client, bufnr) 3 - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end 4 - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end 1 + vim.o.winborder = 'rounded' 2 + vim.cmd[[set completeopt+=menuone,noselect,popup]] 3 + 4 + vim.api.nvim_create_autocmd('LspAttach', { 5 + group = vim.api.nvim_create_augroup('my.lsp', {}), 6 + callback = function(args) 7 + local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) 8 + 9 + -- goto impl 10 + if client:supports_method('textDocument/implementation') then 11 + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) 12 + end 5 13 6 - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') 14 + -- autocomplete 15 + if client:supports_method('textDocument/completion') then 16 + vim.lsp.completion.enable(true, client.id, args.buf, { 17 + autotrigger = true, 18 + convert = function(item) 19 + return { abbr = item.label:gsub('%b()', '') } 20 + end, 21 + }) 22 + end 23 + 24 + -- format on save 25 + if not client:supports_method('textDocument/willSaveWaitUntil') 26 + and client:supports_method('textDocument/formatting') then 27 + vim.api.nvim_create_autocmd('BufWritePre', { 28 + group = vim.api.nvim_create_augroup('my.lsp', {clear=false}), 29 + buffer = args.buf, 30 + callback = function() 31 + vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) 32 + end, 33 + }) 34 + end 7 35 8 36 -- Mappings. 9 37 local bufopts = { noremap=true, silent=true, buffer=bufnr } 10 - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) 38 + vim.keymap.set('n', 'gD', '<C-w>g}', { noremap = true, silent = true }) 11 39 vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) 40 + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) 41 + vim.keymap.set('n', '<space>r', vim.lsp.buf.rename, bufopts) 12 42 vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) 13 - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) 14 43 vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) 15 44 16 45 local opts = { noremap=true, silent=true } 17 46 vim.keymap.set('n', '<space>d', vim.diagnostic.open_float, opts) 18 - vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) 19 - vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) 20 - vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts) 47 + vim.keymap.set('n', '[d', function() vim.diagnostic.jump({count=-1, float=true}) end, opts) 48 + vim.keymap.set('n', ']d', function() vim.diagnostic.jump({count= 1, float=true}) end, opts) 49 + vim.keymap.set('n', '<space>q', vim.diagnostic.setqflist, opts) 21 50 vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) 51 + vim.keymap.set('n', '<space>a', vim.lsp.buf.code_action, bufopts) 52 + 53 + end, 54 + }) 55 + 56 + 57 + local function on_list(options) 58 + vim.fn.setqflist({}, ' ', options) 59 + vim.cmd.cfirst() 22 60 end 23 61 24 - local servers = { "hls", "bashls" } 62 + local servers = { "bashls", "gopls", "ts_ls", "hls", "ocamllsp", "rust_analyzer" } 25 63 for _, lsp in ipairs(servers) do 26 - nvim_lsp[lsp].setup { 27 - on_attach = on_attach, 28 - } 64 + vim.lsp.enable(lsp) 29 65 end 30 66 31 - local capabilities = require('cmp_nvim_lsp') 32 - .default_capabilities(vim.lsp.protocol.make_client_capabilities()) 67 + vim.lsp.config('rust_analyzer', { 68 + settings = { 69 + ["rust-analyzer"] = { 70 + procMacro = { 71 + enable = true, 72 + }, 73 + buildScripts = { 74 + rebuildOnSave = true, 75 + }, 76 + cargo = { 77 + allFeatures = false, 78 + }, 79 + checkOnSave = true, 80 + cachePriming = { 81 + enable = true, 82 + }, 83 + }, 84 + }, 85 + }) 33 86 34 - capabilities.textDocument.completion.completionItem.snippetSupport = true 35 - 36 - -- nvim_lsp.rust_analyzer.setup { 37 - -- on_attach = on_attach, 38 - -- settings = { 39 - -- ["rust-analyzer"] = { 40 - -- procMacro = { 41 - -- enable = true 42 - -- }, 43 - -- cargo = { 44 - -- allFeatures = false, 45 - -- }, 46 - -- checkOnSave = false, 47 - -- }, 48 - -- }, 49 - -- } 50 - 51 - nvim_lsp.ccls.setup { 52 - capabilities = capabilities, 53 - on_attach = on_attach, 54 - init_options = { 55 - index = { 56 - threads = 0; 57 - }; 58 - clang = { 59 - extraArgs = { "-fopenmp" }; 60 - excludeArgs = { "-frounding-math" } ; 61 - }; 62 - } 63 - } 64 - 65 - nvim_lsp.jdtls.setup{ 66 - cmd = {"jdtls"}; 67 - } 68 - 87 + vim.lsp.config('ocamllsp', { 88 + cmd = { 'dune', 'tools', 'exec', 'ocamllsp' }, 89 + })
+158
lua/tangled-permalink.lua
··· 1 + local M = {} 2 + 3 + -- get git remote url and extract username/repo 4 + local function get_repo_info() 5 + local handle = io.popen("git config --get remote.origin.url 2>/dev/null") 6 + if not handle then 7 + return nil, "Failed to execute git command" 8 + end 9 + 10 + local remote = handle:read("*a") 11 + handle:close() 12 + 13 + if remote == "" then 14 + return nil, "No git remote found" 15 + end 16 + 17 + -- Remove trailing whitespace/newline 18 + remote = remote:gsub("%s+$", "") 19 + 20 + -- https://host/username/repo or https://host/username/repo.git 21 + local user_repo = remote:match("[:/]([^:/]+/[^/]+)%.?g?i?t?$") 22 + 23 + if not user_repo then 24 + return nil, "Could not parse repository from remote: " .. remote 25 + end 26 + 27 + -- Remove .git suffix if present 28 + user_repo = user_repo:gsub("%.git$", "") 29 + 30 + return user_repo, nil 31 + end 32 + 33 + -- Get current git commit hash 34 + local function get_commit_hash() 35 + local handle = io.popen("git rev-parse HEAD 2>/dev/null") 36 + if not handle then 37 + return nil, "Failed to execute git command" 38 + end 39 + 40 + local hash = handle:read("*a") 41 + handle:close() 42 + 43 + if hash == "" then 44 + return nil, "Not in a git repository" 45 + end 46 + 47 + return hash:gsub("%s+$", ""), nil 48 + end 49 + 50 + -- Get file path relative to git root 51 + local function get_relative_path(absolute_path) 52 + local handle = io.popen("git rev-parse --show-toplevel 2>/dev/null") 53 + if not handle then 54 + return nil, "Failed to execute git command" 55 + end 56 + 57 + local git_root = handle:read("*a") 58 + handle:close() 59 + 60 + if git_root == "" then 61 + return nil, "Not in a git repository" 62 + end 63 + 64 + git_root = git_root:gsub("%s+$", "") 65 + 66 + -- Remove git root from absolute path 67 + local rel_path = absolute_path:gsub("^" .. git_root .. "/", "") 68 + return rel_path, nil 69 + end 70 + 71 + -- copy text to system clipboard 72 + local function copy_to_clipboard(text) 73 + vim.fn.setreg("+", text) 74 + vim.fn.setreg('"', text) 75 + end 76 + 77 + -- generate and copy permalink 78 + function M.copy_permalink() 79 + local repo, err = get_repo_info() 80 + if err then 81 + vim.notify("Error: " .. err, vim.log.levels.ERROR) 82 + return 83 + end 84 + 85 + local commit, err = get_commit_hash() 86 + if err then 87 + vim.notify("Error: " .. err, vim.log.levels.ERROR) 88 + return 89 + end 90 + 91 + local filepath = vim.fn.expand("%:p") 92 + local rel_path, err = get_relative_path(filepath) 93 + if err then 94 + vim.notify("Error: " .. err, vim.log.levels.ERROR) 95 + return 96 + end 97 + 98 + -- get line numbers 99 + local mode = vim.fn.mode() 100 + local start_line, end_line 101 + 102 + if mode == "v" or mode == "V" or mode == "\22" then -- visual modes 103 + start_line = vim.fn.line("v") 104 + end_line = vim.fn.line(".") 105 + 106 + -- ensure start_line <= end_line 107 + if start_line > end_line then 108 + start_line, end_line = end_line, start_line 109 + end 110 + else 111 + start_line = vim.fn.line(".") 112 + end_line = start_line 113 + end 114 + 115 + -- construct url 116 + local url = string.format( 117 + "https://tangled.org/%s/blob/%s/%s#L%d", 118 + repo, 119 + commit, 120 + rel_path, 121 + start_line 122 + ) 123 + 124 + -- add end line if selection spans multiple lines 125 + if end_line > start_line then 126 + url = url .. "-" .. end_line 127 + end 128 + 129 + -- copy to clipboard 130 + copy_to_clipboard(url) 131 + 132 + 133 + if end_line > start_line then 134 + vim.notify(string.format("Copied permalink for lines %d-%d", start_line, end_line), vim.log.levels.INFO) 135 + else 136 + vim.notify(string.format("Copied permalink for line %d", start_line), vim.log.levels.INFO) 137 + end 138 + end 139 + 140 + -- setup function to configure the plugin 141 + function M.setup(opts) 142 + opts = opts or {} 143 + vim.api.nvim_create_user_command( 144 + "TangledPermalink", 145 + function() 146 + M.copy_permalink() 147 + end, 148 + { range = true, desc = "Copy tangled.org permalink to clipboard" } 149 + ) 150 + end 151 + 152 + -- set up keybindings 153 + vim.keymap.set({"n", "v"}, "<leader>gl", M.copy_permalink, { 154 + desc = "Copy tangled.org permalink", 155 + silent = true 156 + }) 157 + 158 + return M
+41 -41
lua/treesitter.lua
··· 1 - require'nvim-treesitter.configs'.setup { 2 - highlight = { 3 - enable = false, 4 - -- disable = { "c"}, 5 - }, 6 - incremental_selection = { 7 - enable = true, 8 - keymaps = { 9 - init_selection = "gnn", 10 - node_incremental = "g}", 11 - scope_incremental = "grc", 12 - node_decremental = "g{", 13 - }, 14 - }, 15 - indent = { 16 - enable = false 17 - }, 18 - playground = { 19 - enable = true, 20 - disable = {}, 21 - updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code 22 - persist_queries = false, -- Whether the query persists across vim sessions 23 - keybindings = { 24 - toggle_query_editor = 'o', 25 - toggle_hl_groups = 'i', 26 - toggle_injected_languages = 't', 27 - toggle_anonymous_nodes = 'a', 28 - toggle_language_display = 'I', 29 - focus_language = 'f', 30 - unfocus_language = 'F', 31 - update = 'R', 32 - goto_node = '<cr>', 33 - show_help = '?', 34 - }, 35 - }, 36 - query_linter = { 37 - enable = true, 38 - use_virtual_text = true, 39 - lint_events = {"BufWrite", "CursorHold"}, 40 - }, 41 - } 1 + -- require'nvim-treesitter.configs'.setup { 2 + -- highlight = { 3 + -- enable = true, 4 + -- -- disable = { "c"}, 5 + -- }, 6 + -- incremental_selection = { 7 + -- enable = true, 8 + -- keymaps = { 9 + -- init_selection = "gnn", 10 + -- node_incremental = "g}", 11 + -- scope_incremental = "grc", 12 + -- node_decremental = "g{", 13 + -- }, 14 + -- }, 15 + -- indent = { 16 + -- enable = false 17 + -- }, 18 + -- playground = { 19 + -- enable = true, 20 + -- disable = {}, 21 + -- updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code 22 + -- persist_queries = false, -- Whether the query persists across vim sessions 23 + -- keybindings = { 24 + -- toggle_query_editor = 'o', 25 + -- toggle_hl_groups = 'i', 26 + -- toggle_injected_languages = 't', 27 + -- toggle_anonymous_nodes = 'a', 28 + -- toggle_language_display = 'I', 29 + -- focus_language = 'f', 30 + -- unfocus_language = 'F', 31 + -- update = 'R', 32 + -- goto_node = '<cr>', 33 + -- show_help = '?', 34 + -- }, 35 + -- }, 36 + -- query_linter = { 37 + -- enable = true, 38 + -- use_virtual_text = true, 39 + -- lint_events = {"BufWrite", "CursorHold"}, 40 + -- }, 41 + -- }
+1 -1
plugin/maps.vim
··· 16 16 nnoremap <Leader>e : Explore<cr> 17 17 nnoremap <Leader>t : call GetTabber()<cr> 18 18 nnoremap <Leader><ESC> : nohlsearch<cr> 19 - nnoremap <C-l> :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l> 19 + nnoremap <C-l> :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr>:cclose<cr>:lclose<cr><c-l> 20 20 nnoremap H H:exec 'norm! '. &scrolloff . 'k'<cr> 21 21 nnoremap L L:exec 'norm! '. &scrolloff . 'j'<cr> 22 22 nnoremap <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]'
+8 -7
plugin/statusline.vim
··· 83 83 let errs = luaeval("#vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })") 84 84 let warns = luaeval("#vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })") 85 85 if errs != 0 86 - call add(msgs, printf('%%5*%s×%%* ', errs)) 86 + call add(msgs, printf('%%1*%s×%%* ', errs)) 87 87 endif 88 88 if warns != 0 89 89 call add(msgs, printf('%%3*%s!%%* ', warns)) ··· 129 129 return l:line 130 130 endfunction 131 131 132 - set statusline=%!StatusLine('active') 133 - augroup MyStatusLine 134 - autocmd! 135 - autocmd WinEnter * setl statusline=%!StatusLine('active') 136 - autocmd WinLeave * setl statusline=%!StatusLine('inactive') 137 - augroup END 132 + " disable this plugin for now 133 + " set statusline=%!StatusLine('active') 134 + " augroup MyStatusLine 135 + " autocmd! 136 + " autocmd WinEnter * setl statusline=%!StatusLine('active') 137 + " autocmd WinLeave * setl statusline=%!StatusLine('inactive') 138 + " augroup END