diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..8493308 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,8 @@ +{ + "plugins": { + "scnvim": { + "rev": "876732590ef3f409c9705f3659fa1061db2dc7bf", + "src": "https://github.com/davidgranstrom/scnvim" + } + } +} diff --git a/plugin/10_options.lua b/plugin/10_options.lua index 7637e6e..b590349 100644 --- a/plugin/10_options.lua +++ b/plugin/10_options.lua @@ -16,7 +16,7 @@ -- reading. Consider preserving this or remove `-- stylua` lines to autoformat. -- General ==================================================================== -vim.g.mapleader = ' ' -- Use `` as key +vim.g.mapleader = ',' -- Use comma as key vim.o.mouse = 'a' -- Enable mouse vim.o.mousescroll = 'ver:25,hor:6' -- Customize mouse scroll diff --git a/plugin/20_keymaps.lua b/plugin/20_keymaps.lua index 9309059..9ea23ae 100644 --- a/plugin/20_keymaps.lua +++ b/plugin/20_keymaps.lua @@ -14,13 +14,6 @@ local nmap = function(lhs, rhs, desc) vim.keymap.set('n', lhs, rhs, { desc = desc }) end --- Paste linewise before/after current line --- Usage: `yiw` to yank a word and `]p` to put it on the next line. -nmap('[p', 'exe "put! " . v:register', 'Paste Above') -nmap(']p', 'exe "put " . v:register', 'Paste Below') - --- Many general mappings are created by 'mini.basics'. See 'plugin/30_mini.lua' - -- stylua: ignore start -- The next part (until `-- stylua: ignore end`) is aligned manually for easier -- reading. Consider preserving this or remove `-- stylua` lines to autoformat. @@ -38,10 +31,9 @@ nmap(']p', 'exe "put " . v:register', 'Paste Below') -- This is used to provide 'mini.clue' with extra clues. -- Add an entry if you create a new group. _G.Config.leader_group_clues = { - { mode = 'n', keys = 'a', desc = '+AI' }, { mode = 'n', keys = 'b', desc = '+Buffer' }, { mode = 'n', keys = 'e', desc = '+Explore/Edit' }, - { mode = 'n', keys = 'p', desc = '+Pick' }, + { mode = 'n', keys = 'f', desc = '+Pick' }, { mode = 'n', keys = 'g', desc = '+Git' }, { mode = 'n', keys = 'l', desc = '+Language' }, { mode = 'n', keys = 'm', desc = '+Map' }, @@ -68,12 +60,6 @@ local vmap_leader = function(suffix, rhs, desc) vim.keymap.set('v', '' .. suffix, rhs, { desc = desc }) end --- a is for 'AI' - -nmap_leader('ac', ':lua require("opencode").toggle()', 'Toggle Opencode') -nmap_leader('af', ':lua require("opencode").select()', 'Execute Opencode action...') -nmap_leader('aa', ':luat require("opencode").ask("@this: ", { submit = true })', 'Ask Opencode') - -- b is for 'Buffer'. Common usage: -- - `bs` - create scratch (temporary) buffer -- - `ba` - navigate to the alternative buffer @@ -82,11 +68,11 @@ local new_scratch_buffer = function() vim.api.nvim_win_set_buf(0, vim.api.nvim_create_buf(true, true)) end -nmap_leader('ba', 'b#', 'Alternate') -nmap_leader('bd', 'lua MiniBufremove.delete()', 'Delete') -nmap_leader('bD', 'lua MiniBufremove.delete(0, true)', 'Delete!') -nmap_leader('bs', new_scratch_buffer, 'Scratch') -nmap_leader('bw', 'write', 'Write') +nmap_leader('ba', 'b#', 'Alternate') +nmap_leader('bk', 'lua MiniBufremove.delete()', 'Kill') +nmap_leader('bK', 'lua MiniBufremove.delete(0, true)', 'KIIIILLL!') +nmap_leader('bs', new_scratch_buffer, 'Scratch') +nmap_leader('bw', 'write', 'Write') -- e is for 'Explore' and 'Edit'. Common usage: -- - `ed` - open explorer at current working directory @@ -104,15 +90,15 @@ local explore_quickfix = function() vim.cmd('copen') end -nmap_leader('ed', 'lua MiniFiles.open()', 'Directory') -nmap_leader('ef', explore_at_file, 'File directory') -nmap_leader('ei', 'edit $MYVIMRC', 'init.lua') -nmap_leader('ek', edit_plugin_file('20_keymaps.lua'), 'Keymaps config') -nmap_leader('em', edit_plugin_file('30_mini.lua'), 'MINI config') +nmap_leader('ed', 'lua MiniFiles.open()', 'Directory') +nmap_leader('ef', explore_at_file, 'File directory') +nmap_leader('ei', 'edit $MYVIMRC', 'init.lua') +nmap_leader('ek', edit_plugin_file('20_keymaps.lua'), 'Keymaps config') +nmap_leader('em', edit_plugin_file('30_mini.lua'), 'MINI config') nmap_leader('en', 'lua MiniNotify.show_history()', 'Notifications') -nmap_leader('eo', edit_plugin_file('10_options.lua'), 'Options config') -nmap_leader('ep', edit_plugin_file('40_plugins.lua'), 'Plugins config') -nmap_leader('eq', explore_quickfix, 'Quickfix') +nmap_leader('eo', edit_plugin_file('10_options.lua'), 'Options config') +nmap_leader('ep', edit_plugin_file('40_plugins.lua'), 'Plugins config') +nmap_leader('eq', explore_quickfix, 'Quickfix') -- f is for 'Fuzzy Find'. Common usage: -- - `ff` - find files; for best performance requires `ripgrep` @@ -124,24 +110,23 @@ nmap_leader('eq', explore_quickfix, 'Quickfix') -- All these use 'mini.pick'. See `:h MiniPick-overview` for an overview. local pick_workspace_symbols_live = 'Pick lsp scope="workspace_symbol_live"' -nmap_leader('p/', 'Pick history scope="/"', '"/" history') -nmap_leader('p:', 'Pick history scope=":"', '":" history') -nmap_leader('pb', 'Pick buffers', 'Buffers') -nmap_leader('pd', 'Pick diagnostic scope="all"', 'Diagnostic workspace') -nmap_leader('pD', 'Pick diagnostic scope="current"', 'Diagnostic buffer') -nmap_leader('pf', 'Pick files', 'Files') -nmap_leader('pg', 'Pick grep_live', 'Grep live') -nmap_leader('pG', 'Pick grep pattern=""', 'Grep current word') -nmap_leader('ph', 'Pick help', 'Help tags') -nmap_leader('pH', 'Pick hl_groups', 'Highlight groups') -nmap_leader('pl', 'Pick buf_lines scope="all"', 'Lines (all)') -nmap_leader('pL', 'Pick buf_lines scope="current"', 'Lines (buf)') -nmap_leader('pr', 'Pick resume', 'Resume') -nmap_leader('pR', 'Pick lsp scope="references"', 'References (LSP)') -nmap_leader('ps', pick_workspace_symbols_live, 'Symbols workspace (live)') -nmap_leader('pS', 'Pick lsp scope="document_symbol"', 'Symbols document') -nmap_leader('pv', 'Pick visit_paths cwd=""', 'Visit paths (all)') -nmap_leader('pV', 'Pick visit_paths', 'Visit paths (cwd)') +nmap_leader('f/', 'Pick history scope="/"', '"/" history') +nmap_leader('f:', 'Pick history scope=":"', '":" history') +nmap_leader('', 'Pick buffers', 'Buffers') +nmap_leader('w', 'w!', 'Write buffer') +nmap_leader('fd', 'Pick diagnostic scope="all"', 'Diagnostic workspace') +nmap_leader('fD', 'Pick diagnostic scope="current"', 'Diagnostic buffer') +nmap_leader('ff', 'Pick files', 'Files') +nmap_leader('fg', 'Pick grep_live', 'Grep live') +nmap_leader('fG', 'Pick grep pattern=""', 'Grep current word') +nmap_leader('fh', 'Pick help', 'Help tags') +nmap_leader('fH', 'Pick hl_groups', 'Highlight groups') +nmap_leader('fl', 'Pick buf_lines scope="all"', 'Lines (all)') +nmap_leader('fL', 'Pick buf_lines scope="current"', 'Lines (buf)') +nmap_leader('fr', 'Pick resume', 'Resume') +nmap_leader('fR', 'Pick lsp scope="references"', 'References (LSP)') +nmap_leader('fs', pick_workspace_symbols_live, 'Symbols workspace (live)') +nmap_leader('fS', 'Pick lsp scope="document_symbol"', 'Symbols document') -- g is for Git nmap_leader('gg', 'Neogit', 'Open neogit') @@ -152,39 +137,30 @@ nmap_leader('gb', 'Gitsigns toggle_current_line_blame', 'Git blame') -- - `ld` - show more diagnostic details in a floating window -- - `lr` - perform rename via LSP -- - `ls` - navigate to source definition of symbol under cursor --- --- NOTE: most LSP mappings represent a more structured way of replacing built-in --- LSP mappings (like `:h gra` and others). This is needed because `gr` is mapped --- by an "replace" operator in 'mini.operators' (which is more commonly used). -local formatting_cmd = 'lua require("conform").format({lsp_fallback=true})' -nmap_leader('la', 'lua vim.lsp.buf.code_action()', 'Actions') -nmap_leader('ld', 'lua vim.diagnostic.open_float()', 'Diagnostic popup') -nmap_leader('lf', formatting_cmd, 'Format') -nmap_leader('li', 'lua vim.lsp.buf.implementation()', 'Implementation') -nmap_leader('lh', 'lua vim.lsp.buf.hover()', 'Hover') -nmap_leader('lr', 'lua vim.lsp.buf.rename()', 'Rename') -nmap_leader('lR', 'lua vim.lsp.buf.references()', 'References') -nmap_leader('ls', 'lua vim.lsp.buf.definition()', 'Source definition') +nmap_leader('la', 'lua vim.lsp.buf.code_action()', 'Actions') +nmap_leader('ld', 'lua vim.diagnostic.open_float()', 'Diagnostic popup') +nmap_leader('lf', 'lua vim.lsp.buf.format()', 'Format') +nmap_leader('li', 'lua vim.lsp.buf.implementation()', 'Implementation') +nmap_leader('lh', 'lua vim.lsp.buf.hover()', 'Hover') +nmap_leader('lr', 'lua vim.lsp.buf.rename()', 'Rename') +nmap_leader('lR', 'lua vim.lsp.buf.references()', 'References') +nmap_leader('ls', 'lua vim.lsp.buf.definition()', 'Source definition') nmap_leader('lt', 'lua vim.lsp.buf.type_definition()', 'Type definition') -xmap_leader('lf', formatting_cmd, 'Format selection') +-- d is for DAP Debugging +nmap_leader('dd', 'DapViewToggle', 'Open DAP') +nmap_leader('ds', 'DapContinue', 'Start or Continue') +nmap_leader('db', 'DapToggleBreakpoint', 'Toggle Breakpoint') +nmap_leader('di', 'DapStepInto', 'Toggle Breakpoint') +nmap_leader('db', 'DapToggleBreakpoint', 'Toggle Breakpoint') -- o is for 'Other'. Common usage: -- - `oz` - toggle between "zoomed" and regular view of current buffer -nmap_leader('or', 'lua MiniMisc.resize_window()', 'Resize to default width') -nmap_leader('ot', 'lua MiniTrailspace.trim()', 'Trim trailspace') -nmap_leader('oz', 'lua MiniMisc.zoom()', 'Zoom toggle') -nmap_leader('om', 'Mason', 'Open Mason') -nmap_leader('ou', 'DepsUpdate', 'Update plugins') - - --- z if for notes and todos -nmap_leader('zz', "ZkNotes {sort={'modified'}}", 'Notes picker') -nmap_leader('zn', "ZkNew {title = vim.fn.input('Title: ')}", 'New note') -nmap_leader('zt', "ZkTags", 'Notes tags') -nmap_leader('zf', "ZkNotes {sort={'modified'}, match={vim.fn.input('Search: ')}}", 'Search') -vmap_leader('zm', "'<,'>ZkMatch", "Search match") -nmap_leader('zt', "e ~/notes/TODO.md", "Open TODOs") +nmap_leader('ot', 'lua MiniTrailspace.trim()', 'Trim trailspace') +nmap_leader('oz', 'lua MiniMisc.zoom()', 'Zoom toggle') +nmap_leader('om', 'Mason', 'Open Mason') +nmap_leader('ou', 'DepsUpdate', 'Update plugins') +nmap_leader('or', 'Pick registers', 'Yank from register') -- stylua: ignore end diff --git a/plugin/40_plugins.lua b/plugin/40_plugins.lua index f2c8e79..7014cff 100644 --- a/plugin/40_plugins.lua +++ b/plugin/40_plugins.lua @@ -13,11 +13,6 @@ local add, later = MiniDeps.add, MiniDeps.later local now_if_args = _G.Config.now_if_args -- Tree-sitter ================================================================ - --- Tree-sitter is a tool for fast incremental parsing. It converts text into --- a hierarchical structure (called tree) that can be used to implement advanced --- and/or more precise actions: syntax highlighting, textobjects, indent, etc. --- now_if_args(function() add({ source = 'nvim-treesitter/nvim-treesitter', @@ -43,6 +38,9 @@ now_if_args(function() 'python', 'javascript', 'typst', + 'go', + 'sql', + 'typst', -- Add here more languages with which you want to use tree-sitter -- To see available languages: -- - Execute `:=require('nvim-treesitter').get_available()` @@ -67,52 +65,42 @@ now_if_args(function() end) -- Language servers =========================================================== - --- Language Server Protocol (LSP) is a set of conventions that power creation of --- language specific tools. It requires two parts: --- - Server - program that performs language specific computations. --- - Client - program that asks server for computations and shows results. --- --- Add it now if file (and not 'mini.starter') is shown after startup. now_if_args(function() add('neovim/nvim-lspconfig') - - -- Use `:h vim.lsp.enable()` to automatically enable language server based on - -- the rules provided by 'nvim-lspconfig'. - -- Use `:h vim.lsp.config()` or 'after/lsp/' directory to configure servers. - -- Uncomment and tweak the following `vim.lsp.enable()` call to enable servers. vim.lsp.enable({ 'lua_ls', - 'basedpyright', + 'ty', 'ruff', 'html', 'css', 'toml', 'marksman', + 'gopls', + 'clojure_lsp', + 'harper_ls', + 'tinymist' + }) + + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true) + end + end, }) end) -- Formatting ================================================================= - --- Programs dedicated to text formatting (a.k.a. formatters) are very useful. --- Neovim has built-in tools for text formatting (see `:h gq` and `:h 'formatprg'`). --- They can be used to configure external programs, but it might become tedious. --- --- The 'stevearc/conform.nvim' plugin is a good and maintained solution for easier --- formatting setup. later(function() add('stevearc/conform.nvim') - - -- See also: - -- - `:h Conform` - -- - `:h conform-options` - -- - `:h conform-formatters` require('conform').setup({ -- Map of filetype to formatters -- Make sure that necessary CLI tool is available formatters_by_ft = { lua = { 'stylua' }, python = { 'ruff' }, + html = { 'htmlhint' }, }, }) end) @@ -135,7 +123,7 @@ now_if_args(function() float = { transparent = true, }, - compile_path = vim.fn.stdpath "cache" .. "/catppuccin", + compile_path = vim.fn.stdpath('cache') .. '/catppuccin', }) vim.cmd('colorscheme catppuccin') end) @@ -157,88 +145,146 @@ later(function() require('gitsigns').setup({}) end) --- claudecode ================================================================= --- later(function () --- add({ --- source = 'coder/claudecode.nvim', --- depends = { 'folke/snacks.nvim' }, --- }) --- require('claudecode').setup({}) --- end) --- --- open code ================================================================== +-- opencode =================================================================== +local opencode_cmd = "opencode --port" + later(function() add({ source = 'nickjvandyke/opencode.nvim', depends = { 'folke/snacks.nvim' }, }) - vim.g.opencode_opts = { - provider = { - enabled = 'terminal', - terminal = { - width = math.floor(vim.o.columns * 0.5), - }, + require('snacks').setup({ picker = { enabled = true } }) + + ---@type snacks.terminal.Opts + local snacks_terminal_opts = { + win = { + position = "right", + enter = false, }, } - -- Handle `opencode` events - -- vim.api.nvim_create_autocmd('User', { - -- pattern = 'OpencodeEvent:*', -- Optionally filter event types - -- callback = function(args) - -- ---@type opencode.cli.client.Event - -- local event = args.data.event - -- ---@type number - -- local port = args.data.port - -- - -- -- See the available event types and their properties - -- vim.notify(vim.inspect(event)) - -- -- Do something useful - -- if event.type == 'session.idle' then - -- vim.notify('`opencode` finished responding') - -- end - -- end, - -- }) -end) - --- zk ========================================================================= -later(function() - add({ - source = 'zk-org/zk-nvim', - }) - require('zk').setup({ - picker = 'minipick', - enabled = 'snacks', - lsp = { - config = { - name = 'zk', - cmd = { 'zk', 'lsp' }, - filetypes = { 'markdown' }, - }, + ---@type opencode.Opts + vim.g.opencode_opts = { + server = { + start = function() + require("snacks.terminal").open(opencode_cmd, snacks_terminal_opts) + end, }, - auto_attach = { - enabled = true, - }, - }) -end) + } --- checkmate ==================================================================== -now_if_args(function() - add({ - source = 'bngarren/checkmate.nvim', - }) - require('checkmate').setup({ - files = { '/home/mds/notes/TODO.md' }, - }) + vim.keymap.set({ "n", "x" }, "aa", function() + require("opencode").ask("@this: ", { submit = true }) + end, { desc = "Ask opencode" }) + + vim.keymap.set({ "n", "x" }, "ap", function() + require("opencode").select() + end, { desc = "Select opencode" }) + + vim.keymap.set({ "n", "t" }, "ac", function() + require("snacks.terminal").toggle(opencode_cmd, snacks_terminal_opts) + end, { desc = "Toggle opencode" }) end) -- render-markdown.nvim ======================================================== -now_if_args(function () +now_if_args(function() add({ source = 'MeanderingProgrammer/render-markdown.nvim', }) require('render-markdown').setup({ enabled = true, - file_types = {'markdown', 'vimwiki'}, + file_types = { 'markdown', 'vimwiki' }, + latex = { enabled = false } + }) +end) + +-- nvim-dap ==================================================================== +-- +later(function() + add({ + source = 'mfussenegger/nvim-dap', + depends = { + 'nvim-neotest/nvim-nio', + 'mfussenegger/nvim-dap-python', + 'theHamsta/nvim-dap-virtual-text', + }, + }) + + add({ + source = 'igorlfs/nvim-dap-view', + }) + + local dap = require('dap') + local dap_view = require('dap-view') + local dap_python = require('dap-python') + + dap_view.setup({}) + require('nvim-dap-virtual-text').setup({ + commented = true, -- Show virtual text alongside comment + }) + + dap_python.setup('python3') +end) + +-- claude code ================================================================= +now_if_args(function() + add({ + source = "coder/claudecode.nvim", + depends = { "folke/snacks.nvim" } + }) + require("claudecode").setup() + vim.keymap.set({ "n", "x" }, "co", "ClaudeCode", { desc = "Open Claude Code" }) +end) + +-- conjure ===================================================================== +later(function() + add({ + source = 'Olical/conjure', + }) +end +) + +-- Typst ======================================================================== +now_if_args(function() + vim.keymap.set("n", "tt", "LspTinymistExportPdf", { desc = "Export Typst to PDF" }) +end) + + +-- Supercollider =============================================================== +later(function() + add({ + source = 'davidgranstrom/scnvim' + }) + local scnvim = require("scnvim") + local map = scnvim.map + local map_expr = scnvim.map_expr + + scnvim.setup({ + keymaps = { + [""] = map("editor.send_line", { "i", "n" }), + [""] = { + map("editor.send_block", { "i", "n" }), + map("editor.send_selection", "x"), + }, + [""] = map("postwin.toggle"), + [""] = map("postwin.toggle", "i"), + [""] = map("postwin.clear", { "n", "i" }), + [""] = map("signature.show", { "n", "i" }), + [""] = map("sclang.hard_stop", { "n", "x", "i" }), + ["st"] = map("sclang.start"), + ["sk"] = map("sclang.recompile"), + [""] = map_expr("s.boot"), + [""] = map_expr("s.meter"), + }, + editor = { + highlight = { + color = "IncSearch", + }, + }, + postwin = { + float = { + enabled = true, + }, + }, }) end)