Compare commits

..

27 commits

Author SHA1 Message Date
87ce74de40
nvim: Show selection in lualine
Shows number of lines and characters selected in visual mode.
2024-06-17 15:39:53 +02:00
0f46dcad28
nvim: Fix molten statusline icon
Fixed issue when pynvim did not exist in the environment but we tried to
invoke a molten-nvim command. Now we first fire up python to check for
pynvim existence. This takes a moment so we do it asynchronously and
cache the result for the rest of the program runtime.

Also we only show the molten icon if we are actually connected to a
running kernel.
2024-06-17 15:39:25 +02:00
2d513ad74b
nvim: Remove vale linter
It does not work right. I tried to set up the lsp instead, and that also
is giving me more trouble than I can troubleshoot right now.
2024-06-17 14:32:24 +02:00
b4a9b5179f
nvim: Automatically install linters and formatters
Switch out mason-tool-installer for mason-conform.nvim and
mason-nvim-lint as respective wrappers for automatically installing
formatters and linters.

Follows the same principle as mason-lspconfig.nvim (in fact, the repos
are mostly based on the same code) and apply the concept to the other
tools: Whatever is enabled in the respective plugins (lspconfig,
nvim-lint and conform.nvim) will automatically be installed by mason.

This is really neat and basically takes care of me ever having to
interact much with Mason itself or manually set up the tools to be
installed. All I have to make sure is that they're updated once in a
while.
2024-06-17 14:00:00 +02:00
b2dfdfd5ff
nvim: Fix ruff lsp
We now make use of the ruff-inbuilt LSP offering since it just entered
beta.
We also disable all rules in pyright LSP that ruff takes care of, and in
turn disable hover capability in ruff since it's worse than pyright
(still).
More information here:
https://github.com/astral-sh/ruff/tree/main/crates/ruff_server#setup
and here:
https://github.com/astral-sh/ruff/blob/main/crates/ruff_server/docs/setup/NEOVIM.md
2024-06-17 13:34:02 +02:00
8dbfa2dd13
nvim: Extend snippet capability
Enabled snippet completion from the first letter (allowing single letter
snippet prefixes).
Extended the luasnip usage and added a telescope extension to show all
enabled snippets for the current buffer.
2024-06-17 13:34:02 +02:00
a7aca62a15
nvim: Extend lualine enabled extensions
Added more extensions for plugins that I use, all pre-defined.
2024-06-17 13:34:01 +02:00
c45d85922b
nvim: Fix wrong lazy.nvim plugin spec options
Some options were left over from old plugin managers, some were just
used wrong.
2024-06-17 13:34:00 +02:00
157fbc812c
nvim: Extraction completion setup into own module
As a first step to disentangle the ide.lua module into completion,
formatting, lsp (and maybe lint?), this separates the completion module
into its own file.
2024-06-17 10:42:12 +02:00
543a149da2
nvim: Update treesitter dependencies
Moved rainbow delimiters into dependencies so that it runs with TS
instead of loading TS on its own. Made TS itself more lazy (only loading
on VeryLazy by default).

Run TSUpdate on each run instead of only each build step.
2024-06-17 10:31:39 +02:00
c4f2522f2b
wezterm: Ensure CTRL and SHIFT mods passed through
These bindings ensure that wezterm understands (and informs the shell)
that `<C-Return>` and `<S-Return>` are different key binds than just
`<Return>` on its own.

For example 'euporie' uses it to mimic the python notebook 'enter means
newline but ctrl-enter means execute' style of quick coding.
2024-06-17 08:30:06 +02:00
d8823d4661
wezterm: Switch navigator and tab hiding maps around
Since I (almost) never use the navigator, it has been put behind
`<leader>T`. The tab-hiding I used a (little) more often so that now
lies behind `<leader>t`. Simple change.
2024-06-17 08:27:35 +02:00
1a2e83ccb6
nvim: Fix overlapping REPL key maps 2024-06-16 22:30:49 +02:00
fae2d85cca
nvim: Fix crash on no python venv available 2024-06-16 22:30:11 +02:00
fa1db974f0
nvim: Update plugins 2024-06-16 21:38:05 +02:00
ebee0042d8
nvim: Fix correct workspace propagation for python env 2024-06-16 21:36:58 +02:00
b2c64a0925
nvim: Allow pasting images into markup files
With the new `img-clip.nvim` extension we can copy any image anywhere
and simply paste it into a markdown/quarto/latex/typst/... document with
the right markup already.

