-
1. ObjectiveI'm using lazyvim as a template to create my own 2. What I triedI mentioned in a previous discussion that I've managed "to make marksman work for both markdown md and quarto qmd files. Both symbols-outline.nvim and nvim-navbuddy can recognize the headings in qmd files without including the comment symbol # in a code block", as shown by the code below. return {
-- add pyright and marksman to lspconfig
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- pyright will be automatically installed with mason and loaded with lspconfig
pyright = {},
marksman = {},
},
},
-- add marksman support for markdown and quoarto files
config = function()
local lspconfig = require("lspconfig")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local util = require("lspconfig.util")
local on_attach2 = function(client, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
local opts = { noremap = true, silent = true }
buf_set_keymap("n", "gh", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_set_keymap("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
buf_set_keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
buf_set_keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
buf_set_keymap("n", "<leader>ll", "<cmd>lua vim.lsp.codelens.run()<cr>", opts)
client.server_capabilities.document_formatting = true
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
-- also need to add the following to $home/.config/marksman/config.toml :
-- [core]
-- markdown.file_extensions = ["md", "markdown", "qmd"]
lspconfig.marksman.setup({
on_attach = on_attach2,
capabilities = capabilities,
filetypes = { "markdown", "quarto" },
root_dir = util.root_pattern(".git", ".marksman.toml", "_quarto.yml"),
})
end,
},
} 3. The problemHowever, this config seemed to interfere with and wash away some of the default 4. My questionI want to ask how to add configs of More specifically, I noticed the lspconfig.marksman.setup {
on_attach = on_attach_qmd,
capabilities = capabilities,
filetypes = { 'markdown', 'quarto' },
root_dir = util.root_pattern(".git", ".marksman.toml", "_quarto.yml"),
} So, how to achieve the same in the return {
-- add pyright and marksman to lspconfig
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- pyright will be automatically installed with mason and loaded with lspconfig
pyright = {},
marksman = {
filetypes = { "markdown", "quarto" },
},
},
},
},
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
I made a version of kickstarter based on LazyVim for this very purpose. Incidentally, the on_attach things are not necessary there because LazyVim uses the LspAttach autocommand, which runs before on_attach, so I was able to add my own autocommand right inside of quarto/otter (here: https://github.com/quarto-dev/quarto-nvim/blob/main/ftplugin/quarto.lua). If quarto is configured after lspconfig (determined via the dependencies), it's keybindings should win out. This should be the case in the example. |
Beta Was this translation helpful? Give feedback.
-
@jmbuhr Thank you very much. The lazyvim-starter-for-quarto is very helpful. I modifed my I didn't add any keymap for {
"quarto-dev/quarto-nvim",
dev = false,
ft = "quarto",
-- dependencies = {
-- "neovim/nvim-lspconfig",
-- },
opts = {
lspFeatures = {
languages = { "r", "python", "julia", "bash", "lua", "html" },
},
},
keys = {
{
"<leader>qp",
"<CMD>QuartoPreview<CR>",
desc = "Quarto Preview",
},
},
}, However, when I press the Firstly, the
Secondly, the keymap for I want to ask: |
Beta Was this translation helpful? Give feedback.
-
Hi @jmbuhr, thank you. However, after I updated quarto and otter plugins in my config, I'm getting the following error while trying to rename a variable in python:
My quarto.lua file is in this oatLazyVim config. I used this hello.qmd file to test renaming the variable "r" in the python code block. |
Beta Was this translation helpful? Give feedback.
I made a version of kickstarter based on LazyVim for this very purpose.
https://github.com/jmbuhr/lazyvim-starter-for-quarto/blob/main/lua/plugins/quarto.lua
should contain everything you need.
Incidentally, the on_attach things are not necessary there because LazyVim uses the LspAttach autocommand, which runs before on_attach, so I was able to add my own autocommand right inside of quarto/otter (here: https://github.com/quarto-dev/quarto-nvim/blob/main/ftplugin/quarto.lua). If quarto is configured after lspconfig (determined via the dependencies), it's keybindings should win out. This should be the case in the example.