Skip to content

Commit 06a9082

Browse files
committed
fix: copy lspconfig util functions to remove dependency. fixes #175
1 parent 3c25bf3 commit 06a9082

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ return {
3232
```
3333

3434
Because Quarto provides a lot of functionality through integration with existing plugins,
35-
we recommend to experiment with the [quarto-nvim kickstarter configuration](https://github.com/jmbuhr/quarto-nvim-kickstarter)
35+
you may want to experiment with my [config](https://github.com/jmbuhr/nvim-config)
3636
and then pick the relevant parts from the
37-
[`lua/plugins/quarto.lua`](https://github.com/jmbuhr/quarto-nvim-kickstarter/blob/main/lua/plugins/quarto.lua) file
37+
[`lua/plugins/quarto.lua`](https://github.com/jmbuhr/nvim-config/blob/main/lua/plugins/quarto.lua) file
3838
to integrate it into your own existing configuration.
3939

4040
Plugins and their configuration to look out for in either of those files are:
@@ -49,15 +49,13 @@ Plugins and their configuration to look out for in either of those files are:
4949
}
5050
```
5151

52-
Quarto-nvim requires the latest [Neovim stable version](https://github.com/neovim/neovim/releases/tag/stable) (>= `v0.10.0`).
52+
Quarto-nvim requires [Neovim stable version](https://github.com/neovim/neovim/releases/tag/stable) >= `v0.10.0`.
5353

5454
## Usage
5555

5656
### Configure
5757

58-
You can pass a lua table with options to the setup function
59-
as shown in [quarto-nvim-kickstarter/..quarto.lua](https://github.com/jmbuhr/quarto-nvim-kickstarter/blob/main/lua/plugins/quarto.lua)
60-
58+
You can pass a lua table with options to the setup function or via `lazy.nvim`s `opts` keyword.
6159
It will be merged with the default options, which are shown below in the example.
6260
If you want to use the defaults, simply call `setup` without arguments or with an empty table.
6361

@@ -219,6 +217,6 @@ QuartoSendLine
219217
Quarto works great with a number of plugins in the neovim ecosystem.
220218
You can find my (@jmbuhr) personal (and thus up-to-date) configuration for use with Quarto, R and python here:
221219

222-
<https://github.com/jmbuhr/quarto-nvim-kickstarter>
220+
<https://github.com/jmbuhr/nvim-config>
223221

224222
But remember, the best config is always your own.

lua/quarto/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local M = {}
22
local api = vim.api
33
local cfg = require 'quarto.config'
44
local tools = require 'quarto.tools'
5-
local util = require 'lspconfig.util'
5+
local util = require 'quarto.util'
66

77
---Quarto preview
88
---@param opts table

lua/quarto/util.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
-- functions from neovim/nvim-lspconfig
2+
local M = {}
3+
4+
local nvim_eleven = vim.fn.has 'nvim-0.11' == 1
5+
6+
function M.tbl_flatten(t)
7+
--- @diagnostic disable-next-line:deprecated
8+
return nvim_eleven and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t)
9+
end
10+
11+
function M.strip_archive_subpath(path)
12+
-- Matches regex from zip.vim / tar.vim
13+
path = vim.fn.substitute(path, 'zipfile://\\(.\\{-}\\)::[^\\\\].*$', '\\1', '')
14+
path = vim.fn.substitute(path, 'tarfile:\\(.\\{-}\\)::.*$', '\\1', '')
15+
return path
16+
end
17+
18+
local function escape_wildcards(path)
19+
return path:gsub('([%[%]%?%*])', '\\%1')
20+
end
21+
22+
function M.root_pattern(...)
23+
local patterns = M.tbl_flatten { ... }
24+
return function(startpath)
25+
startpath = M.strip_archive_subpath(startpath)
26+
for _, pattern in ipairs(patterns) do
27+
local match = M.search_ancestors(startpath, function(path)
28+
for _, p in ipairs(vim.fn.glob(table.concat({ escape_wildcards(path), pattern }, '/'), true, true)) do
29+
if vim.uv.fs_stat(p) then
30+
return path
31+
end
32+
end
33+
end)
34+
35+
if match ~= nil then
36+
return match
37+
end
38+
end
39+
end
40+
end
41+
42+
return M

0 commit comments

Comments
 (0)