Those can be from the web/locally. Also allows drag and drop from e.g.
web pages.

Mapped to `<leader>pp` currently, though we will have to find a better
mapping. Or invoked with `:ImagePaste`.
2024-06-16 21:36:57 +02:00
3b1a874883
nvim: Open ipynb files as quarto files
We can now open any ipynb file as if it were a quarto document by
leveraging the `jupytext.nvim` extension which works in the background
to convert everything. Will only work if `jupytext` program is actually
installed on the machine.

Allows normal editing of the file and will write any changes back to the
original notebook on save and exit!
2024-06-16 21:36:57 +02:00
4d8cc4d2af
nvim: Add FeMaco codecell edit mapping
Added mapping to quickly edit any code cell in FeMaco, an extra buffer
which brings lsp functionality and similar with it. Can be used as a
fallback if otter.nvim is not working for the buffer, or when working on
a buffer which otter.nvim does not understand.
2024-06-16 21:36:56 +02:00
0ec49583bd
nvim: Set up image.nvim image display
Finally got image.nvim fully working on wezterm with the kitty backend
and auto-installed rock dependencies.
2024-06-16 21:36:55 +02:00
e25aedd94b
nvim: Set up molten for interactive python repl
Set it up with extended options and keymaps. Will use an image provider
if it has been set externally (usually set by the 'image.nvim' setup
routine) or fall back to use the `wezterm.nvim` plugin to display it in
a wezterm pane. This display can be a little buggy so we should prefer
others.
2024-06-16 21:36:54 +02:00
63dc6fb888
nvim: Set up quarto for interactive python work 2024-06-16 21:36:53 +02:00
849489afd6
nvim: Move mini.bracketed comment to k suffix
Moved the mini bracketed comment following to use the ]k [k suffix. I am
not sure if this is completely taking since every now and again it seems
to still be overriding my own configured mapping.
2024-06-16 17:42:48 +02:00
9dcd2f3d48
nvim: Add direct python env set utility function
Added a simple 'set python environment' function to directly set the
correct python binary and update the PATH for python.
2024-06-16 17:41:18 +02:00
0bac43eb91
nvim: Split python venv fetching into multiple
Now we can either fetch the python venv basefolder
(`require('core.util').get_python_venv_basefolder()`) or specifically
the python binary contained within (`.get_python_bin()`).

Additionally, the venv result should be cached for the duration of using
nvim so that we only have to fetch it once, regardless of how many
modules require it.
2024-06-16 17:37:54 +02:00
4f5445cc0e
nvim: Add function to cleanly unmap keys
Removes them from being active in vim as well as removing them from
being displayed in which-key.

Unfortunately the which-key implementation still seems broken, sometimes
removing them sometimes leaving them as-is.
2024-06-16 16:40:10 +02:00
3e13941eae
nvim: Add mappings for inspecting treesitter
Simply invokes the `:Inspect` and `:InspectTree` commands, to have
quicker access, especially while tinkering with TS for the foreseeable
future.
2024-06-15 19:26:42 +02:00
17 changed files with 855 additions and 465 deletions

View file

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

View file

@ -6,14 +6,13 @@ local default_buffer_session = function()
if vim.fn.getftype(dir) ~= "dir" then
vim.fn.mkdir(dir, "p")
end
return temp_path
end
-- Start quarto session
local startsession = function(file, args)
file = file or default_buffer_session()
local path = require("core.util").get_python_venv()
local path = require("core.util").get_python_venv_bin()
vim.g["python3_host_prog"] = path
if vim.fn.executable("jupyter-console") ~= 1 then
@ -41,92 +40,27 @@ vim.api.nvim_create_user_command("JupyterStart", function()
startsession()
end, {})
local map = vim.keymap.set
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,
vim.api.nvim_create_autocmd({"InsertEnter", "BufEnter"}, {
callback = function()
if vim.b["sessionfile"] == nil then
local path = default_buffer_session()
vim.b["sessionfile"] = path
vim.schedule_wrap(startsession(path))
end
end,
})
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", "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" })
-- 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()
vim.b["sessionfile"] = path
vim.schedule_wrap(startsession(path))
end
-- vim.g["python3_host_prog"] = vim.fn.expand(require("core.util").get_python_venv())

View file

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

View file

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

View file

@ -17,32 +17,67 @@ function T.get_plugin(plugin)
return nil
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
local function path_join(...)
return table.concat(vim.tbl_flatten({ ... }), "/")
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
function T.get_python_venv(workspace)
function T.get_python_venv_basefolder(workspace)
if venv_path and venv_path ~= "" then
return venv_path
end
-- Use activated virtualenv.
if vim.env.VIRTUAL_ENV then
return path_join(vim.env.VIRTUAL_ENV, "bin", "python")
venv_path = vim.env.VIRTUAL_ENV
return venv_path
end
-- Find and use virtualenv in workspace directory.
for _, pattern in ipairs({ "*", ".*" }) do
local match = vim.fn.glob(path_join(workspace, pattern, "pyvenv.cfg"))
if match ~= "" then
local py = path_join("bin", "python")
match = string.gsub(match, "pyvenv.cfg", py)
return match
match = string.gsub(match, "pyvenv.cfg", "")
venv_path = match
return venv_path
end
match = vim.fn.glob(path_join(workspace, pattern, "poetry.lock"))
if match ~= "" then
local venv_base_folder = vim.fn.trim(vim.fn.system("poetry env info -p"))
return path_join(venv_base_folder, "bin", "python")
venv_path = venv_base_folder
return venv_path
end
end
-- Fallback to system Python.
return vim.fn.exepath("python3") or vim.fn.exepath("python") or "python"
end
return T

View file

@ -0,0 +1,199 @@
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

@ -1,144 +0,0 @@
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" },
},
basedpyright = {},
ruff_lsp = {},
ruff = {},
serve_d = {},
tailwindcss = {},
taplo = {},
@ -43,17 +43,7 @@ local servers = {
yamlls = {},
}
-- 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 function on_attach(_, bufnr)
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_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" })
@ -166,21 +156,35 @@ local python_path
-- ensure python virtualenv is determined automatically on lsp start
lspconfig.basedpyright.setup({
on_attach = function(client, bufnr)
on_attach(client, bufnr)
if python_path == nil then
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir))
end
vim.g["python3_host_prog"] = 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.pythonPath = python_path
on_attach(client, bufnr)
end,
settings = {
-- disable imports and linting since, we use ruff for that
pyright = {
disableOrganizeImports = true,
},
python = {
analysis = {
ignore = { "*" },
},
},
},
})
lspconfig.ruff_lsp.setup({
lspconfig.ruff.setup({
on_attach = function(client, bufnr)
on_attach(client, bufnr)
client.server_capabilities.hoverProvider = false -- we use pyright for hover info
if python_path == nil then
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir))
end
vim.g["python3_host_prog"] = python_path
client.config.settings.python = {} or client.config.settings.python
client.config.settings.python.pythonPath = python_path
end,

View file

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

View file

@ -1,4 +1,15 @@
return {
{
"jmbuhr/otter.nvim",
config = function()
require("otter").setup({
buffers = {
set_filetype = true,
write_to_disk = false,
},
})
end,
},
{
"quarto-dev/quarto-nvim",
dependencies = {
@ -7,80 +18,180 @@ return {
"vim-pandoc/vim-pandoc-syntax",
"hrsh7th/nvim-cmp",
"nvim-treesitter/nvim-treesitter",
{ "benlubas/molten-nvim", optional = true },
},
config = function()
require("core.util").set_python_env()
require("quarto").setup({
lspFeatures = {
enabled = true,
languages = { "r", "python", "julia", "bash" },
diagnostics = { enabled = false, triggers = { "BufWritePost" } },
completion = { enabled = true },
},
codeRunner = {
enabled = true,
default_method = "molten",
default_method = "slime",
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,
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",
dependencies = { "luarocks.nvim" },
cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed
config = function()
-- Example for configuring Neovim to load user-installed installed Lua rocks:
package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua;"
package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua;"
require("image").setup({
backend = "kitty",
integrations = {
markdown = {
enabled = true,
download_remote_images = true,
only_render_image_at_cursor = true,
filetypes = { "markdown", "vimwiki", "quarto" },
},
},
})
local integrations = {}
if vim.treesitter.language.get_lang("markdown") then
integrations["markdown"] = {
enabled = true,
clear_in_insert_mode = true,
download_remote_images = true,
only_render_image_at_cursor = true,
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" },
ft = { "markdown", "vimwiki", "quarto", "norg", "python" },
priority = 51,
},
-- REPL work
{
"benlubas/molten-nvim",
dependencies = {
{ "willothy/wezterm.nvim", config = true },
{ "3rd/image.nvim", optional = true },
},
build = ":UpdateRemotePlugins",
config = function()
vim.g.molten_image_provider = "none" -- image integration does NOT work currently :-(
vim.g.molten_image_provider = vim.g.molten_image_provider or "wezterm"
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,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MoltenDeinitPost",
callback = function()
local unmap = require("core.util").unmap_key
unmap("<localleader>cc")
unmap("<localleader>cl")
unmap("<localleader>c", "x")
unmap("<localleader>cr")
unmap("<localleader>cR")
unmap("<localleader>cp")
unmap("<localleader>cP")
unmap("<localleader>co")
unmap("<localleader>cD")
unmap("<localleader>ci")
unmap("<localleader>cV")
local map = vim.keymap.set
map("n", "<localleader>cI", ":MoltenInit<cr>", { desc = "init molten", silent = true })
end,
})
end,
cmd = {
"MoltenInfo",
"MoltenInit",
"MoltenDeinit",
"MoltenGoto",
"MoltenNext",
"MoltenPrev",
"MoltenEvaluateLine",
"MoltenEvaluateVisual",
"MoltenEvaluateOperator",
"MoltenEvaluateArgument",
"MoltenReevaluateCell",
"MoltenDelete",
"MoltenShowOutput",
"MoltenHideOutput",
"MoltenEnterOutput",
"MoltenInterrupt",
"MoltenRestart",
"MoltenSave",
"MoltenLoad",
"MoltenExportOutput",
},
ft = { "quarto", "python" },
lazy = false,
ft = { "norg", "quarto", "python" },
keys = {
{ "<leader>vn", ":MoltenInfo<cr>" },
{ "<localleader>ci", ":MoltenInit<cr>" },
},
},
-- Edit code blocks in md/quarto using whatever language is
{
"AckslD/nvim-FeMaco.lua",
@ -92,8 +203,10 @@ return {
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
keys = {
{ "<localleader>ce", ":FeMaco<cr>", desc = "edit codecell" },
},
},
-- MARKDOWN ONLY
-- Evaluate markdown code blocks
{
@ -108,4 +221,27 @@ return {
},
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" },
javascript = { "eslint_d" },
javascriptreact = { "eslint_d" },
markdown = { "markdownlint", "vale" },
quarto = { "markdownlint", "vale" },
markdown = { "markdownlint" },
quarto = { "markdownlint" },
sh = { "shellcheck" },
svelte = { "eslint_d" },
text = { "vale" },
text = {},
typescript = { "eslint_d" },
typescriptreact = { "eslint_d" },
}
@ -96,16 +96,14 @@ return {
"williamboman/mason-lspconfig.nvim",
cmd = { "LspInstall", "LspUninstall" },
},
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
},
event = { "BufReadPost", "BufNewFile", "BufWritePre" },
after = { "nvim-cmp" },
config = function()
require("plugins.config.lsp")
end,
keys = { { "<leader>vs", ":LspInfo<cr>", desc = "LspInfo" } },
},
-- very very pretty lsp 'peek' menus
-- pretty lsp 'peek' menus
{
"DNLHC/glance.nvim",
opts = { border = { enable = true }, theme = { enable = true, mode = "auto" } },
@ -114,118 +112,98 @@ return {
-- linting setup
{
"mfussenegger/nvim-lint",
config = function()
require("lint").linters_by_ft = linters
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
callback = function()
if not vim.g.disable_autolint then
require("lint").try_lint()
end
"rshkarin/mason-nvim-lint",
dependencies = {
{
"mfussenegger/nvim-lint",
config = function()
require("lint").linters_by_ft = linters
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
callback = function()
if not vim.g.disable_autolint then
require("lint").try_lint()
end
end,
})
end,
})
end,
dependencies = { "williamboman/mason.nvim" },
},
},
event = { "BufReadPost", "BufNewFile", "BufWritePre" },
opts = {},
},
-- formatting setup
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
lsp_fallback = true,
format_after_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { lsp_fallback = true }
"zapling/mason-conform.nvim",
dependencies = {
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
lsp_fallback = true,
format_after_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { lsp_fallback = true }
end,
formatters_by_ft = formatters,
formatters = {
-- enable python isort functionality
ruff_fix = {
prepend_args = { "--select", "I" },
},
},
})
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable formatting on save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Enable formatting on save",
})
end,
formatters_by_ft = formatters,
formatters = {
-- enable python isort functionality
ruff_fix = {
prepend_args = { "--select", "I" },
cmd = { "ConformInfo" },
keys = {
{
"<localleader>ll",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
desc = "Format buffer",
},
{
"<localleader>lL",
function()
vim.g.disable_autoformat = not vim.g.disable_autoformat
end,
desc = "Toggle AutoFormat",
},
{
"<leader>vf",
":ConformInfo<cr>",
desc = "ConformInfo",
},
},
})
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable formatting on save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Enable formatting on save",
})
end,
cmd = { "ConformInfo" },
init = function()
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
},
},
event = { "BufReadPost", "BufNewFile", "BufWritePre" },
keys = {
{
"<localleader>ll",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
desc = "Format buffer",
},
{
"<localleader>lL",
function()
vim.g.disable_autoformat = not vim.g.disable_autoformat
end,
desc = "Toggle AutoFormat",
},
{
"<leader>vf",
":ConformInfo<cr>",
desc = "ConformInfo",
},
},
init = function()
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
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" },
},
},
config = function()
require("plugins.config.cmp")
end,
event = { "InsertEnter", "CmdlineEnter" },
opts = {},
},
-- useful quickfix-like buffer

