Skip to content

Commit ac9bafe

Browse files
authored
feat: nvim 0.9.0! (#50)
* fix: adjust diagnosticts to otter.nvim refactor * perf: update diagnostics * docs: update readme * fix(CI): use nvim.appimage * feat: register markdown parser for quarto ft * !breaking change: require nvim => 0.9.0
1 parent 4ec0ee3 commit ac9bafe

File tree

4 files changed

+72
-101
lines changed

4 files changed

+72
-101
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
- name: Install Neovim
1616
shell: bash
1717
run: |
18-
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.deb -O /tmp/nvim.deb
19-
sudo dpkg -i /tmp/nvim.deb
18+
sudo apt install libfuse2
19+
sudo wget -q https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -O /usr/bin/nvim
20+
sudo chmod 0755 /usr/bin/nvim
2021
- name: Run Tests
2122
run: |
2223
nvim --version

README.md

Lines changed: 44 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,59 @@
11
# quarto-nvim
22

3-
Quarto-nvim provides tools for working on [quarto](https://quarto.org/) manuscripts in neovim.
3+
Quarto-nvim provides tools for working on [quarto](https://quarto.org/) manuscripts in Neovim.
44

5-
**Note**: Some functionality has been refactored into its own library [otter.nvim](https://github.com/jmbuhr/otter.nvim) for better extensibility.
5+
Quarto-nvim requires Neovim >= **v0.9.0** (https://github.com/neovim/neovim/releases/tag/stable).
66

77
## Setup
88

9-
Install the plugin from GitHub with your favourite neovim plugin manager.
10-
With example configuration:
9+
You can install `quarto-nvim` from GitHub with your favourite Neovim plugin manager
10+
like [lazy.nvim](https://github.com/folke/lazy.nvim), [packer.nvim](https://github.com/wbthomason/packer.nvim) or [VimPlug](https://github.com/junegunn/vim-plug).
1111

12-
### [packer.nvim](https://github.com/wbthomason/packer.nvim)
12+
Because Quarto provides a lot of functionality through integration with existing plugins,
13+
some of those have to be told about the existence of `quarto-nvim` (like e.g. registering
14+
it as a source for the autocompletion plugin `nvim-cmp`).
1315

14-
```lua
15-
use { 'quarto-dev/quarto-nvim',
16-
requires = {
17-
'jmbuhr/otter.nvim',
18-
'hrsh7th/nvim-cmp',
19-
'neovim/nvim-lspconfig',
20-
'nvim-treesitter/nvim-treesitter'
21-
},
22-
config = function()
23-
require 'quarto'.setup {
24-
lspFeatures = {
25-
enabled = true,
26-
languages = { 'r', 'python', 'julia' },
27-
diagnostics = {
28-
enabled = true,
29-
triggers = { "BufWrite" }
30-
},
31-
completion = {
32-
enabled = true
33-
}
34-
}
35-
}
36-
end
37-
}
38-
```
16+
As such, we recommend you to experiment with the [quarto-nvim kickstarter configuration](https://github.com/jmbuhr/quarto-nvim-kickstarter)
17+
and then pick the relevant parts from the
18+
[`lua/plugins/quarto.lua`](https://github.com/jmbuhr/quarto-nvim-kickstarter/blob/main/lua/plugins/quarto.lua) file
19+
to integrate it into your own existing configuration.
3920

40-
### [lazy.nvim](https://github.com/folke/lazy.nvim)
21+
Plugins and their configuration to look out for in this file are:
4122

4223
```lua
43-
{ 'quarto-dev/quarto-nvim',
44-
dependencies = {
45-
'jmbuhr/otter.nvim',
46-
'hrsh7th/nvim-cmp',
47-
'neovim/nvim-lspconfig',
48-
'nvim-treesitter/nvim-treesitter'
49-
},
50-
config = function()
51-
require 'quarto'.setup {
52-
lspFeatures = {
53-
enabled = true,
54-
languages = { 'r', 'python', 'julia' },
55-
diagnostics = {
56-
enabled = true,
57-
triggers = { "BufWrite" }
58-
},
59-
completion = {
60-
enabled = true
61-
}
62-
}
63-
}
64-
end
65-
},
66-
```
67-
68-
### [vim-plug](https://github.com/junegunn/vim-plug)
69-
70-
```vim
71-
Plug 'quarto-dev/quarto-nvim'
72-
Plug 'neovim/nvim-lspconfig'
73-
Plug 'jmbuhr/otter.nvim'
74-
Plug 'hrsh7th/nvim-cmp'
75-
Plug 'nvim-treesitter/nvim-treesitter'
24+
{
25+
'quarto-dev/quarto-nvim',
26+
'jmbuhr/otter.nvim',
27+
'hrsh7th/nvim-cmp',
28+
'neovim/nvim-lspconfig',
29+
'nvim-treesitter/nvim-treesitter'
30+
}
7631
```
7732

7833
## Usage
7934

80-
### Preview
35+
### Configure
8136

82-
Use the command
83-
84-
```vim
85-
QuartoPreview
86-
```
37+
You can pass a lua table with options to the setup function
38+
as shown in [quarto-nvim-kickstarter/..quarto.lua](https://github.com/jmbuhr/quarto-nvim-kickstarter/blob/main/lua/plugins/quarto.lua)
8739

88-
or access the function from lua, e.g. to create a keybinding:
89-
90-
```lua
91-
local quarto = require'quarto'
92-
vim.keymap.set('n', '<leader>qp', quarto.quartoPreview, {silent = true, noremap = true})
93-
```
94-
95-
Then use the keyboard shortcut to open `quarto preview` for the current file or project in the active working directory in the neovim integrated terminal in a new tab.
96-
97-
## Configure
98-
99-
You can pass a lua table with options to the setup function.
100-
It will be merged with the default options, which are shown below in the example:
40+
It will be merged with the default options, which are shown below in the example.
41+
If you want to use the defaults, simply call `setup` without arguments or with an empty table.
10142

10243
```lua
10344
require'quarto'.setup{
10445
debug = false,
10546
closePreviewOnExit = true,
10647
lspFeatures = {
107-
enabled = false,
108-
languages = { 'r', 'python', 'julia' },
48+
enabled = true,
49+
languages = { 'r', 'python', 'julia', 'bash' },
10950
chunks = 'curly', -- 'curly' or 'all'
11051
diagnostics = {
11152
enabled = true,
112-
triggers = { "BufWrite" }
53+
triggers = { "BufWritePost" }
11354
},
11455
completion = {
115-
enabled = false,
56+
enabled = true,
11657
},
11758
},
11859
keymap = {
@@ -122,7 +63,22 @@ require'quarto'.setup{
12263
}
12364
```
12465

125-
If you only need `QuartoPreview`, you don't have to call the setup function.
66+
### Preview
67+
68+
Use the command
69+
70+
```vim
71+
QuartoPreview
72+
```
73+
74+
or access the function from lua, e.g. to create a keybinding:
75+
76+
```lua
77+
local quarto = require'quarto'
78+
vim.keymap.set('n', '<leader>qp', quarto.quartoPreview, {silent = true, noremap = true})
79+
```
80+
81+
Then use the keyboard shortcut to open `quarto preview` for the current file or project in the active working directory in the neovim integrated terminal in a new tab.
12682

12783
## Language support
12884

lua/quarto/init.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ local api = vim.api
33
local util = require "lspconfig.util"
44
local tools = require 'quarto.tools'
55
local otter = require 'otter'
6+
local otterkeeper = require'otter.keeper'
67

78
M.defaultConfig = {
89
debug = false,
910
closePreviewOnExit = true,
1011
lspFeatures = {
11-
enabled = false,
12-
languages = { 'r', 'python', 'julia' },
12+
enabled = true,
13+
languages = { 'r', 'python', 'julia', 'bash' },
1314
chunks = 'curly', -- 'curly' or 'all'
1415
diagnostics = {
1516
enabled = true,
16-
triggers = { "BufWrite" }
17+
triggers = { "BufWritePost" }
1718
},
1819
completion = {
19-
enabled = false,
20+
enabled = true,
2021
},
2122
},
2223
keymap = {
@@ -86,12 +87,13 @@ M.enableDiagnostics = function()
8687
buffer = main_nr,
8788
group = api.nvim_create_augroup("quartoLSPDiagnositcs", { clear = false }),
8889
callback = function(_, _)
89-
local bufnrs = otter.sync_raft(main_nr)
90-
for _, bufnr in ipairs(bufnrs) do
90+
local bufnrs = otterkeeper._otters_attached[main_nr].buffers
91+
otterkeeper.sync_raft(main_nr)
92+
for lang, bufnr in pairs(bufnrs) do
9193
local diag = vim.diagnostic.get(bufnr)
92-
local ns = api.nvim_create_namespace('quarto-lang-' .. bufnr)
93-
vim.diagnostic.reset(ns, 0)
94-
vim.diagnostic.set(ns, 0, diag, {})
94+
local ns = api.nvim_create_namespace('quarto-lang-' .. lang)
95+
vim.diagnostic.reset(ns, main_nr)
96+
vim.diagnostic.set(ns, main_nr, diag, {})
9597
end
9698
end
9799
})

plugin/quarto.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
local quarto = require'quarto'
1+
if vim.fn.has("nvim-0.9.0") ~= 1 then
2+
local msg =
3+
[[quarto-dev/quarto-nvim and jmbuhr/otter.nvim require Neovim version >= 0.9.0 (https://github.com/neovim/neovim/releases/tag/stable). Please upgrade to get access to the latest features and performance improvements.]]
4+
local displayed = vim.notify_once(msg, vim.log.levels.WARN)
5+
if displayed then
6+
return msg
7+
end
8+
return
9+
end
10+
11+
local quarto = require 'quarto'
212
local api = vim.api
313

414
api.nvim_create_user_command('QuartoPreview', quarto.quartoPreview, {})
515
api.nvim_create_user_command('QuartoClosePreview', quarto.quartoClosePreview, {})
616
api.nvim_create_user_command('QuartoDiagnostics', quarto.enableDiagnostics, {})
717
api.nvim_create_user_command('QuartoActivate', quarto.activate, {})
8-
api.nvim_create_user_command('QuartoHelp', quarto.searchHelp, {nargs=1})
18+
api.nvim_create_user_command('QuartoHelp', quarto.searchHelp, { nargs = 1 })
919
api.nvim_create_user_command('QuartoHover', quarto.quartoHover, {})
1020

21+
vim.treesitter.language.register('markdown', 'quarto')
22+

0 commit comments

Comments
 (0)