Compare commits

...

3 Commits

Author SHA1 Message Date
iGor milhit d89a6c4d5f
wip plugins: configure environment for quarto
- Installs and configures the nvim-quarto plugin.
- Adds needed plugins and configuration from diving in the quarto
  kickstart configuration, which is damn huge.
- Adds the marksman parser for markdown, with its configuration.
- Adds the quarto filetype to the pandoc pluging.
- Loads the markdown snippets for the quarto filetype.
- Adds language support for treesitter.
- Installs and configure vim-slime plugin in order to execute emmbedded
  code (but it doesn't work as it misses a LOT of configuration).
- Documents very shortly the added plugins in the README.

Co-Authored-by: iGor milhit <igor@milhit.ch>
2024-10-10 14:47:13 +02:00
iGor milhit 5c7675e938
plugins: add zotcite and cmp-zotcite plugins
- Adds zotcite plugins (with completion).

Co-Authored-by: iGor milhit <igor@milhit.ch>
2024-10-10 14:45:24 +02:00
iGor milhit bd142e38b1
plugins: folds .md frontmatter and code blocks
- Folds the frontmatter YAML and fenced code blocks in markdown file.
- Removes unneccessary filetype for lazy loading markdown plugins.
- Moves a markdownpreview settings that was wrongfully placed in the
  pandoc plugin configuration.
- Lazy loads mkdnflow plugin for quarto filetype.

Co-Authored-by: iGor milhit <igor@milhit.ch>
2024-10-10 14:40:45 +02:00
11 changed files with 132 additions and 27 deletions

View File

@ -102,6 +102,10 @@ I won't provide links for each of these plugins as they are easily to be found.
- `rainbow-csv.nvim` to manage CSV files.
- `venv-selector.nvim` to ease python virtual env.
- `vim-grammalecte` to get a good grammar checker for French.
- Quarto:
- `nvim-quarto` to add quarto environment configuration.
- `otter` for the embedded code completion.
- `vim-slime` for the embedded code execution.
<!-- references -->

View File

@ -3,7 +3,5 @@
-- See :h awa
vim.opt.awa=true
-- vim.opt.foldmethod = "expr"
-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.foldlevel = 1
vim.opt.conceallevel = 2
-- vim.opt.foldlevel = 1
-- vim.opt.conceallevel = 2

View File

@ -1,3 +1,7 @@
-- Temporary setting needed to make otter working
-- https://github.com/jmbuhr/otter.nvim/issues/179
vim.treesitter.language.register("markdown", { "quarto", "rmd" })
-- Search and replace
-- Ignore case except when using a capital case
-- Highlight found occurrences

View File

@ -17,6 +17,8 @@ return {
-- Import lspconfig
local lspconfig = require("lspconfig")
local util = require("lspconfig.util")
-- Import mason-tool-installer
local mason_tool_installer = require("mason-tool-installer")
@ -51,6 +53,7 @@ return {
"html",
"jsonls",
"lua_ls",
"marksman",
"pylsp",
"yamlls",
},
@ -105,7 +108,7 @@ return {
end,
jsonls = function()
lspconfig.lua_ls.setup({
lspconfig.jsonls.setup({
settings = {
json = {
schemas = require("schemastore").json.schemas(),
@ -113,6 +116,22 @@ return {
}
}
})
end,
marksman = function()
lspconfig.marksman.setup({
setting = {
filetypes = {
"markdown",
"quarto",
},
root_dir = util.root_pattern(
'.git',
'.marksman.toml',
'_quarto.yml'
),
}
})
end
},
})

View File

@ -2,13 +2,15 @@
-- https://github.com/iamcco/markdown-preview.nvim
-- https://github.com/iamcco/markdown-preview.nvim/issues/558#issuecomment-1514701537
-- Defines the filetypes that should be recognize by markdown-preview.
vim.cmd([[ let g:mkdp_filetypes = ['markdown', 'pandoc',] ]])
return {
{
"iamcco/markdown-preview.nvim",
ft = {
'pandoc',
'markdown',
'pandoc.markdown'
},
lazy = true,
build = "cd app && npm install && git reset --hard",

View File

@ -17,7 +17,7 @@ return {
ft = {
'pandoc',
'markdown',
'pandoc.markdown',
'quarto'
},
lazy = true,
config = function ()

View File

@ -1,12 +1,18 @@
-- Install and configure Pandoc plugins: vim-pandoc, vim-pandoc-syntax
-- Defines the filetypes that should be recognize by vim-pandoc. Allows
-- mardown-preview to be available with pandoc filetype.
vim.cmd([[ let g:mkdp_filetypes = ['markdown', 'pandoc', 'pandoc.markdown'] ]])
-- Sets the pandoc formatting mode to hardwrap
vim.cmd([[ let g:pandoc#formatting#mode = "hA" ]])
-- Pandoc folding settings
-- Fold level 2 headings
vim.cmd([[ let g:pandoc#folding#level=1 ]])
-- Enable YAML folding
vim.cmd([[ let g:pandoc#folding#fold_yaml=1 ]])
-- Fold the entire frontmatter
vim.cmd([[ let g:pandoc#folding#foldlevel_yaml=2 ]])
-- Fold fenced code blocks
vim.cmd([[ let g:pandoc#folding#fold_fenced_codeblocks=1 ]])
-- Keymaps to switch to soft or hardwarp, or to toggle.
vim.keymap.set(
'n',
@ -40,8 +46,7 @@ return {
"vim-pandoc/vim-pandoc",
ft = {
'markdown',
'pandoc',
'pandoc.markdown'
'pandoc'
},
lazy = true,
},
@ -49,8 +54,7 @@ return {
"vim-pandoc/vim-pandoc-syntax",
ft = {
'markdown',
'pandoc',
'pandoc.markdown'
'pandoc'
},
lazy = true,
},

View File

@ -28,6 +28,9 @@ return {
"hrsh7th/cmp-emoji",
-- vs-code pictrograms
"onsails/lspkind.nvim",
-- Completion source for code emmbedded in other documents
"jmbuh/otter.nvim",
},
-- Configure nvim-cmp
@ -40,11 +43,12 @@ return {
luasnip.config.setup {
-- Extend markdown snippets to pandoc filetype
-- https://github.com/L3MON4D3/LuaSnip/issues/132#issuecomment-1101710309
-- https://github.com/L3MON4D3/LuaSnip/issues/132#issuecomment-1101731222
snippets = {
markdown = {},
},
luasnip.filetype_extend("pandoc", {"markdown"}),
luasnip.filetype_extend("quarto", {"markdown"}),
}
-- Load snippets from ~/.config/nvim/my_snippets/
@ -107,6 +111,7 @@ return {
},
{ name = "path" },
{ name = "emoji" },
{ name = "cmp_zotcite"} -- zotcite (plugins/markdown/zotcite.lua)
}),
formatting = {

View File

@ -0,0 +1,16 @@
-- Install and configure `quarto-nvim`
-- https://github.com/quarto-dev/quarto-nvim
return {
{
"quarto-dev/quarto-nvim",
lazy = true,
ft = {
"quarto",
},
dependencies = {
"jmbuhr/otter.nvim",
"nvim-treesitter/nvim-treesitter",
},
},
}

View File

@ -39,6 +39,7 @@ return {
-- Configure treesitter
config = function()
---@diagnostic disable-next-line: missing-fields
local config = require("nvim-treesitter.configs")
config.setup({
@ -55,24 +56,26 @@ return {
-- Installed and configured languages
ensure_installed = {
"bash",
"css",
"dot",
"gitignore",
"html",
"javascript",
"json",
"julia",
"latex",
"lua",
"python",
"vim",
"yaml",
},
-- Empty option, to avoid warning
modules = {},
-- List of parsers to ignore installing
ignore_install = {
"markdown",
"markdown_inline"
"markdown_inline",
"mermaid",
"norg",
"python",
"query",
"r",
"typescript",
"vim",
"vimdoc",
"yaml",
},
-- Do not install parses synchronously

View File

@ -0,0 +1,50 @@
-- Install and configure vim-slime
-- https://github.com/jpalardy/vim-slime
return {
'jpalardy/vim-slime',
dev = false,
init = function()
vim.b['quarto_is_python_chunk'] = false
Quarto_is_in_python_chunk = function()
require('otter.tools.functions').is_otter_language_context 'python'
end
vim.cmd [[
let g:slime_dispatch_ipython_pause = 100
function SlimeOverride_EscapeText_quarto(text)
call v:lua.Quarto_is_in_python_chunk()
if exists('g:slime_python_ipython') && len(split(a:text,"\n")) > 1 && b:quarto_is_python_chunk && !(exists('b:quarto_is_r_mode') && b:quarto_is_r_mode)
return ["%cpaste -q\n", g:slime_dispatch_ipython_pause, a:text, "--", "\n"]
else
if exists('b:quarto_is_r_mode') && b:quarto_is_r_mode && b:quarto_is_python_chunk
return [a:text, "\n"]
else
return [a:text]
end
end
endfunction
]]
vim.g.slime_target = 'neovim'
vim.g.slime_no_mappings = true
vim.g.slime_python_ipython = 1
end,
config = function()
vim.g.slime_input_pid = false
vim.g.slime_suggest_default = true
vim.g.slime_menu_config = false
vim.g.slime_neovim_ignore_unlisted = true
local function mark_terminal()
local job_id = vim.b.terminal_job_id
vim.print('job_id: ' .. job_id)
end
local function set_terminal()
vim.fn.call('slime#config', {})
end
vim.keymap.set('n', '<leader>cm', mark_terminal, { desc = '[m]ark terminal' })
vim.keymap.set('n', '<leader>cs', set_terminal, { desc = '[s]et terminal' })
end
}