View file

@ -1,4 +1,4 @@
local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" }
local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex", "typst" }
local prose_plugs = {
-- UI improvements
@ -69,6 +69,26 @@ local prose_plugs = {
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
{
"mickael-menu/zk-nvim",
@ -111,6 +131,7 @@ local prose_plugs = {
"ZkOrphans",
},
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>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
{

View file

@ -2,6 +2,22 @@ return {
{
"nvim-treesitter/nvim-treesitter",
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()
require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
@ -63,7 +79,7 @@ return {
filetype = "nu",
}
end,
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
event = { "VeryLazy" },
cmd = {
"TSBufDisable",
"TSBufEnable",
@ -79,24 +95,9 @@ return {
"TSUpdate",
"TSUpdateSync",
},
-- 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",
keys = {
{ "<leader>si", "<cmd>Inspect<cr>", desc = "treesitter element", silent = true },
{ "<leader>sI", "<cmd>InspectTree<cr>", desc = "treesitter tree", silent = true },
},
},
-- 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,18 +2,46 @@ return {
-- statusline
{
"nvim-lualine/lualine.nvim",
requires = { "nvim-tree/nvim-web-devicons", config = true },
dependencies = { { "nvim-tree/nvim-web-devicons", config = true } },
config = function()
-- FIXME: Errors out on no pynvim installed
-- local function molten()
-- if
-- require("core.util").is_available("molten.status")
-- and require("molten.status").initialized() ~= ""
-- then
-- return "󱪄"
-- end
-- return ""
-- end
local has_pynvim = -1
-- if molten exists, is initialized and connected to a kernel
-- show it in the statusline
local function molten()
local function checked_pynvim(_, exitcode)
if exitcode == 0 then
has_pynvim = 1
else
has_pynvim = 0
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({
options = {
icons_enabled = true,
@ -27,9 +55,9 @@ return {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype", "molten" },
lualine_x = { "encoding", "fileformat", "filetype", molten },
lualine_y = { "progress" },
lualine_z = { "location" },
lualine_z = { selectionCount, "location" },
},
inactive_sections = {
lualine_a = {},
@ -40,7 +68,18 @@ return {
lualine_z = {},
},
tabline = {},
extensions = { "quickfix", "toggleterm" },
extensions = {
"aerial",
"lazy",
"man",
"mason",
"nvim-dap-ui",
"nvim-tree",
"oil",
"quickfix",
"toggleterm",
"trouble",
},
})
end,
event = { "VeryLazy" },
@ -58,10 +97,10 @@ return {
},
},
event = { "VeryLazy" },
cmd = {"Fidget"},
cmd = { "Fidget" },
keys = {
{ "<leader>sh", "<cmd>Fidget history<cr>", { silent = true, desc = "show notification history" } },
}
},
},
-- make all vim.ui interfaces prettyy
{ "stevearc/dressing.nvim", config = true, event = "VeryLazy" },

View file

@ -0,0 +1,80 @@
# 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

@ -0,0 +1,100 @@
# 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",
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 = "r",
@ -100,7 +100,9 @@ local keys = {
action = act.EmitEvent("ActivatePaneDirection-Right"),
},
{ key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") },
{ key = "T", mods = "CTRL", action = act.EmitEvent("toggle-tabbar") },
{ key = "t", mods = "LEADER", 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
for i = 1, 8 do