Compare commits

..

No commits in common. "87ce74de403d6537dacbcca038aba2f7ccd326e5" and "a746e35d260fc54e1a9923023a1082ae93f37307" have entirely different histories.

17 changed files with 470 additions and 860 deletions

View file

@ -35,9 +35,9 @@ if require("core.util").is_available("peek") then
peek.open() peek.open()
end end
end end
map("n", "<leader>po", togglePeek, { desc = "show md preview" }) map("n", "<leader>pp", togglePeek, { desc = "show md preview" })
else else
map("n", "<leader>po", "<Plug>MarkdownPreviewToggle", { desc = "show md preview" }) map("n", "<leader>pp", "<Plug>MarkdownPreviewToggle", { desc = "show md preview" })
end end
-- create mindmaps directly from markdown! requires external executable -- create mindmaps directly from markdown! requires external executable

View file

@ -6,13 +6,14 @@ local default_buffer_session = function()
if vim.fn.getftype(dir) ~= "dir" then if vim.fn.getftype(dir) ~= "dir" then
vim.fn.mkdir(dir, "p") vim.fn.mkdir(dir, "p")
end end
return temp_path return temp_path
end end
-- Start quarto session -- Start quarto session
local startsession = function(file, args) local startsession = function(file, args)
file = file or default_buffer_session() file = file or default_buffer_session()
local path = require("core.util").get_python_venv_bin() local path = require("core.util").get_python_venv()
vim.g["python3_host_prog"] = path vim.g["python3_host_prog"] = path
if vim.fn.executable("jupyter-console") ~= 1 then if vim.fn.executable("jupyter-console") ~= 1 then
@ -40,27 +41,92 @@ vim.api.nvim_create_user_command("JupyterStart", function()
startsession() startsession()
end, {}) end, {})
vim.api.nvim_create_autocmd({"InsertEnter", "BufEnter"}, { local map = vim.keymap.set
callback = function()
if vim.b["sessionfile"] == nil then local function molten_mappings_set()
-- Operate jupyter notebooks from within vim
map("n", "<localleader>cc", ":MoltenEvaluateLine<cr>", { silent = true })
map(
"n",
"<localleader>C",
require("quarto.runner").run_cell,
{ silent = true, desc = "Evaluate current code cell" }
)
map("x", "<localleader>c", ":<C-u>MoltenEvaluateVisual<cr>", { silent = true })
map(
"n",
"<localleader>c",
"nvim_exec('MoltenEvaluateOperator', v:true)",
{ expr = true, silent = true, desc = "+code-evaluation" }
)
map("n", "<localleader>cr", ":MoltenReevaluateCell<cr>", { silent = true })
map("n", "<localleader>cu", ":MoltenShowOutput<cr>", { silent = true })
map("n", "<localleader>cU", ":noautocmd :MoltenEnterOutput<cr>", { silent = true, desc = "Molten enter output" })
map("n", "<localleader>cd", ":MoltenDelete<cr>", { silent = true })
map("n", "<localleader>ci", ":MoltenInterrupt<cr>")
map("n", "<localleader>cN", ":MoltenInit ")
map("n", "<localleader>cD", ":MoltenDeinit<cr>")
map("n", "<localleader>cR", ":MoltenRestart<cr>")
map("n", "<localleader>cA", require("quarto.runner").run_all, { silent = true, desc = "Evaluate all code cells" })
map(
"n",
"<localleader>ca",
require("quarto.runner").run_above,
{ silent = true, desc = "Evaluate cells above current" }
)
map(
"n",
"<localleader>cb",
require("quarto.runner").run_below,
{ silent = true, desc = "Evaluate cells below current" }
)
-- jump to beginning of previous/ next cell code
map("n", "]c", "/^```{<cr>}:nohl<cr>", { desc = "Next quarto cell" })
map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Previous quarto cell" })
-- insert cell header above/below
map("n", "<localleader>co", "o```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell below" })
map("n", "<localleader>cO", "O```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell above" })
end
vim.api.nvim_create_autocmd("User", {
pattern = "MoltenInitPost",
callback = molten_mappings_set,
})
local bufnr = 0
map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" })
map(
"n",
"[e",
"<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<cr>",
{ buffer = bufnr, desc = "Previous error" }
)
map(
"n",
"]e",
"<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})<cr>",
{ buffer = bufnr, desc = "Next error" }
)
-- TODO find better way to enable lsp key mappings for quarto buffers
local prefix = require("which-key").register
prefix({ ["<localleader>l"] = { name = "+lsp" } })
map("n", "<localleader>li", "<cmd>LspInfo<cr>", { buffer = bufnr, desc = "Lsp Info" })
map("n", "<localleader>ld", "<cmd>lua vim.diagnostic.open_float()<cr>", { buffer = bufnr, desc = "Line diagnostics" })
map("n", "<localleader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", { buffer = bufnr, desc = "Codeactions" })
map("n", "<localleader>ln", "<cmd>lua vim.lsp.buf.rename()<cr>", { buffer = bufnr, desc = "Rename element" })
map("n", "<localleader>lr", "<cmd>lua vim.lsp.buf.references()<cr>", { buffer = bufnr, desc = "References" })
map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", { buffer = bufnr, desc = "Hover definition" })
map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", { buffer = bufnr, desc = "Definition" })
map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", { buffer = bufnr, desc = "Declaration" })
map("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>", { buffer = bufnr, desc = "Signature help" })
map("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<cr>", { buffer = bufnr, desc = "Implementation" })
map("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<cr>", { buffer = bufnr, desc = "Type definition" })
if vim.b["sessionfile"] == nil then
local path = default_buffer_session() local path = default_buffer_session()
vim.b["sessionfile"] = path vim.b["sessionfile"] = path
vim.schedule_wrap(startsession(path)) vim.schedule_wrap(startsession(path))
end end
end,
})
-- -- -- TODO find better way to enable lsp key mappings for quarto buffers
-- -- local prefix = require("which-key").register
-- -- prefix({ ["<localleader>l"] = { name = "+lsp" } })
-- -- map("n", "<localleader>li", "<cmd>LspInfo<cr>", { buffer = bufnr, desc = "Lsp Info" })
-- -- map("n", "<localleader>ld", "<cmd>lua vim.diagnostic.open_float()<cr>", { buffer = bufnr, desc = "Line diagnostics" })
-- -- map("n", "<localleader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", { buffer = bufnr, desc = "Codeactions" })
-- -- map("n", "<localleader>ln", "<cmd>lua vim.lsp.buf.rename()<cr>", { buffer = bufnr, desc = "Rename element" })
-- -- map("n", "<localleader>lr", "<cmd>lua vim.lsp.buf.references()<cr>", { buffer = bufnr, desc = "References" })
-- --
-- -- map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", { buffer = bufnr, desc = "Declaration" })
-- -- map("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>", { buffer = bufnr, desc = "Signature help" })
-- -- map("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<cr>", { buffer = bufnr, desc = "Implementation" })
-- -- map("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<cr>", { buffer = bufnr, desc = "Type definition" })
-- vim.g["python3_host_prog"] = vim.fn.expand(require("core.util").get_python_venv())

