···11;; extends
22+;; sql injection for sqlx in rust
2334(macro_invocation
45 macro: (scoped_identifier
+10
candy/ftplugin/rust.lua
···11+-- I just like having it seperated by ft even if its not heavy
22+vim.g.rustaceanvim = {
33+ tools = {},
44+ server = {
55+ settings = {
66+ ["rust-analyzer"] = {},
77+ },
88+ },
99+ dap = {},
1010+}
···11-local M = {}
22-33-M.root_patterns = { ".git", "lua" }
44-55--- returns the root directory based on:
66--- * lsp workspace folders
77--- * lsp root_dir
88--- * root pattern of filename of the current buffer
99--- * root pattern of cwd
1010----@return string
1111-function M.get_root()
1212- ---@type string?
1313- local path = vim.api.nvim_buf_get_name(0)
1414- path = path ~= "" and vim.loop.fs_realpath(path) or nil
1515- ---@type string[]
1616- local roots = {}
1717- if path then
1818- for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
1919- local workspace = client.config.workspace_folders
2020- local paths = workspace
2121- and vim.tbl_map(function(ws)
2222- return vim.uri_to_fname(ws.uri)
2323- end, workspace)
2424- or client.config.root_dir and { client.config.root_dir }
2525- or {}
2626- for _, p in ipairs(paths) do
2727- local r = vim.loop.fs_realpath(p)
2828- if path:find(r, 1, true) then
2929- roots[#roots + 1] = r
3030- end
3131- end
3232- end
3333- end
3434- table.sort(roots, function(a, b)
3535- return #a > #b
3636- end)
3737- ---@type string?
3838- local root = roots[1]
3939- if not root then
4040- path = path and vim.fs.dirname(path) or vim.loop.cwd()
4141- ---@type string?
4242- root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
4343- root = root and vim.fs.dirname(root) or vim.loop.cwd()
4444- end
4545- ---@cast root string
4646- return root
4747-end
4848-4949-return M