diff --git a/init.lua b/init.lua index 16d65925..5241594a 100644 --- a/init.lua +++ b/init.lua @@ -1397,9 +1397,97 @@ require('lazy').setup({ -- tag = "v0.10", -- uncomment to pin to a specific release init = function() -- wiki.vim configuration goes here, e.g. - vim.g.wiki_root = '~/Documents/wiki' + vim.g.wiki_root = '~/Documents/Developer/' end, }, + { + 'NickvanDyke/opencode.nvim', + dependencies = { + -- Recommended for better prompt input, and required to use opencode.nvim's embedded terminal — otherwise optional + { 'folke/snacks.nvim', opts = { input = { enabled = true } } }, + }, + ---@type opencode.Opts + opts = { + -- Your configuration, if any — see lua/opencode/config.lua + }, + keys = { + -- Recommended keymaps + { + 'oA', + function() + require('opencode').ask() + end, + desc = 'Ask opencode', + }, + { + 'oa', + function() + require('opencode').ask '@cursor: ' + end, + desc = 'Ask opencode about this', + mode = 'n', + }, + { + 'oa', + function() + require('opencode').ask '@selection: ' + end, + desc = 'Ask opencode about selection', + mode = 'v', + }, + { + 'ot', + function() + require('opencode').toggle() + end, + desc = 'Toggle embedded opencode', + }, + { + 'on', + function() + require('opencode').command 'session_new' + end, + desc = 'New session', + }, + { + 'oy', + function() + require('opencode').command 'messages_copy' + end, + desc = 'Copy last message', + }, + { + '', + function() + require('opencode').command 'messages_half_page_up' + end, + desc = 'Scroll messages up', + }, + { + '', + function() + require('opencode').command 'messages_half_page_down' + end, + desc = 'Scroll messages down', + }, + { + 'op', + function() + require('opencode').select_prompt() + end, + desc = 'Select prompt', + mode = { 'n', 'v' }, + }, + -- Example: keymap for custom prompt + { + 'oe', + function() + require('opencode').prompt 'Explain @cursor and its context' + end, + desc = 'Explain code near cursor', + }, + }, + }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and @@ -1410,12 +1498,12 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua index 386d392e..e59d0f28 100644 --- a/lua/kickstart/plugins/autopairs.lua +++ b/lua/kickstart/plugins/autopairs.lua @@ -4,5 +4,31 @@ return { 'windwp/nvim-autopairs', event = 'InsertEnter', - opts = {}, + config = function() + require('nvim-autopairs').setup({ + check_ts = true, + ts_config = { + lua = { 'string' }, -- it will not add a pair on that treesitter node + javascript = { 'template_string' }, + java = false, -- don't check treesitter on java + }, + disable_filetype = { 'TelescopePrompt', 'spectre_panel' }, + fast_wrap = { + map = '', + chars = { '{', '[', '(', '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], '%s+', ''), + offset = 0, -- Offset from pattern match + end_key = '$', + keys = 'qwertyuiopzxcvbnmasdfghjkl', + check_comma = true, + highlight = 'PmenuSel', + highlight_grey = 'LineNr', + }, + }) + + -- Integration with nvim-cmp + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, }