View file

@ -28,26 +28,22 @@
"dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" },
"fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" },
"flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" }, "flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" },
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" }, "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" },
"fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" },
"git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" }, "git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" },
"gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, "gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" },
"glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" },
"headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" },
"image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" },
"img-clip.nvim": { "branch": "main", "commit": "fc30500c35663aa1762697f5aba31d43b86028f0" }, "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" },
"jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" },
"lazy.nvim": { "branch": "main", "commit": "c501b429cf995c645454539b924aaefae45bb9eb" },
"lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"luarocks.nvim": { "branch": "main", "commit": "1db9093915eb16ba2473cfb8d343ace5ee04130a" },
"markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" }, "markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" },
"mason-conform.nvim": { "branch": "main", "commit": "abce2be529f3b4b336c56d0ba6336a9144e0fee6" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
"mason-nvim-lint": { "branch": "main", "commit": "637a5b8f1b454753ec70289c4996d88a50808642" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mdeval.nvim": { "branch": "master", "commit": "2c32e2f3e7d8f222e7a4724989f218d036e1081d" }, "mdeval.nvim": { "branch": "master", "commit": "2c32e2f3e7d8f222e7a4724989f218d036e1081d" },
"mini.nvim": { "branch": "main", "commit": "19e1584124cda35388d4fdb911eab7124014e541" }, "mini.nvim": { "branch": "main", "commit": "f24747266a047617d06605a2316aa6c071662fa2" },
"molten-nvim": { "branch": "main", "commit": "df5ccef3b6fda3582f7746e45327ee031f668826" }, "molten-nvim": { "branch": "main", "commit": "df5ccef3b6fda3582f7746e45327ee031f668826" },
"neogen": { "branch": "main", "commit": "0daffcec249bf42275e322361fe55b89a05ff278" }, "neogen": { "branch": "main", "commit": "0daffcec249bf42275e322361fe55b89a05ff278" },
"neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" }, "neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" },
@ -57,7 +53,7 @@
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
"nvim-coverage": { "branch": "main", "commit": "aa4b4400588e2259e87e372b1e4e90ae13cf5a39" }, "nvim-coverage": { "branch": "main", "commit": "aa4b4400588e2259e87e372b1e4e90ae13cf5a39" },
"nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" }, "nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" },
"nvim-lspconfig": { "branch": "master", "commit": "bd7c76375a511994c9ca8d69441f134dc10ae3bd" }, "nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" },
"nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" }, "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
"nvim-surround": { "branch": "main", "commit": "687ea2f33955df0042bf228853a82696265e7e2d" }, "nvim-surround": { "branch": "main", "commit": "687ea2f33955df0042bf228853a82696265e7e2d" },
"nvim-toggleterm.lua": { "branch": "main", "commit": "066cccf48a43553a80a210eb3be89a15d789d6e6" }, "nvim-toggleterm.lua": { "branch": "main", "commit": "066cccf48a43553a80a210eb3be89a15d789d6e6" },
@ -73,22 +69,21 @@
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" }, "peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"quarto-nvim": { "branch": "main", "commit": "a6e7452de5944f7f38a4b12f1d50e460c1dccd95" }, "quarto-nvim": { "branch": "main", "commit": "67e09027b5d8bd948907734fc6fb15028ffdcd28" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" },
"smartcolumn.nvim": { "branch": "main", "commit": "d01b99355c7fab13233f48d0f28dc097e68a03f7" }, "smartcolumn.nvim": { "branch": "main", "commit": "d01b99355c7fab13233f48d0f28dc097e68a03f7" },
"stickybuf.nvim": { "branch": "master", "commit": "2160fcd536d81f5fa43f7167dba6634e814e3154" }, "stickybuf.nvim": { "branch": "master", "commit": "2160fcd536d81f5fa43f7167dba6634e814e3154" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope-luasnip.nvim": { "branch": "master", "commit": "11668478677de360dea45cf2b090d34f21b8ae07" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"trouble.nvim": { "branch": "main", "commit": "09380a8ed0694dbfbbcf59f9eaac499e259cb75c" }, "trouble.nvim": { "branch": "main", "commit": "3609bb9a82bbab1ef95cf2c27ce7e52267a7d40d" },
"twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" },
"undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" }, "undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" },
"vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" }, "vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" },
"vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" },
"vim-numbertoggle": { "branch": "main", "commit": "df9b1fe616507340718716204ba7f434125bdf7a" }, "vim-numbertoggle": { "branch": "main", "commit": "df9b1fe616507340718716204ba7f434125bdf7a" },
"vim-pandoc-syntax": { "branch": "master", "commit": "16939cda184ff555938cc895cc62477c172997f9" }, "vim-pandoc-syntax": { "branch": "master", "commit": "16939cda184ff555938cc895cc62477c172997f9" },
"vim-scimark": { "branch": "master", "commit": "9b66a88fa4bb87b8baab3c4aecc43b985b32e7fd" },
"vim-spellsync": { "branch": "master", "commit": "3d6dd50de9c4d953cc16638112a6ae196df41463" }, "vim-spellsync": { "branch": "master", "commit": "3d6dd50de9c4d953cc16638112a6ae196df41463" },
"wezterm.nvim": { "branch": "main", "commit": "f73bba23ab4becd146fa2d0a3a16a84b987eeaca" },
"which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }, "which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" },
"wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" }, "wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" },
"zen-mode.nvim": { "branch": "main", "commit": "cb73b8bd0ef9d765b942db09dc762c603a89ae44" }, "zen-mode.nvim": { "branch": "main", "commit": "cb73b8bd0ef9d765b942db09dc762c603a89ae44" },

