···1;; extends
2+;; sql injection for sqlx in rust
34(macro_invocation
5 macro: (scoped_identifier
+10
candy/ftplugin/rust.lua
···0000000000
···1+-- I just like having it seperated by ft even if its not heavy
2+vim.g.rustaceanvim = {
3+ tools = {},
4+ server = {
5+ settings = {
6+ ["rust-analyzer"] = {},
7+ },
8+ },
9+ dap = {},
10+}
···1-local M = {}
2-3-M.root_patterns = { ".git", "lua" }
4-5--- returns the root directory based on:
6--- * lsp workspace folders
7--- * lsp root_dir
8--- * root pattern of filename of the current buffer
9--- * root pattern of cwd
10----@return string
11-function M.get_root()
12- ---@type string?
13- local path = vim.api.nvim_buf_get_name(0)
14- path = path ~= "" and vim.loop.fs_realpath(path) or nil
15- ---@type string[]
16- local roots = {}
17- if path then
18- for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
19- local workspace = client.config.workspace_folders
20- local paths = workspace
21- and vim.tbl_map(function(ws)
22- return vim.uri_to_fname(ws.uri)
23- end, workspace)
24- or client.config.root_dir and { client.config.root_dir }
25- or {}
26- for _, p in ipairs(paths) do
27- local r = vim.loop.fs_realpath(p)
28- if path:find(r, 1, true) then
29- roots[#roots + 1] = r
30- end
31- end
32- end
33- end
34- table.sort(roots, function(a, b)
35- return #a > #b
36- end)
37- ---@type string?
38- local root = roots[1]
39- if not root then
40- path = path and vim.fs.dirname(path) or vim.loop.cwd()
41- ---@type string?
42- root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
43- root = root and vim.fs.dirname(root) or vim.loop.cwd()
44- end
45- ---@cast root string
46- return root
47-end
48-49-return M