diff --git a/after/queries/python/injections.scm b/after/queries/python/injections.scm new file mode 100644 index 0000000..2629c61 --- /dev/null +++ b/after/queries/python/injections.scm @@ -0,0 +1,25 @@ +; extends +((call + function: (identifier) @function_name (#eq? @function_name "Style") + arguments: (argument_list + (string + (string_content) @injection.content))) + + (#set! injection.language "css")) + +((call + function: (identifier) @function_name (#eq? @function_name "Script") + arguments: (argument_list + (string + (string_content) @injection.content))) + + (#set! injection.language "javascript")) + +((call + function: (identifier) @function_name (#eq? @function_name "On") + arguments: (argument_list + + (string + (string_content) @injection.content)) + + (#set! injection.language "javascript"))) diff --git a/ftplugin/python.lua b/ftplugin/python.lua index 64762dc..4e4b6b1 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -1 +1,3 @@ vim.b.slime_cell_delimiter = '#\\s\\=%%' + +require("otter").activate() diff --git a/init.lua b/init.lua index 76a90de..1fdb26d 100644 --- a/init.lua +++ b/init.lua @@ -14,3 +14,8 @@ require 'config.global' require 'config.lazy' require 'config.autocommands' require 'config.redir' + + +vim.treesitter.language.add('pandoc_markdown', { path = "/usr/local/lib/libtree-sitter-pandoc-markdown.so" }) +vim.treesitter.language.add('pandoc_markdown_inline', { path = "/usr/local/lib/libtree-sitter-pandoc-markdown-inline.so" }) +vim.treesitter.language.register('pandoc_markdown', { 'quarto', 'rmarkdown' }) diff --git a/lua/config/keymap.lua b/lua/config/keymap.lua index 1dd601b..2faa4ae 100644 --- a/lua/config/keymap.lua +++ b/lua/config/keymap.lua @@ -58,11 +58,13 @@ nmap('Q', '') --- TODO: figure out bracketed paste for reticulate python repl. local function send_cell() local has_molten, molten_status = pcall(require, 'molten.status') + local molten_works = false local molten_active = "" if has_molten then - molten_active = molten_status.kernels() + molten_works, molten_active = pcall(molten_status.kernels) end - if molten_active ~= vim.NIL and molten_active ~= "" then + if molten_works and molten_active ~= vim.NIL and molten_active ~= "" then + print('using quarto send') vim.cmd.QuartoSend() return end diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua index 2463911..119e756 100644 --- a/lua/plugins/completion.lua +++ b/lua/plugins/completion.lua @@ -123,11 +123,11 @@ return { { name = 'path' }, { name = 'nvim_lsp_signature_help' }, { name = 'nvim_lsp' }, - { name = 'luasnip', keyword_length = 3, max_item_count = 3 }, + { name = 'luasnip', keyword_length = 3, max_item_count = 3 }, { name = 'pandoc_references' }, - { name = 'buffer', keyword_length = 5, max_item_count = 3 }, + { name = 'buffer', keyword_length = 5, max_item_count = 3 }, { name = 'spell' }, - { name = 'treesitter', keyword_length = 5, max_item_count = 3 }, + { name = 'treesitter', keyword_length = 5, max_item_count = 3 }, { name = 'calc' }, { name = 'latex_symbols' }, { name = 'emoji' }, @@ -174,4 +174,44 @@ return { } end, }, + + { -- LLMs + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "nvim-telescope/telescope.nvim", + { + "stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI + opts = {}, + }, + }, + keys = { + { 'ac', ':CodeCompanionChat', desc = '[a]i chat' }, + }, + config = function() + require("codecompanion").setup({ + strategies = { + chat = { + adapter = "anthropic", + }, + inline = { + adapter = "anthropic", + }, + agent = { + adapter = "anthropic", + }, + }, + adapters = { + anthropic = function() + return require("codecompanion.adapters").extend("anthropic", { + env = { + api_key = os.getenv("ANTHROPIC_API_KEY") + }, + }) + end, + }, + }) + end + } } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 25325d7..b4f9a55 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -5,7 +5,7 @@ return { -- for lsp features in code cells / embedded code 'jmbuhr/otter.nvim', - dev = true, + dev = false, dependencies = { { 'neovim/nvim-lspconfig', @@ -100,8 +100,8 @@ return { map('gh', vim.lsp.buf.signature_help, '[g]o to signature [h]elp') map('gI', vim.lsp.buf.implementation, '[g]o to [I]mplementation') map('gr', vim.lsp.buf.references, '[g]o to [r]eferences') - map('[d', function () vim.diagnostic.jump({count = 1}) end,'previous [d]iagnostic ') - map(']d', function () vim.diagnostic.jump({count = -1}) end, 'next [d]iagnostic ') + map(']d', function () vim.diagnostic.jump({count = 1}) end,'previous [d]iagnostic ') + map('[d', function () vim.diagnostic.jump({count = -1}) end, 'next [d]iagnostic ') map('ll', vim.lsp.codelens.run, '[l]ens run') map('lR', vim.lsp.buf.rename, '[l]sp [R]ename') map('lf', vim.lsp.buf.format, '[l]sp [f]ormat') @@ -182,7 +182,7 @@ return { flags = lsp_flags, } - lspconfig.tsserver.setup { + lspconfig.ts_ls.setup { capabilities = capabilities, flags = lsp_flags, filetypes = { 'js', 'javascript', 'typescript', 'ojs' }, diff --git a/lua/plugins/notes.lua b/lua/plugins/notes.lua index 52bbf4c..07a0b44 100644 --- a/lua/plugins/notes.lua +++ b/lua/plugins/notes.lua @@ -21,7 +21,7 @@ return { { 'epwalsh/obsidian.nvim', - enabled = false, + enabled = true, ft = 'markdown', event = { -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. diff --git a/lua/plugins/quarto.lua b/lua/plugins/quarto.lua index 4c9a244..1cc831b 100644 --- a/lua/plugins/quarto.lua +++ b/lua/plugins/quarto.lua @@ -127,12 +127,13 @@ return { { 'benlubas/molten-nvim', + dev = true, enabled = true, build = ':UpdateRemotePlugins', init = function() vim.g.molten_image_provider = 'image.nvim' vim.g.molten_output_win_max_height = 20 - vim.g.molten_auto_open_output = false + vim.g.molten_auto_open_output = true end, keys = { { 'mi', ':MoltenInit', desc = '[m]olten [i]nit' },