View file

@ -36,7 +36,7 @@ require("lazy").setup({
defaults = { lazy = true, version = "*" }, defaults = { lazy = true, version = "*" },
performance = { performance = {
rtp = { disabled_plugins = { "netrw", "netrwPlugin" } }, rtp = { disabled_plugins = { "netrw", "netrwPlugin" } },
cache = { enable = true }, cache = { enable = false },
}, },
}) })
vim.keymap.set("n", "<leader>vl", ":Lazy<cr>", { desc = "Lazy" }) vim.keymap.set("n", "<leader>vl", ":Lazy<cr>", { desc = "Lazy" })

View file

@ -17,67 +17,32 @@ function T.get_plugin(plugin)
return nil return nil
end end
-- Remove the key from the vim keymap and from being displayed in which-key
-- FIXME This does not consistently currently with which-key
-- Every once in a while the maps are correctly hidden but other times they stay?
function T.unmap_key(lhs, mode)
mode = mode or "n"
if T.is_available("which-key") then
vim.keymap.set(mode, lhs, "", { desc = "which_key_ignore", silent = true })
end
pcall(vim.keymap.del, mode, lhs)
end
-- from https://github.com/ray-x/navigator.lua/issues/247#issue-1465308677 -- from https://github.com/ray-x/navigator.lua/issues/247#issue-1465308677
local function path_join(...) local function path_join(...)
return table.concat(vim.tbl_flatten({ ... }), "/") return table.concat(vim.tbl_flatten({ ... }), "/")
end end
function T.set_python_env(workspace)
local base = require("core.util").get_python_venv_basefolder(workspace)
base = vim.fn.expand(base)
local p = vim.env.PATH or ""
if not base then
return
end
vim.g["python3_host_prog"] = vim.fn.expand(require("core.util").get_python_venv_bin(workspace))
vim.env.PATH = base .. "/bin:" .. p
end
function T.get_python_venv_bin(workspace)
local pyenv = T.get_python_venv_basefolder(workspace)
if not pyenv then
-- Fallback to system Python.
return vim.fn.exepath("python3") or vim.fn.exepath("python") or "python"
end
return path_join(pyenv, "bin", "python")
end
-- cache path so we can call it multiple times
local venv_path = ""
-- return the current python environment path -- return the current python environment path
function T.get_python_venv_basefolder(workspace) function T.get_python_venv(workspace)
if venv_path and venv_path ~= "" then
return venv_path
end
-- Use activated virtualenv. -- Use activated virtualenv.
if vim.env.VIRTUAL_ENV then if vim.env.VIRTUAL_ENV then
venv_path = vim.env.VIRTUAL_ENV return path_join(vim.env.VIRTUAL_ENV, "bin", "python")
return venv_path
end end
-- Find and use virtualenv in workspace directory. -- Find and use virtualenv in workspace directory.
for _, pattern in ipairs({ "*", ".*" }) do for _, pattern in ipairs({ "*", ".*" }) do
local match = vim.fn.glob(path_join(workspace, pattern, "pyvenv.cfg")) local match = vim.fn.glob(path_join(workspace, pattern, "pyvenv.cfg"))
if match ~= "" then if match ~= "" then
match = string.gsub(match, "pyvenv.cfg", "") local py = path_join("bin", "python")
venv_path = match match = string.gsub(match, "pyvenv.cfg", py)
return venv_path return match
end end
match = vim.fn.glob(path_join(workspace, pattern, "poetry.lock")) match = vim.fn.glob(path_join(workspace, pattern, "poetry.lock"))
if match ~= "" then if match ~= "" then
local venv_base_folder = vim.fn.trim(vim.fn.system("poetry env info -p")) local venv_base_folder = vim.fn.trim(vim.fn.system("poetry env info -p"))
venv_path = venv_base_folder return path_join(venv_base_folder, "bin", "python")
return venv_path
end end
end end
-- Fallback to system Python.
return vim.fn.exepath("python3") or vim.fn.exepath("python") or "python"
end end
return T return T

View file

@ -1,199 +0,0 @@
return {
-- completion setup
{
"hrsh7th/nvim-cmp",
branch = "main",
version = false,
dependencies = {
"andersevenrud/cmp-tmux",
"cbarrete/completion-vcard",
"f3fora/cmp-spell",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp-signature-help",
"dmitmel/cmp-digraphs",
"jc-doyle/cmp-pandoc-references",
"kdheepak/cmp-latex-symbols",
"lukas-reineke/cmp-rg",
"crispgm/cmp-beancount",
{ "ray-x/cmp-treesitter", dependencies = { "nvim-treesitter/nvim-treesitter" } },
{
"saadparwaiz1/cmp_luasnip",
dependencies = {
{
"L3MON4D3/LuaSnip",
dependencies = {
"rafamadriz/friendly-snippets",
{
"benfowler/telescope-luasnip.nvim",
dependencies = { { "nvim-telescope/telescope.nvim", optional = true } },
config = function()
require("telescope").load_extension("luasnip")
end,
},
},
build = "make install_jsregexp",
config = function()
require("luasnip.loaders.from_vscode").lazy_load({ exclude = { "markdown", "quarto" } })
require("luasnip.loaders.from_snipmate").lazy_load()
end,
},
},
},
},
config = function()
local luasnip = require("luasnip")
local cmp = require("cmp")
local has_words_before = function()
---@diagnostic disable-next-line:deprecated
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local kind_icons = {
Text = "",
Method = "",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "V",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
cmp.setup({
window = { documentation = cmp.config.window.bordered() },
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = {
{ name = "nvim_lua" },
{
name = "beancount",
option = {
account = vim.env["HOME"] .. "/documents/records/budget/main.beancount", -- TODO implement dynamically
},
},
{ name = "otter" },
{ name = "nvim_lsp" },
{ name = "nvim_lsp_signature_help" },
{ name = "luasnip", keyword_length = 1 },
{ name = "pandoc_references" },
{ name = "calc" },
{ name = "path" },
{ name = "buffer", keyword_length = 3 },
{ name = "latex_symbols" },
{ name = "spell", keyword_length = 3 },
{ name = "tmux" }, -- { name = 'rg', keyword_length = 5 },
{ name = "vCard" },
{ name = "digraphs", keyword_length = 2 },
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false,
})
else
fallback()
end
end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false,
}), -- disable selection in cmd mode
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons, removing kind text leaving only icon
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- Source
vim_item.menu = ({
buffer = "",
calc = "󰃬",
digraphs = "",
latex_symbols = "𝓧",
luasnip = "",
nvim_lsp = "",
nvim_lua = "󰢱",
pandoc_references = "",
spell = "󰓆",
vCard = "󰛋",
})[entry.source.name]
return vim_item
end,
},
})
-- `/` cmdline setup.
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = "buffer" } },
})
-- `:` cmdline setup.
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ { name = "path" } }, {
{ name = "cmdline", option = { ignore_cmds = { "Man", "!" } } },
}),
})
end,
event = { "InsertEnter", "CmdlineEnter" },
},
}

View file

@ -0,0 +1,144 @@
local luasnip = require("luasnip")
local cmp = require("cmp")
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local kind_icons = {
Text = "",
Method = "",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "V",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
cmp.setup({
window = { documentation = cmp.config.window.bordered() },
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = {
{ name = "nvim_lua" },
{
name = "beancount",
option = {
account = vim.env["HOME"] .. "/documents/records/budget/main.beancount", -- TODO implement dynamically
},
},
{ name = "otter" },
{ name = "nvim_lsp" },
{ name = "nvim_lsp_signature_help" },
{ name = "luasnip", keyword_length = 2 },
{ name = "pandoc_references" },
{ name = "calc" },
{ name = "path" },
{ name = "buffer", keyword_length = 3 },
{ name = "latex_symbols" },
{ name = "spell", keyword_length = 3 },
{ name = "tmux" }, -- { name = 'rg', keyword_length = 5 },
{ name = "vCard" },
{ name = "digraphs", keyword_length = 2 },
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false,
})
else
fallback()
end
end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false,
}), -- disable selection in cmd mode
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons, removing kind text leaving only icon
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- Source
vim_item.menu = ({
buffer = "",
calc = "󰃬",
digraphs = "",
latex_symbols = "𝓧",
luasnip = "",
nvim_lsp = "",
nvim_lua = "󰢱",
pandoc_references = "",
spell = "󰓆",
vCard = "󰛋",
})[entry.source.name]
return vim_item
end,
},
})
-- `/` cmdline setup.
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = "buffer" } },
})
-- `:` cmdline setup.
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ { name = "path" } }, {
{ name = "cmdline", option = { ignore_cmds = { "Man", "!" } } },
}),
})

View file

@ -34,7 +34,7 @@ local servers = {
filetypes = { "markdown", "quarto" }, filetypes = { "markdown", "quarto" },
}, },
basedpyright = {}, basedpyright = {},
ruff = {}, ruff_lsp = {},
serve_d = {}, serve_d = {},
tailwindcss = {}, tailwindcss = {},
taplo = {}, taplo = {},
@ -43,7 +43,17 @@ local servers = {
yamlls = {}, yamlls = {},
} }
local function on_attach(_, bufnr) -- TODO installed for conform/nvim-lint so should be sourced from there not here
local to_mason =
{ "stylua", "shellcheck", "shfmt", "markdownlint", "bibtex-tidy", "jq", "prettier", "ruff", unpack(servers) }
require("mason-tool-installer").setup({
-- a list of all tools you want to ensure are installed upon
-- start
ensure_installed = to_mason,
start_delay = 3000,
})
local function on_attach(client, bufnr)
local map = vim.keymap.set local map = vim.keymap.set
map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" }) map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" }) map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" })
@ -156,35 +166,21 @@ local python_path
-- ensure python virtualenv is determined automatically on lsp start -- ensure python virtualenv is determined automatically on lsp start
lspconfig.basedpyright.setup({ lspconfig.basedpyright.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
on_attach(client, bufnr)
if python_path == nil then if python_path == nil then
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
end end
vim.g["python3_host_prog"] = python_path
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path))) -- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
client.config.settings.python = {} or client.config.settings.python client.config.settings.python = {} or client.config.settings.python
client.config.settings.python.pythonPath = python_path client.config.settings.python.pythonPath = python_path
on_attach(client, bufnr)
end, end,
settings = {
-- disable imports and linting since, we use ruff for that
pyright = {
disableOrganizeImports = true,
},
python = {
analysis = {
ignore = { "*" },
},
},
},
}) })
lspconfig.ruff.setup({ lspconfig.ruff_lsp.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
on_attach(client, bufnr) on_attach(client, bufnr)
client.server_capabilities.hoverProvider = false -- we use pyright for hover info
if python_path == nil then if python_path == nil then
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
end end
vim.g["python3_host_prog"] = python_path
client.config.settings.python = {} or client.config.settings.python client.config.settings.python = {} or client.config.settings.python
client.config.settings.python.pythonPath = python_path client.config.settings.python.pythonPath = python_path
end, end,

View file

@ -119,17 +119,17 @@ return {
require("mini.bracketed").setup({ require("mini.bracketed").setup({
{ {
buffer = { suffix = "b", options = {} }, buffer = { suffix = "b", options = {} },
comment = { suffix = "k", options = {} }, comment = { suffix = "c", options = {} },
conflict = { suffix = "" }, -- disable to use git-conflict instead conflict = { suffix = "", options = {} },
diagnostic = { suffix = "d", options = {} }, diagnostic = { suffix = "d", options = {} },
file = { suffix = "", options = {} }, file = { suffix = "f", options = {} },
indent = { suffix = "" }, -- disable since we use indentscope above indent = { suffix = "", options = {} }, -- disable since we use indentscope above
jump = { suffix = "j", options = {} }, jump = { suffix = "j", options = {} },
location = { suffix = "l", options = {} }, location = { suffix = "l", options = {} },
oldfile = { suffix = "o", options = {} }, oldfile = { suffix = "o", options = {} },
quickfix = { suffix = "q", options = {} }, quickfix = { suffix = "q", options = {} },
treesitter = { suffix = "t", options = {} }, treesitter = { suffix = "t", options = {} },
undo = { suffix = "" }, -- disable since I don't need it undo = { suffix = "", options = {} }, -- disable since I don't need it
window = { suffix = "w", options = {} }, window = { suffix = "w", options = {} },
yank = { suffix = "y", options = {} }, yank = { suffix = "y", options = {} },
}, },

View file

@ -1,15 +1,4 @@
return { return {
{
"jmbuhr/otter.nvim",
config = function()
require("otter").setup({
buffers = {
set_filetype = true,
write_to_disk = false,
},
})
end,
},
{ {
"quarto-dev/quarto-nvim", "quarto-dev/quarto-nvim",
dependencies = { dependencies = {
@ -18,180 +7,80 @@ return {
"vim-pandoc/vim-pandoc-syntax", "vim-pandoc/vim-pandoc-syntax",
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
{ "benlubas/molten-nvim", optional = true },
}, },
config = function() config = function()
require("core.util").set_python_env()
require("quarto").setup({ require("quarto").setup({
lspFeatures = { lspFeatures = {
enabled = true, enabled = true,
languages = { "r", "python", "julia", "bash" }, languages = { "r", "python", "julia", "bash" },
diagnostics = { enabled = false, triggers = { "BufWritePost" } },
completion = { enabled = true },
}, },
codeRunner = { codeRunner = {
enabled = true, enabled = true,
default_method = "slime", default_method = "molten",
ft_runners = {
python = "molten",
quarto = "molten",
},
}, },
}) })
local map = vim.keymap.set
map("n", "<localleader>C", require("quarto.runner").run_cell, { desc = "run cell" })
map("n", "<localleader>ca", require("quarto.runner").run_above, { desc = "run cells above" })
map("n", "<localleader>cb", require("quarto.runner").run_below, { desc = "run cells below" })
map("n", "<localleader>cA", require("quarto.runner").run_all, { desc = "run all similar cells" })
map("n", "]c", "/^```{<cr>}:nohl<cr>", { desc = "Codecell forward" })
map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Codecell last" })
map("n", "<localleader>co", "o```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell below" })
map("n", "<localleader>cO", "O```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell above" })
end, end,
ft = { "quarto" }, ft = { "quarto" },
}, },
{ -- REPL work
"vhyrro/luarocks.nvim",
priority = 1001, -- this plugin needs to run before anything else
opts = {
rocks = { "magick" },
},
},
-- image display
{ {
"3rd/image.nvim", "3rd/image.nvim",
dependencies = { "luarocks.nvim" },
cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed
config = function() config = function()
local integrations = {} -- Example for configuring Neovim to load user-installed installed Lua rocks:
if vim.treesitter.language.get_lang("markdown") then package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua;"
integrations["markdown"] = { package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua;"
require("image").setup({
backend = "kitty",
integrations = {
markdown = {
enabled = true, enabled = true,
clear_in_insert_mode = true,
download_remote_images = true, download_remote_images = true,
only_render_image_at_cursor = true, only_render_image_at_cursor = true,
filetypes = { "markdown", "vimwiki", "quarto" }, filetypes = { "markdown", "vimwiki", "quarto" },
}
end
if vim.treesitter.language.get_lang("norg") then
integrations["neorg"] = {
enabled = true,
clear_in_insert_mode = true,
download_remote_images = true,
only_render_image_at_cursor = true,
filetypes = { "norg" },
}
end
if next(integrations) ~= nil then -- only set up if we have at least 1 TS parser
require("image").setup({
backend = "kitty",
integrations = integrations,
})
vim.g.molten_image_provider = "image.nvim"
end
end,
ft = { "markdown", "vimwiki", "quarto", "norg", "python" },
priority = 51,
}, },
-- REPL work },
})
end,
ft = { "markdown", "vimwiki", "quarto" },
},
{ {
"benlubas/molten-nvim", "benlubas/molten-nvim",
dependencies = {
{ "willothy/wezterm.nvim", config = true },
{ "3rd/image.nvim", optional = true },
},
build = ":UpdateRemotePlugins", build = ":UpdateRemotePlugins",
config = function() config = function()
vim.g.molten_image_provider = vim.g.molten_image_provider or "wezterm" vim.g.molten_image_provider = "none" -- image integration does NOT work currently :-(
vim.g.molten_auto_open_output = false vim.g.molten_auto_open_output = false
vim.g.molten_virt_text_output = true
if vim.fn.has("nvim-0.10") then
vim.g.molten_output_show_more = true
end
vim.api.nvim_create_autocmd("User", {
pattern = "MoltenInitPost",
callback = function()
local map = vim.keymap.set
if require("core.util").is_available("which-key") then
require("which-key").register({ ["<localleader>c"] = { name = "+codecells" } })
end
-- Operate jupyter notebooks from within vim
map(
"n",
"<localleader>cc",
":MoltenEvaluateOperator<cr>",
{ desc = "evaluate operator", silent = true }
)
map("n", "<localleader>cl", ":MoltenEvaluateLine<cr>", { desc = "evaluate line", silent = true })
map(
"x",
"<localleader>c",
":<C-u>MoltenEvaluateVisual<cr>",
{ desc = "evaluate visual", silent = true }
)
map(
"n",
"<localleader>cr",
":MoltenReevaluateCell<cr>",
{ desc = "reevaluate cell", silent = true }
)
map(
"n",
"<localleader>cp",
":noautocmd :MoltenEnterOutput<cr>",
{ silent = true, desc = "show output" }
)
map("n", "<localleader>cP", function()
vim.cmd("MoltenHideOutput")
vim.cmd("MoltenDelete")
end, { silent = true, desc = "hide output" })
map("n", "<localleader>ci", ":MoltenImagePopup<cr>", { silent = true, desc = "open image" })
map("n", "<localleader>cI", ":MoltenInterrupt<cr>", { desc = "interrupt cell", silent = true })
map("n", "<localleader>cD", ":MoltenDeinit<cr>", { desc = "de-init molten", silent = true })
map("n", "<localleader>cR", ":MoltenRestart<cr>", { desc = "restart molten", silent = true })
-- FIXME: Works for toggling TO virt text but not back
local function toggle_virtual_text_output()
if vim.g.molten_virt_text_output then
vim.fn.MoltenUpdateOption("molten_virt_text_output", false)
return
end
vim.fn.MoltenUpdateOption("molten_virt_text_output", true)
end
map(
"n",
"<localleader>cV",
toggle_virtual_text_output,
{ desc = "toggle virtual output", silent = true }
)
end, end,
}) cmd = {
vim.api.nvim_create_autocmd("User", { "MoltenInfo",
pattern = "MoltenDeinitPost", "MoltenInit",
callback = function() "MoltenDeinit",
local unmap = require("core.util").unmap_key "MoltenGoto",
unmap("<localleader>cc") "MoltenNext",
unmap("<localleader>cl") "MoltenPrev",
unmap("<localleader>c", "x") "MoltenEvaluateLine",
unmap("<localleader>cr") "MoltenEvaluateVisual",
unmap("<localleader>cR") "MoltenEvaluateOperator",
unmap("<localleader>cp") "MoltenEvaluateArgument",
unmap("<localleader>cP") "MoltenReevaluateCell",
unmap("<localleader>co") "MoltenDelete",
unmap("<localleader>cD") "MoltenShowOutput",
unmap("<localleader>ci") "MoltenHideOutput",
unmap("<localleader>cV") "MoltenEnterOutput",
local map = vim.keymap.set "MoltenInterrupt",
map("n", "<localleader>cI", ":MoltenInit<cr>", { desc = "init molten", silent = true }) "MoltenRestart",
end, "MoltenSave",
}) "MoltenLoad",
end, "MoltenExportOutput",
ft = { "norg", "quarto", "python" }, },
ft = { "quarto", "python" },
lazy = false,
keys = { keys = {
{ "<leader>vn", ":MoltenInfo<cr>" }, { "<leader>vn", ":MoltenInfo<cr>" },
{ "<localleader>ci", ":MoltenInit<cr>" },
}, },
}, },
-- Edit code blocks in md/quarto using whatever language is -- Edit code blocks in md/quarto using whatever language is
{ {
"AckslD/nvim-FeMaco.lua", "AckslD/nvim-FeMaco.lua",
@ -203,10 +92,8 @@ return {
dependencies = { dependencies = {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
}, },
keys = {
{ "<localleader>ce", ":FeMaco<cr>", desc = "edit codecell" },
},
}, },
-- MARKDOWN ONLY -- MARKDOWN ONLY
-- Evaluate markdown code blocks -- Evaluate markdown code blocks
{ {
@ -221,27 +108,4 @@ return {
}, },
lazy = false, lazy = false,
}, },
-- Open ipynb Jupyter notebooks as if they're quarto files
-- requires jupytext to be installed
{
"GCBallesteros/jupytext.nvim",
opts = {
style = "light",
custom_language_formatting = {
python = {
extension = "qmd",
style = "quarto",
force_ft = "quarto",
},
r = {
extension = "qmd",
style = "quarto",
force_ft = "quarto",
},
},
},
cond = vim.fn.executable("jupytext") == 1, -- only runs if imagemagick installed
lazy = false -- does not work in lazy mode
},
} }

View file

@ -3,11 +3,11 @@ local linters = {
bash = { "shellcheck" }, bash = { "shellcheck" },
javascript = { "eslint_d" }, javascript = { "eslint_d" },
javascriptreact = { "eslint_d" }, javascriptreact = { "eslint_d" },
markdown = { "markdownlint" }, markdown = { "markdownlint", "vale" },
quarto = { "markdownlint" }, quarto = { "markdownlint", "vale" },
sh = { "shellcheck" }, sh = { "shellcheck" },
svelte = { "eslint_d" }, svelte = { "eslint_d" },
text = {}, text = { "vale" },
typescript = { "eslint_d" }, typescript = { "eslint_d" },
typescriptreact = { "eslint_d" }, typescriptreact = { "eslint_d" },
} }
@ -96,14 +96,16 @@ return {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
cmd = { "LspInstall", "LspUninstall" }, cmd = { "LspInstall", "LspUninstall" },
}, },
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
}, },
event = { "BufReadPost", "BufNewFile", "BufWritePre" }, event = { "BufReadPost", "BufNewFile", "BufWritePre" },
after = { "nvim-cmp" },
config = function() config = function()
require("plugins.config.lsp") require("plugins.config.lsp")
end, end,
keys = { { "<leader>vs", ":LspInfo<cr>", desc = "LspInfo" } }, keys = { { "<leader>vs", ":LspInfo<cr>", desc = "LspInfo" } },
}, },
-- pretty lsp 'peek' menus -- very very pretty lsp 'peek' menus
{ {
"DNLHC/glance.nvim", "DNLHC/glance.nvim",
opts = { border = { enable = true }, theme = { enable = true, mode = "auto" } }, opts = { border = { enable = true }, theme = { enable = true, mode = "auto" } },
@ -111,9 +113,6 @@ return {
}, },
-- linting setup -- linting setup
{
"rshkarin/mason-nvim-lint",
dependencies = {
{ {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
config = function() config = function()
@ -126,17 +125,10 @@ return {
end, end,
}) })
end, end,
dependencies = { "williamboman/mason.nvim" },
},
},
event = { "BufReadPost", "BufNewFile", "BufWritePre" }, event = { "BufReadPost", "BufNewFile", "BufWritePre" },
opts = {},
}, },
-- formatting setup -- formatting setup
{
"zapling/mason-conform.nvim",
dependencies = {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
config = function() config = function()
@ -175,6 +167,7 @@ return {
}) })
end, end,
cmd = { "ConformInfo" }, cmd = { "ConformInfo" },
event = { "BufReadPost", "BufNewFile", "BufWritePre" },
keys = { keys = {
{ {
"<localleader>ll", "<localleader>ll",
@ -201,9 +194,38 @@ return {
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end, end,
}, },
-- completion setup
{
"hrsh7th/nvim-cmp",
branch = "main",
dependencies = {
"andersevenrud/cmp-tmux",
"cbarrete/completion-vcard",
"f3fora/cmp-spell",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp-signature-help",
"dmitmel/cmp-digraphs",
"jc-doyle/cmp-pandoc-references",
"kdheepak/cmp-latex-symbols",
"lukas-reineke/cmp-rg",
"crispgm/cmp-beancount",
"ray-x/cmp-treesitter",
"saadparwaiz1/cmp_luasnip",
{
"L3MON4D3/LuaSnip",
dependencies = { "rafamadriz/friendly-snippets" },
}, },
event = { "BufReadPost", "BufNewFile", "BufWritePre" }, },
opts = {}, config = function()
require("plugins.config.cmp")
end,
event = { "InsertEnter", "CmdlineEnter" },
}, },
-- useful quickfix-like buffer -- useful quickfix-like buffer

View file

@ -1,4 +1,4 @@
local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst" } local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" }
local prose_plugs = { local prose_plugs = {
-- UI improvements -- UI improvements
@ -69,26 +69,6 @@ local prose_plugs = {
ft = writing_ft, ft = writing_ft,
}, },
-- easy copy paste of images into markup files
{
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
opts = {
filetypes = {
quarto = {
url_encode_path = true,
template = "![$CURSOR]($FILE_PATH)",
download_images = false,
},
},
},
cmd = { "PasteImage" },
keys = {
{ "<leader>pp", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
},
ft = writing_ft,
},
-- bring zettelkasten commands -- bring zettelkasten commands
{ {
"mickael-menu/zk-nvim", "mickael-menu/zk-nvim",
@ -131,7 +111,6 @@ local prose_plugs = {
"ZkOrphans", "ZkOrphans",
}, },
keys = { keys = {
-- additional key instpirations https://github.com/al1-ce/MonolithVim/blob/master/after/ftplugin/markdown.lua
{ "<leader>ni", "<cmd>edit ~/documents/notes/index.md<cr>", desc = "open index", silent = true }, { "<leader>ni", "<cmd>edit ~/documents/notes/index.md<cr>", desc = "open index", silent = true },
{ "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" }, { "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
{ {

View file

@ -2,22 +2,6 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
-- show current cursor context at top of buffer
-- improves commenting plugin above by using ts
dependencies = {
{ "romgrk/nvim-treesitter-context", config = true },
"JoosepAlviste/nvim-ts-context-commentstring",
"RRethy/nvim-treesitter-textsubjects",
"windwp/nvim-ts-autotag",
"RRethy/nvim-treesitter-endwise",
-- rainbow brackets using treesitter
{
"HiPhish/rainbow-delimiters.nvim",
config = function()
require("rainbow-delimiters.setup").setup({})
end,
},
},
config = function() config = function()
require("nvim-treesitter.configs").setup({ require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages -- one of "all", "maintained" (parsers with maintainers), or a list of languages
@ -79,7 +63,7 @@ return {
filetype = "nu", filetype = "nu",
} }
end, end,
event = { "VeryLazy" }, event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
cmd = { cmd = {
"TSBufDisable", "TSBufDisable",
"TSBufEnable", "TSBufEnable",
@ -95,9 +79,24 @@ return {
"TSUpdate", "TSUpdate",
"TSUpdateSync", "TSUpdateSync",
}, },
keys = {
{ "<leader>si", "<cmd>Inspect<cr>", desc = "treesitter element", silent = true }, -- show current cursor context at top of buffer
{ "<leader>sI", "<cmd>InspectTree<cr>", desc = "treesitter tree", silent = true }, -- improves commenting plugin above by using ts
dependencies = {
{ "romgrk/nvim-treesitter-context", config = true },
"JoosepAlviste/nvim-ts-context-commentstring",
"RRethy/nvim-treesitter-textsubjects",
"windwp/nvim-ts-autotag",
"RRethy/nvim-treesitter-endwise",
}, },
}, },
-- rainbow brackets using treesitter
{
"https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
lazy = false,
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
config = function()
require("rainbow-delimiters.setup").setup({})
end,
},
} }

View file

@ -2,46 +2,18 @@ return {
-- statusline -- statusline
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
dependencies = { { "nvim-tree/nvim-web-devicons", config = true } }, requires = { "nvim-tree/nvim-web-devicons", config = true },
config = function() config = function()
local has_pynvim = -1 -- FIXME: Errors out on no pynvim installed
-- if molten exists, is initialized and connected to a kernel -- local function molten()
-- show it in the statusline -- if
local function molten() -- require("core.util").is_available("molten.status")
local function checked_pynvim(_, exitcode) -- and require("molten.status").initialized() ~= ""
if exitcode == 0 then -- then
has_pynvim = 1 -- return "󱪄"
else -- end
has_pynvim = 0 -- return ""
end -- end
end
if has_pynvim == 0 then
return ""
elseif has_pynvim == -1 then
vim.fn.jobstart({ "python", "-c", "from neovim import VERSION" }, { on_exit = checked_pynvim })
end
if
has_pynvim == 1
and require("core.util").is_available("molten.status")
and require("molten.status").kernels() ~= ""
then
return "󱪄"
end
return ""
end
-- count number of selected lines and characters
-- stolen: https://github.com/chrisgrieser/.config/blob/8af1841ba24f7c81c513e12f853b52f530ef5b37/nvim/lua/plugins/lualine.lua#L80C1-L87C4
local function selectionCount()
local isVisualMode = vim.fn.mode():find("[Vv]")
if not isVisualMode then
return ""
end
local starts = vim.fn.line("v")
local ends = vim.fn.line(".")
local lines = starts <= ends and ends - starts + 1 or starts - ends + 1
return " " .. tostring(lines) .. "L " .. tostring(vim.fn.wordcount().visual_chars) .. "C"
end
require("lualine").setup({ require("lualine").setup({
options = { options = {
icons_enabled = true, icons_enabled = true,
@ -55,9 +27,9 @@ return {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" }, lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" }, lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype", molten }, lualine_x = { "encoding", "fileformat", "filetype", "molten" },
lualine_y = { "progress" }, lualine_y = { "progress" },
lualine_z = { selectionCount, "location" }, lualine_z = { "location" },
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
@ -68,18 +40,7 @@ return {
lualine_z = {}, lualine_z = {},
}, },
tabline = {}, tabline = {},
extensions = { extensions = { "quickfix", "toggleterm" },
"aerial",
"lazy",
"man",
"mason",
"nvim-dap-ui",
"nvim-tree",
"oil",
"quickfix",
"toggleterm",
"trouble",
},
}) })
end, end,
event = { "VeryLazy" }, event = { "VeryLazy" },
@ -97,10 +58,10 @@ return {
}, },
}, },
event = { "VeryLazy" }, event = { "VeryLazy" },
cmd = { "Fidget" }, cmd = {"Fidget"},
keys = { keys = {
{ "<leader>sh", "<cmd>Fidget history<cr>", { silent = true, desc = "show notification history" } }, { "<leader>sh", "<cmd>Fidget history<cr>", { silent = true, desc = "show notification history" } },
}, }
}, },
-- make all vim.ui interfaces prettyy -- make all vim.ui interfaces prettyy
{ "stevearc/dressing.nvim", config = true, event = "VeryLazy" }, { "stevearc/dressing.nvim", config = true, event = "VeryLazy" },

View file

@ -1,80 +0,0 @@
# Markdown snippets
# Combination of snips from friendly-snippets and vim-snippets repos
snippet h1 Heading level 1
# ${0}
snippet h2 Heading level 2
## ${0}
snippet h3 Heading level 3
### ${0}
snippet h4 Heading level 4
#### ${0}
snippet h5 Heading level 5
##### ${0}
snippet h6 Heading level 6
##### ${0}
snippet ] Link
[${1:text}](${2:link})
snippet ]h Weblink
[${1:text}](https://${2:address})
snippet ]c Link filled with clipboard contents
[${1:text}](${2:`@+`})
snippet ]: Link reference style
[${1:id}]: ${2:text}
snippet ]] Footnote
[^${1:id}]${0}
[^${1:id}]: ${2:text}
snippet img Image link
![${1:alt}](${2:link})
snippet imgc Image link with clipboard content
![${1:alt}](${2:`@+`})
snippet ** Bold
**$0**
snippet __ Bold
__$0__
snippet --- Frontmatter
---
$0
---
# codeblocks
snippet `` Codeblock with language
\`\`\`${1:language}
${2:code}
\`\`\`
# table
snippet tb Simple table
| ${5:factors} | ${1:a} | ${2:b} |
| ------------- |------------- | ------- |
| ${3:f1} | ${0} | N |
| ${4:f2} | N | N |
# tasklists
snippet tl Tasklist item
- [ ] ${0:item}
snippet tl3 Tasklist item
- [ ] ${1:item}
- [ ] ${2:item}
- [ ] ${0:item}
# super/subscript - pandoc/extended markdown only
snippet sub Subscript
~${0}~
snippet sup Superscript
^${0}^

View file

@ -1,100 +0,0 @@
# Quarto extensions to markdown
extends markdown
# definitions list
snippet : Definition list
$1
: $0
snippet `` Codecell with language
\`\`\`{${1:language}}
${2:code}
\`\`\`
snippet ``p Codecell with language
\`\`\`{python}
${2:code}
\`\`\`
snippet ``r Codecell with language
\`\`\`{r}
${2:code}
\`\`\`
snippet pyfig2 Sub-Figures from python codecell
\`\`\`{python}
#| label: fig-${1:label}
#| fig-cap: "${2:caption}"
#| fig-subcap:
#| - "${3:subcap1}"
#| - "${3:subcap2}"
#| layout-ncol: 2
${0:code}
\`\`\`
snippet pyfig Figure from python codecell
\`\`\`{python}
#| label: fig-${1:label}
#| fig-cap: "${2:caption}"
${0:code}
\`\`\`
snippet fig General figure
![${1:caption}](${3:figure}){#fig-${2:label}}
snippet pytab Figure from python codecell
\`\`\`{python}
#| label: tbl-${1:label}
#| tbl-cap: "${2:caption}"
${0:code}
\`\`\`
snippet fref Figure crossref
@fig-${1:label}
snippet tref Table crossref
@tbl-${1:label}
snippet sref Section crossref
@sec-${1:label}
snippet eref Equation crossref
@eq-${1:label}
snippet cite Citation
[@${1:bib-key}]
snippet fn Footnote
[^${1:id}]
[^${1}]: ${2:text}
snippet shortcode Shortcode
{{< $0 >}}
snippet div Div block
::: {.${1:class}}
$0
:::
snippet note Callout note
::: {.callout-note}
$0
:::
snippet warn Callout warning
::: {.callout-warning}
$0
:::
snippet import Callout important
::: {.callout-important}
$0
:::
snippet tip Callout tip
::: {.callout-tip}
$0
:::
snippet caut Callout caution
::: {.callout-caution}
$0
:::

View file

@ -52,7 +52,7 @@ local keys = {
mods = "LEADER", mods = "LEADER",
action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }), action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }),
}, },
{ key = "T", mods = "LEADER", action = act.ShowTabNavigator }, { key = "t", mods = "LEADER", action = act.ShowTabNavigator },
{ key = "[", mods = "LEADER", action = act.ActivateCopyMode }, { key = "[", mods = "LEADER", action = act.ActivateCopyMode },
{ {
key = "r", key = "r",
@ -100,9 +100,7 @@ local keys = {
action = act.EmitEvent("ActivatePaneDirection-Right"), action = act.EmitEvent("ActivatePaneDirection-Right"),
}, },
{ key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") }, { key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") },
{ key = "t", mods = "LEADER", action = act.EmitEvent("toggle-tabbar") }, { key = "T", mods = "CTRL", action = act.EmitEvent("toggle-tabbar") },
{ key = "Enter", mods = "CTRL", action = wezterm.action({ SendString = "\x1b[13;5u" }) },
{ key = "Enter", mods = "SHIFT", action = wezterm.action({ SendString = "\x1b[13;2u" }) },
} }
-- Leader + number to activate that tab -- Leader + number to activate that tab
for i = 1, 8 do for i = 1, 8 do