Compare commits
7 Commits
4419f2e5f3
...
b84e46bda1
| Author | SHA1 | Date | |
|---|---|---|---|
| b84e46bda1 | |||
| 65680cb255 | |||
| f54bbc5676 | |||
| 70486dda84 | |||
| d7122e9345 | |||
| 2fdabfb056 | |||
| 1b0b2ad50c |
15
docs/README.md
Normal file
15
docs/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# New Spec
|
||||
|
||||
For new LSP, add in `lua/modules/language-specs.lua` at `lsp = <name>`.
|
||||
Name should match the mason registry one at: `https://github.com/mason-org/mason-registry/tree/main/packages`
|
||||
|
||||
1. Run `nvim --headless +InstallAll +qa` (it invalidates cache automatically)
|
||||
2. Run ` nvim --headless +FetchLspConfigs +qa` -> It will download the nvim-lspconfig variant in `lsp/`
|
||||
|
||||
You may need to run: `pkill prettierd` (as it is running in background)
|
||||
|
||||
# Other commands
|
||||
|
||||
```
|
||||
nvim --headless +Sync +qa # For packages/plugins
|
||||
```
|
||||
23
docs/docs.md
23
docs/docs.md
@@ -1,13 +1,3 @@
|
||||
TODO:
|
||||
- wrap up invero theme in separate repo and proper colors?
|
||||
- check plugins logins
|
||||
- cache / create final result
|
||||
- simplify coding: ts, lsp, lint, format (check other repos)
|
||||
- how to download parsers and plugins alternative
|
||||
- telescope alternative
|
||||
- keymaps
|
||||
- wrap up everything
|
||||
|
||||
```lua
|
||||
--[[
|
||||
Neovim Lua config: ways to set things
|
||||
@@ -31,6 +21,7 @@ TODO:
|
||||
## check macos fileS: https://github.com/dsully/dotfiles/blob/main/.data/macos-defaults/globals.yaml
|
||||
|
||||
# Used pacakges:
|
||||
|
||||
- rockspaces Metadata files describing how to build and install a Lua package.
|
||||
- luarocks Package manager for Lua modules. (optional)
|
||||
- tree-sitter Parser generator. Not needed except for using CLI. (optional)
|
||||
@@ -66,8 +57,8 @@ TODO:
|
||||
- ncurses ncurses-dev ncurses-libs ncurses-terminfo \
|
||||
- check: https://github.com/glepnir/nvim/blob/main/Dockerfile
|
||||
|
||||
|
||||
# Currently installed
|
||||
|
||||
- plenary.nvim
|
||||
- lazy.nvim
|
||||
|
||||
@@ -93,11 +84,12 @@ TODO:
|
||||
- plenary.nvim
|
||||
- harpoon # tags
|
||||
|
||||
|
||||
# Notes:
|
||||
|
||||
- in lsp change tsserver to vtsls
|
||||
|
||||
# New package definition
|
||||
|
||||
- Plugin and Package managers
|
||||
- folke/lazy.nvim
|
||||
- mason-org/mason.nvim
|
||||
@@ -106,7 +98,6 @@ TODO:
|
||||
- nvim-treesitter-textobjects
|
||||
- LSP
|
||||
- neovim/nvim-lspconfig
|
||||
|
||||
- nvim-ts-autotag tag elements (`</>`)
|
||||
- windwp/nvim-autopairs auto pairs
|
||||
- blink.cmp autocompletion
|
||||
@@ -123,11 +114,13 @@ TODO:
|
||||
- mini.indentscope
|
||||
|
||||
## Deps:
|
||||
|
||||
- SchemaStore.nvim
|
||||
- mason-lspconfig.nvim
|
||||
- mason.nvim
|
||||
|
||||
## Maybe:
|
||||
|
||||
- folke/ts-comments.nvim better comments
|
||||
- grug-far.nvim find and replace
|
||||
- markdown-preview.nvim side by side md (disabled in folke)
|
||||
@@ -146,6 +139,7 @@ TODO:
|
||||
- undo tree (find a plugin)
|
||||
|
||||
## AI help
|
||||
|
||||
- jackMort/ChatGPT.nvim
|
||||
- MunifTanjim/nui.nvim (dep)
|
||||
- nvim-lua/plenary.nvim (dep)
|
||||
@@ -155,6 +149,7 @@ TODO:
|
||||
- milanglacier/minuet-ai.nvim (folke)
|
||||
|
||||
## Options
|
||||
|
||||
```
|
||||
|
||||
opt.backup = true
|
||||
@@ -178,6 +173,7 @@ vim.keymap.set("n", "<C-c>", "ciw")
|
||||
```
|
||||
|
||||
folke cmd
|
||||
|
||||
```lua
|
||||
-- show cursor line only in active window
|
||||
vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, {
|
||||
@@ -210,6 +206,7 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
```
|
||||
|
||||
Enable folding with TS:
|
||||
|
||||
```
|
||||
vim.opt.foldmethod = "expr"
|
||||
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
|
||||
6
init.lua
6
init.lua
@@ -5,6 +5,12 @@ end
|
||||
|
||||
vim.env.PATH = vim.fn.stdpath('data') .. '/mason/bin:' .. vim.env.PATH
|
||||
|
||||
vim.filetype.add({
|
||||
pattern = {
|
||||
['.*/templates/.*%.ya?ml'] = 'yaml.helm-values',
|
||||
},
|
||||
})
|
||||
|
||||
require('core.options')
|
||||
require('core.keymaps')
|
||||
require('core.events')
|
||||
|
||||
25
lsp/helm_ls.lua
Normal file
25
lsp/helm_ls.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
---@brief
|
||||
---
|
||||
--- https://github.com/mrjosh/helm-ls
|
||||
---
|
||||
--- Helm Language server. (This LSP is in early development)
|
||||
---
|
||||
--- `helm Language server` can be installed by following the instructions [here](https://github.com/mrjosh/helm-ls).
|
||||
---
|
||||
--- The default `cmd` assumes that the `helm_ls` binary can be found in `$PATH`.
|
||||
---
|
||||
--- If need Helm file highlight use [vim-helm](https://github.com/towolf/vim-helm) plugin.
|
||||
|
||||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = { 'helm_ls', 'serve' },
|
||||
filetypes = { 'helm', 'yaml.helm-values' },
|
||||
root_markers = { 'Chart.yaml' },
|
||||
capabilities = {
|
||||
workspace = {
|
||||
didChangeWatchedFiles = {
|
||||
dynamicRegistration = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
80
lsp/yamlls.lua
Normal file
80
lsp/yamlls.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
---@brief
|
||||
---
|
||||
--- https://github.com/redhat-developer/yaml-language-server
|
||||
---
|
||||
--- `yaml-language-server` can be installed via `yarn`:
|
||||
--- ```sh
|
||||
--- yarn global add yaml-language-server
|
||||
--- ```
|
||||
---
|
||||
--- To use a schema for validation, there are two options:
|
||||
---
|
||||
--- 1. Add a modeline to the file. A modeline is a comment of the form:
|
||||
---
|
||||
--- ```
|
||||
--- # yaml-language-server: $schema=<urlToTheSchema|relativeFilePath|absoluteFilePath}>
|
||||
--- ```
|
||||
---
|
||||
--- where the relative filepath is the path relative to the open yaml file, and the absolute filepath
|
||||
--- is the filepath relative to the filesystem root ('/' on unix systems)
|
||||
---
|
||||
--- 2. Associated a schema url, relative , or absolute (to root of project, not to filesystem root) path to
|
||||
--- the a glob pattern relative to the detected project root. Check `:checkhealth vim.lsp` to determine the resolved project
|
||||
--- root.
|
||||
---
|
||||
--- ```lua
|
||||
--- vim.lsp.config('yamlls', {
|
||||
--- ...
|
||||
--- settings = {
|
||||
--- yaml = {
|
||||
--- ... -- other settings. note this overrides the lspconfig defaults.
|
||||
--- schemas = {
|
||||
--- ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
|
||||
--- ["../path/relative/to/file.yml"] = "/.github/workflows/*",
|
||||
--- ["/path/from/root/of/project"] = "/.github/workflows/*",
|
||||
--- },
|
||||
--- },
|
||||
--- }
|
||||
--- })
|
||||
--- ```
|
||||
---
|
||||
--- Currently, kubernetes is special-cased in yammls, see the following upstream issues:
|
||||
--- * [#211](https://github.com/redhat-developer/yaml-language-server/issues/211).
|
||||
--- * [#307](https://github.com/redhat-developer/yaml-language-server/issues/307).
|
||||
---
|
||||
--- To override a schema to use a specific k8s schema version (for example, to use 1.18):
|
||||
---
|
||||
--- ```lua
|
||||
--- vim.lsp.config('yamlls', {
|
||||
--- ...
|
||||
--- settings = {
|
||||
--- yaml = {
|
||||
--- ... -- other settings. note this overrides the lspconfig defaults.
|
||||
--- schemas = {
|
||||
--- ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.32.1-standalone-strict/all.json"] = "/*.k8s.yaml",
|
||||
--- ... -- other schemas
|
||||
--- },
|
||||
--- },
|
||||
--- }
|
||||
--- })
|
||||
--- ```
|
||||
|
||||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = { 'yaml-language-server', '--stdio' },
|
||||
filetypes = { 'helm', 'yaml', 'yaml.docker-compose', 'yaml.gitlab', 'yaml.helm-values' },
|
||||
root_markers = { '.git' },
|
||||
settings = {
|
||||
-- https://github.com/redhat-developer/vscode-redhat-telemetry#how-to-disable-telemetry-reporting
|
||||
redhat = { telemetry = { enabled = false } },
|
||||
-- formatting disabled by default in yaml-language-server; enable it
|
||||
yaml = { format = { enable = true } },
|
||||
},
|
||||
on_init = function(client)
|
||||
--- https://github.com/neovim/nvim-lspconfig/pull/4016
|
||||
--- Since formatting is disabled by default if you check `client:supports_method('textDocument/formatting')`
|
||||
--- during `LspAttach` it will return `false`. This hack sets the capability to `true` to facilitate
|
||||
--- autocmd's which check this capability
|
||||
client.server_capabilities.documentFormattingProvider = true
|
||||
end,
|
||||
}
|
||||
@@ -31,12 +31,14 @@ vim.opt.textwidth = 100
|
||||
vim.opt.colorcolumn = '+0'
|
||||
|
||||
vim.opt.signcolumn = 'no'
|
||||
vim.opt.number = false
|
||||
vim.opt.relativenumber = false
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.cursorline = false
|
||||
vim.opt.ruler = false
|
||||
vim.opt.winborder = 'rounded'
|
||||
vim.opt.guicursor = 'n-v-i-c:block'
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = { leadmultispace = '│ ', tab = '→ ', trail = '·' }
|
||||
|
||||
vim.opt.laststatus = 3
|
||||
vim.opt.statusline = '── %f %h%w%m%r %= [%l,%c-%L] ──'
|
||||
|
||||
@@ -1,7 +1,32 @@
|
||||
local M = {}
|
||||
|
||||
-- vim.filetype.add({
|
||||
-- pattern = {
|
||||
-- ['.*/templates/.*%.ya?ml'] = 'yaml.helm-values',
|
||||
-- ['.*/templates/.*%.tpl'] = 'yaml.helm-values',
|
||||
-- },
|
||||
-- })
|
||||
|
||||
-- vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
|
||||
-- pattern = '**/templates/**/*.y?ml',
|
||||
-- callback = function()
|
||||
-- vim.bo.filetype = 'yaml.helm-values'
|
||||
-- end,
|
||||
-- })
|
||||
--
|
||||
function M.get()
|
||||
return {
|
||||
{
|
||||
ft = 'yaml.helm-values',
|
||||
ts = 'helm',
|
||||
lsp = 'helm-ls',
|
||||
},
|
||||
{
|
||||
ft = 'yaml',
|
||||
ts = 'yaml',
|
||||
lsp = 'yaml-language-server',
|
||||
format = { 'prettierd', 'prettier' },
|
||||
},
|
||||
{ ts = { 'yaml', 'toml', 'sql', 'diff', 'dockerfile', 'gitcommit', 'gitignore' } },
|
||||
{ ts = { 'c', 'cpp', 'go', 'rust', 'python' } },
|
||||
|
||||
@@ -17,7 +42,7 @@ function M.get()
|
||||
lsp = { 'vtsls', 'eslint-lsp' },
|
||||
format = { 'prettierd', 'prettier' },
|
||||
},
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
require('plugins.filetree')
|
||||
require('plugins.finder').setup({
|
||||
local finder = require('plugins.finder')
|
||||
finder.setup({
|
||||
exclude_patterns = { 'node_modules', 'dist', 'build', '.git', '.cache', '.turbo', '*-lock.json' },
|
||||
use_disk_cache = true, -- optional
|
||||
use_disk_cache = true,
|
||||
follow_symlinks = true,
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '<leader>f', function()
|
||||
require('plugins.finder').files()
|
||||
end)
|
||||
|
||||
vim.keymap.set('n', '<leader>g', function()
|
||||
require('plugins.finder').grep()
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>f', finder.files)
|
||||
vim.keymap.set('n', '<leader>g', finder.grep)
|
||||
-- vim.keymap.set('n', '<leader>fc', finder.clear_cache)
|
||||
-- vim.keymap.set('n', '<leader>fD', finder.diagnose)
|
||||
|
||||
@@ -4,6 +4,8 @@ function M.load_theme()
|
||||
highlights = function(c, tool)
|
||||
c.bg_float = tool(152)
|
||||
return {
|
||||
FinderPath = { fg = c.muted },
|
||||
Whitespace = { fg = c.outline_light },
|
||||
ModeMsg = { fg = c.yellow, bg = c.none, bold = true },
|
||||
WinSeparator = { fg = c.outline, bg = c.base },
|
||||
StatusLine = { fg = c.outline, bg = c.base, bold = false },
|
||||
|
||||
@@ -99,7 +99,7 @@ require('nvim-tree').setup({
|
||||
modified = { enable = true, show_on_dirs = true, show_on_open_dirs = true },
|
||||
filters = {
|
||||
enable = true,
|
||||
git_ignored = true,
|
||||
git_ignored = false,
|
||||
dotfiles = false,
|
||||
git_clean = false,
|
||||
no_buffer = false,
|
||||
|
||||
@@ -6,7 +6,7 @@ local M = {}
|
||||
-- Config
|
||||
---------------------------------------------------------------------
|
||||
M.config = {
|
||||
file_cmd = nil, -- "fd" | "fdfind" | nil (auto)
|
||||
file_cmd = nil, -- "fd" | "fdfind" | nil (auto-detect)
|
||||
grep_cmd = 'rg', -- ripgrep binary
|
||||
page_size = 60, -- soft cap; real viewport height is measured
|
||||
debounce_ms = 80,
|
||||
@@ -15,8 +15,10 @@ M.config = {
|
||||
cache_ttl_sec = 20,
|
||||
max_items = 5000, -- safety cap for massive outputs
|
||||
debug = false,
|
||||
follow_symlinks = true, -- pass -L to fd
|
||||
grep_path_width = 30,
|
||||
|
||||
-- Exclusion controls (added to tool flags and used in glob fallback)
|
||||
-- Exclusion patterns (used by fd/rg in addition to their gitignore handling)
|
||||
exclude_patterns = { 'node_modules', 'dist', 'build', '.git' },
|
||||
|
||||
-- Optional on-disk filelist cache at $ROOT/.devflow/finder_cache.json
|
||||
@@ -77,16 +79,18 @@ local function L(msg, data)
|
||||
end
|
||||
|
||||
local function now_sec()
|
||||
return vim.loop.now() / 1000
|
||||
return os.time()
|
||||
end
|
||||
|
||||
local function clamp(v, lo, hi)
|
||||
return (v < lo) and lo or ((v > hi) and hi or v)
|
||||
end
|
||||
|
||||
local function cmd_exists(bin)
|
||||
return vim.fn.executable(bin) == 1
|
||||
end
|
||||
|
||||
-- single reusable timer to avoid churn; caller controls ms
|
||||
-- single reusable timer to avoid churn
|
||||
local function debounce(fn, ms)
|
||||
if not S.timer then
|
||||
S.timer = vim.loop.new_timer()
|
||||
@@ -98,30 +102,12 @@ local function debounce(fn, ms)
|
||||
end)
|
||||
end
|
||||
|
||||
local function read_gitignore(root)
|
||||
local p = root .. '/.gitignore'
|
||||
local f = io.open(p, 'r')
|
||||
if not f then
|
||||
return {}
|
||||
end
|
||||
local lines = {}
|
||||
for line in f:lines() do
|
||||
local l = vim.trim(line)
|
||||
if #l > 0 and not l:match('^#') and not l:match('^!') then
|
||||
l = l:gsub('/+$', '')
|
||||
table.insert(lines, l)
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
return lines
|
||||
end
|
||||
|
||||
local function ensure_cache_dir(root)
|
||||
local dir = root .. '/.devflow'
|
||||
local ok = vim.loop.fs_stat(dir)
|
||||
if not ok then
|
||||
pcall(vim.loop.fs_mkdir, dir, 448)
|
||||
end -- 0700
|
||||
pcall(vim.loop.fs_mkdir, dir, 448) -- 0700
|
||||
end
|
||||
return dir
|
||||
end
|
||||
|
||||
@@ -141,7 +127,7 @@ local function load_cache(root)
|
||||
return nil
|
||||
end
|
||||
if now_sec() - (data.timestamp or 0) > M.config.cache_ttl_sec then
|
||||
pcall(os.remove, file) -- proactively clear stale
|
||||
pcall(os.remove, file)
|
||||
return nil
|
||||
end
|
||||
return data.files
|
||||
@@ -173,7 +159,6 @@ local function project_root()
|
||||
return vim.fn.getcwd(0, 0)
|
||||
end
|
||||
|
||||
-- Robust relative-to-root
|
||||
local function normalize_rel(root, p)
|
||||
if not p or p == '' then
|
||||
return ''
|
||||
@@ -189,7 +174,6 @@ local function normalize_rel(root, p)
|
||||
return abs:sub(#root_norm + 2)
|
||||
end
|
||||
end
|
||||
-- strip leading ./ as last resort
|
||||
return (p:gsub('^%./', ''))
|
||||
end
|
||||
|
||||
@@ -201,7 +185,6 @@ local function to_abs_path(root, rel)
|
||||
end
|
||||
|
||||
local function to_display_path(abs)
|
||||
-- relative to current working dir if possible, else absolute
|
||||
return vim.fn.fnamemodify(abs, ':.')
|
||||
end
|
||||
|
||||
@@ -225,11 +208,11 @@ local function effective_debounce_ms()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Render helpers
|
||||
-- Render
|
||||
---------------------------------------------------------------------
|
||||
local function ensure_visible()
|
||||
local page = page_rows()
|
||||
local sel = clamp(S.select, 1, #S.filtered)
|
||||
local sel = clamp(S.select, 1, math.max(1, #S.filtered))
|
||||
local top = S.scroll + 1
|
||||
local bot = S.scroll + page
|
||||
if sel < top then
|
||||
@@ -240,9 +223,6 @@ local function ensure_visible()
|
||||
S.scroll = clamp(S.scroll, 0, math.max(#S.filtered - page, 0))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Render
|
||||
---------------------------------------------------------------------
|
||||
local function render()
|
||||
if not (S.buf_res and vim.api.nvim_buf_is_valid(S.buf_res)) then
|
||||
return
|
||||
@@ -253,31 +233,107 @@ local function render()
|
||||
local total = #S.filtered
|
||||
local view = {}
|
||||
if total == 0 then
|
||||
view = { '-- no matches --' }
|
||||
view = { ' (no matches)' }
|
||||
else
|
||||
local start_idx = S.scroll + 1
|
||||
local end_idx = math.min(start_idx + page_rows() - 1, total)
|
||||
for i = start_idx, end_idx do
|
||||
local line = S.filtered[i]
|
||||
view[#view + 1] = tostring(line or '')
|
||||
view[#view + 1] = tostring(S.filtered[i] or '')
|
||||
end
|
||||
end
|
||||
|
||||
-- For grep mode, reformat lines with fixed-width path column
|
||||
local offset_map = {} -- maps display line -> character offset for highlighting
|
||||
if S.mode == 'grep' and total > 0 then
|
||||
local path_width = M.config.grep_path_width or 40
|
||||
|
||||
for i = 1, #view do
|
||||
local line = view[i]
|
||||
if line then
|
||||
-- Parse original vimgrep format: file:line:col:content
|
||||
local file, lnum, col = line:match('^(.-):(%d+):(%d+):')
|
||||
if file and lnum and col then
|
||||
-- Pad line number to 3 chars with underscores
|
||||
local padded_lnum = lnum
|
||||
while #padded_lnum < 3 do
|
||||
padded_lnum = ' ' .. padded_lnum
|
||||
end
|
||||
|
||||
local lineinfo = ':' .. padded_lnum .. '|'
|
||||
local content_start = #file + 1 + #lnum + 1 + #col + 2 -- file + :lnum: + col:
|
||||
local content_part = line:sub(content_start)
|
||||
|
||||
-- Calculate how much space we need for file + lineinfo
|
||||
local prefix_len = #file + #lineinfo
|
||||
local formatted_line
|
||||
|
||||
if prefix_len > path_width then
|
||||
-- Need to truncate the filepath part only
|
||||
local available_for_file = path_width - #lineinfo
|
||||
if available_for_file > 1 then
|
||||
local truncated_file = '…' .. file:sub(-(available_for_file - 1))
|
||||
formatted_line = truncated_file .. lineinfo .. content_part
|
||||
-- Offset is: original_file_length - truncated_file_length
|
||||
offset_map[i] = #file - #truncated_file
|
||||
else
|
||||
-- Extreme case: line info itself is too long, just show what we can
|
||||
formatted_line = ('…' .. file):sub(1, path_width) .. lineinfo .. content_part
|
||||
offset_map[i] = #file - (path_width - #lineinfo)
|
||||
end
|
||||
elseif prefix_len < path_width then
|
||||
-- Right-align by padding before the filepath
|
||||
local padding = string.rep(' ', path_width - prefix_len)
|
||||
formatted_line = padding .. file .. lineinfo .. content_part
|
||||
offset_map[i] = -(path_width - prefix_len) -- negative for padding added
|
||||
else
|
||||
formatted_line = file .. lineinfo .. content_part
|
||||
offset_map[i] = 0
|
||||
end
|
||||
|
||||
view[i] = formatted_line
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.bo[S.buf_res].modifiable = true
|
||||
vim.bo[S.buf_res].readonly = false
|
||||
vim.api.nvim_buf_set_lines(S.buf_res, 0, -1, false, view)
|
||||
vim.api.nvim_buf_clear_namespace(S.buf_res, S.ns, 0, -1)
|
||||
|
||||
-- match highlights (visible window only)
|
||||
-- highlight groups
|
||||
vim.api.nvim_set_hl(0, 'FinderMatch', { link = 'Search', default = true })
|
||||
vim.api.nvim_set_hl(0, 'FinderPath', { fg = '#888888', default = true })
|
||||
|
||||
for i = 1, #view do
|
||||
local idx = S.scroll + i
|
||||
local line = view[i]
|
||||
|
||||
-- In grep mode, highlight the entire "file:line|" prefix in gray
|
||||
if S.mode == 'grep' and line then
|
||||
-- Find the end of the full prefix including the pipe
|
||||
local _, prefix_end = line:find(':[ 0-9]+|')
|
||||
if prefix_end then
|
||||
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, i - 1, 0, {
|
||||
end_col = prefix_end,
|
||||
hl_group = 'FinderPath',
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- match highlights (query matches in orange)
|
||||
local spans = S.positions[idx]
|
||||
if spans then
|
||||
for _, se in ipairs(spans) do
|
||||
local scol, ecol = se[1], se[2]
|
||||
if ecol > scol then
|
||||
vim.api.nvim_buf_set_extmark(S.buf_res, S.ns, i - 1, scol, {
|
||||
|
||||
-- Adjust positions for grep mode formatting
|
||||
if S.mode == 'grep' and offset_map[i] then
|
||||
scol = scol - offset_map[i]
|
||||
ecol = ecol - offset_map[i]
|
||||
end
|
||||
|
||||
if ecol > scol and scol >= 0 then
|
||||
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, i - 1, scol, {
|
||||
end_col = ecol,
|
||||
hl_group = 'FinderMatch',
|
||||
})
|
||||
@@ -287,10 +343,10 @@ local function render()
|
||||
end
|
||||
|
||||
-- selection highlight
|
||||
if total > 0 and #view > 0 then
|
||||
if total > 0 then
|
||||
vim.api.nvim_set_hl(0, 'FinderSelection', { link = 'CursorLine', default = true })
|
||||
local rel = clamp(S.select - S.scroll, 1, #view)
|
||||
vim.api.nvim_buf_set_extmark(S.buf_res, S.ns, rel - 1, 0, {
|
||||
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, rel - 1, 0, {
|
||||
end_line = rel,
|
||||
hl_group = 'FinderSelection',
|
||||
hl_eol = true,
|
||||
@@ -298,11 +354,11 @@ local function render()
|
||||
end
|
||||
|
||||
vim.bo[S.buf_res].modifiable = false
|
||||
L('render', { select = S.select, scroll = S.scroll, total = total, lines = #view })
|
||||
L('render', { select = S.select, scroll = S.scroll, total = total })
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Querying / Filtering
|
||||
-- Filtering
|
||||
---------------------------------------------------------------------
|
||||
local function compute_positions_files(items, q)
|
||||
local ok, res = pcall(vim.fn.matchfuzzypos, items, q)
|
||||
@@ -320,14 +376,13 @@ local function compute_positions_files(items, q)
|
||||
local spans = {}
|
||||
local start_col, last_col = nil, nil
|
||||
for _, c in ipairs(cols) do
|
||||
local c0 = c
|
||||
if not start_col then
|
||||
start_col, last_col = c0, c0
|
||||
elseif c0 == last_col + 1 then
|
||||
last_col = c0
|
||||
start_col, last_col = c, c
|
||||
elseif c == last_col + 1 then
|
||||
last_col = c
|
||||
else
|
||||
table.insert(spans, { start_col, last_col + 1 }) -- end exclusive
|
||||
start_col, last_col = c0, c0
|
||||
table.insert(spans, { start_col, last_col + 1 })
|
||||
start_col, last_col = c, c
|
||||
end
|
||||
end
|
||||
if start_col then
|
||||
@@ -342,14 +397,16 @@ local function compute_positions_grep(lines, q)
|
||||
if q == '' then
|
||||
return lines, {}
|
||||
end
|
||||
local qlow = q:lower()
|
||||
-- Match rg's --smart-case: case-insensitive unless query has uppercase
|
||||
local case_insensitive = not q:match('[A-Z]')
|
||||
local qmatch = case_insensitive and q:lower() or q
|
||||
local positions = {}
|
||||
for i, line in ipairs(lines) do
|
||||
local llow = tostring(line or ''):lower()
|
||||
local lmatch = case_insensitive and tostring(line or ''):lower() or tostring(line or '')
|
||||
local spans = {}
|
||||
local sidx = 1
|
||||
while true do
|
||||
local s, e = llow:find(qlow, sidx, true)
|
||||
local s, e = lmatch:find(qmatch, sidx, true)
|
||||
if not s then
|
||||
break
|
||||
end
|
||||
@@ -365,7 +422,7 @@ local function compute_positions_grep(lines, q)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- set_items
|
||||
-- set_items / set_query
|
||||
---------------------------------------------------------------------
|
||||
local function set_items(list)
|
||||
list = list or {}
|
||||
@@ -377,11 +434,12 @@ local function set_items(list)
|
||||
list = tmp
|
||||
end
|
||||
|
||||
-- sanitize to strings
|
||||
for i, v in ipairs(list) do
|
||||
list[i] = tostring(v or '')
|
||||
end
|
||||
|
||||
table.sort(list)
|
||||
|
||||
S.items = list
|
||||
S.filtered = list
|
||||
S.positions = {}
|
||||
@@ -390,9 +448,6 @@ local function set_items(list)
|
||||
render()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- set_query
|
||||
---------------------------------------------------------------------
|
||||
local function set_query(q)
|
||||
local prev_val = S.filtered[S.select]
|
||||
S.query = q
|
||||
@@ -410,7 +465,6 @@ local function set_query(q)
|
||||
end
|
||||
end
|
||||
|
||||
-- selection policy:
|
||||
if not S.user_moved then
|
||||
S.select = 1
|
||||
else
|
||||
@@ -428,11 +482,11 @@ local function set_query(q)
|
||||
|
||||
ensure_visible()
|
||||
render()
|
||||
L('set_query', { query = q, filtered = #S.filtered, user_moved = S.user_moved })
|
||||
L('set_query', { query = q, filtered = #S.filtered })
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Move / Accept
|
||||
-- Navigation
|
||||
---------------------------------------------------------------------
|
||||
local function move_down()
|
||||
if #S.filtered == 0 then
|
||||
@@ -454,52 +508,70 @@ local function move_up()
|
||||
render()
|
||||
end
|
||||
|
||||
-- Correct parser for rg --vimgrep (file:line:col:match)
|
||||
local function page_down()
|
||||
if #S.filtered == 0 then
|
||||
return
|
||||
end
|
||||
S.user_moved = true
|
||||
S.select = clamp(S.select + page_rows(), 1, #S.filtered)
|
||||
ensure_visible()
|
||||
render()
|
||||
end
|
||||
|
||||
local function page_up()
|
||||
if #S.filtered == 0 then
|
||||
return
|
||||
end
|
||||
S.user_moved = true
|
||||
S.select = clamp(S.select - page_rows(), 1, #S.filtered)
|
||||
ensure_visible()
|
||||
render()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Accept selection
|
||||
---------------------------------------------------------------------
|
||||
local function parse_vimgrep(line)
|
||||
if type(line) ~= 'string' then
|
||||
return nil
|
||||
end
|
||||
local file, lnum = line:match('^(.-):(%d+):%d+:')
|
||||
local file, lnum, col = line:match('^(.-):(%d+):(%d+):')
|
||||
if not file then
|
||||
return nil
|
||||
end
|
||||
return file, tonumber(lnum) or 1
|
||||
return file, tonumber(lnum) or 1, tonumber(col) or 1
|
||||
end
|
||||
|
||||
local function accept_selection_files()
|
||||
local function accept_selection()
|
||||
local pick = S.filtered[S.select]
|
||||
if type(pick) ~= 'string' or pick == '' then
|
||||
if type(pick) ~= 'string' or pick == '' or pick:match('^%s*%(') then
|
||||
return -- ignore "(no matches)" placeholder
|
||||
end
|
||||
|
||||
if S.mode == 'grep' then
|
||||
local file, lnum, col = parse_vimgrep(pick)
|
||||
if not file then
|
||||
return
|
||||
end
|
||||
local abs = to_abs_path(S.root, file)
|
||||
local path = to_display_path(abs)
|
||||
M.close()
|
||||
vim.schedule(function()
|
||||
vim.cmd.edit(vim.fn.fnameescape(path))
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, { lnum, col - 1 })
|
||||
end)
|
||||
else
|
||||
local abs = to_abs_path(S.root, pick)
|
||||
local path = to_display_path(abs)
|
||||
M.close()
|
||||
vim.schedule(function()
|
||||
vim.cmd.edit(vim.fn.fnameescape(path))
|
||||
end)
|
||||
end
|
||||
|
||||
local function accept_selection_grep()
|
||||
local pick = S.filtered[S.select]
|
||||
if type(pick) ~= 'string' or pick == '' then
|
||||
return
|
||||
end
|
||||
local file, lnum = parse_vimgrep(pick)
|
||||
if not file then
|
||||
return
|
||||
end
|
||||
local abs = to_abs_path(S.root, file)
|
||||
local path = to_display_path(abs)
|
||||
local ln = tonumber(lnum) or 1
|
||||
M.close()
|
||||
vim.schedule(function()
|
||||
vim.cmd.edit(vim.fn.fnameescape(path))
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, { ln, 0 })
|
||||
end)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Backends
|
||||
-- Async backends
|
||||
---------------------------------------------------------------------
|
||||
local function cancel_job(job)
|
||||
if not job then
|
||||
@@ -507,7 +579,7 @@ local function cancel_job(job)
|
||||
end
|
||||
pcall(function()
|
||||
job:kill(15)
|
||||
end) -- SIGTERM if available
|
||||
end)
|
||||
end
|
||||
|
||||
local function collect_files_async(cb)
|
||||
@@ -531,24 +603,19 @@ local function collect_files_async(cb)
|
||||
end
|
||||
end
|
||||
|
||||
local excludes = {}
|
||||
for _, p in ipairs(M.config.exclude_patterns or {}) do
|
||||
table.insert(excludes, p)
|
||||
end
|
||||
local gi = read_gitignore(root)
|
||||
for _, p in ipairs(gi) do
|
||||
table.insert(excludes, p)
|
||||
end
|
||||
|
||||
if file_cmd then
|
||||
if file_cmd and cmd_exists(file_cmd) then
|
||||
local args = { file_cmd, '--type', 'f', '--hidden', '--color', 'never' }
|
||||
if file_cmd == 'fd' or file_cmd == 'fdfind' then
|
||||
table.insert(args, '--strip-cwd-prefix')
|
||||
if M.config.follow_symlinks then
|
||||
table.insert(args, '-L')
|
||||
end
|
||||
for _, ex in ipairs(excludes) do
|
||||
end
|
||||
for _, ex in ipairs(M.config.exclude_patterns or {}) do
|
||||
table.insert(args, '--exclude')
|
||||
table.insert(args, ex)
|
||||
end
|
||||
|
||||
cancel_job(S.job_files)
|
||||
S.job_files = vim.system(args, { text = true, cwd = root }, function(obj)
|
||||
if not (S.active and gen == S.gen) then
|
||||
@@ -556,9 +623,11 @@ local function collect_files_async(cb)
|
||||
end
|
||||
local list = {}
|
||||
if obj.stdout then
|
||||
local raw = vim.split(obj.stdout, '\n', { trimempty = true })
|
||||
for _, p in ipairs(raw) do
|
||||
list[#list + 1] = normalize_rel(root, p)
|
||||
for p in obj.stdout:gmatch('[^\n]+') do
|
||||
local rel = normalize_rel(root, p)
|
||||
if rel ~= '' then
|
||||
list[#list + 1] = rel
|
||||
end
|
||||
end
|
||||
end
|
||||
if #list > M.config.max_items then
|
||||
@@ -578,20 +647,23 @@ local function collect_files_async(cb)
|
||||
return
|
||||
end
|
||||
|
||||
-- Try git ls-files as async fallback
|
||||
-- Fallback: git ls-files
|
||||
if cmd_exists('git') then
|
||||
cancel_job(S.job_files)
|
||||
S.job_files = vim.system(
|
||||
{ 'git', 'ls-files', '-co', '--exclude-standard', '-z' },
|
||||
{ 'git', 'ls-files', '-co', '--exclude-standard' },
|
||||
{ text = true, cwd = root },
|
||||
function(o2)
|
||||
function(obj)
|
||||
if not (S.active and gen == S.gen) then
|
||||
return
|
||||
end
|
||||
local list = {}
|
||||
if o2.stdout then
|
||||
for p in o2.stdout:gmatch('([^%z]+)') do
|
||||
list[#list + 1] = normalize_rel(root, p)
|
||||
if obj.stdout then
|
||||
for p in obj.stdout:gmatch('[^\n]+') do
|
||||
local rel = normalize_rel(root, p)
|
||||
if rel ~= '' then
|
||||
list[#list + 1] = rel
|
||||
end
|
||||
end
|
||||
end
|
||||
if #list > M.config.max_items then
|
||||
@@ -612,7 +684,7 @@ local function collect_files_async(cb)
|
||||
return
|
||||
end
|
||||
|
||||
-- Last resort omitted: blocking glob removed to keep async-only behavior
|
||||
L('no file lister available')
|
||||
cb({})
|
||||
end
|
||||
|
||||
@@ -624,6 +696,7 @@ local function grep_async(query, cb)
|
||||
local gen = S.gen
|
||||
local rg = M.config.grep_cmd
|
||||
if not cmd_exists(rg) then
|
||||
L('grep_cmd not found', rg)
|
||||
cb({})
|
||||
return
|
||||
end
|
||||
@@ -640,28 +713,27 @@ local function grep_async(query, cb)
|
||||
'never',
|
||||
'--path-separator',
|
||||
'/',
|
||||
'--',
|
||||
query,
|
||||
}
|
||||
-- Apply excludes as negative globs
|
||||
|
||||
-- Add excludes before the pattern
|
||||
for _, p in ipairs(M.config.exclude_patterns or {}) do
|
||||
table.insert(args, 2, '--glob')
|
||||
table.insert(args, 3, '!' .. p)
|
||||
end
|
||||
for _, p in ipairs(read_gitignore(root)) do
|
||||
table.insert(args, 2, '--glob')
|
||||
table.insert(args, 3, '!' .. p)
|
||||
table.insert(args, '--glob')
|
||||
table.insert(args, '!' .. p)
|
||||
end
|
||||
|
||||
table.insert(args, '--')
|
||||
table.insert(args, query)
|
||||
|
||||
cancel_job(S.job_rg)
|
||||
S.job_rg = vim.system(args, { text = true, cwd = root }, function(obj)
|
||||
if not (S.active and gen == S.gen) then
|
||||
return
|
||||
end
|
||||
local list = {}
|
||||
-- Accept output even if exit code != 0 (no matches or partial errors)
|
||||
if obj.stdout and #obj.stdout > 0 then
|
||||
list = vim.split(obj.stdout, '\n', { trimempty = true })
|
||||
for line in obj.stdout:gmatch('[^\n]+') do
|
||||
list[#list + 1] = line
|
||||
end
|
||||
end
|
||||
if #list > M.config.max_items then
|
||||
local tmp = {}
|
||||
@@ -692,19 +764,14 @@ local function open_layout(prompt)
|
||||
vim.bo[b].swapfile = false
|
||||
end
|
||||
end
|
||||
if S.buf_inp and vim.api.nvim_buf_is_valid(S.buf_inp) then
|
||||
vim.bo[S.buf_inp].buftype = 'prompt'
|
||||
end
|
||||
if S.buf_res and vim.api.nvim_buf_is_valid(S.buf_res) then
|
||||
vim.bo[S.buf_res].buftype = 'nofile'
|
||||
vim.bo[S.buf_res].modifiable = false
|
||||
vim.bo[S.buf_res].readonly = false
|
||||
end
|
||||
|
||||
local width = math.floor(vim.o.columns * 0.8)
|
||||
local height = math.min(math.floor(vim.o.lines * 0.5), M.config.page_size + 2)
|
||||
local col = math.floor((vim.o.columns - width) / 2)
|
||||
local row = math.floor((vim.o.lines - height) * 0.7)
|
||||
local row = math.floor((vim.o.lines - height) * 0.4)
|
||||
|
||||
S.win_inp = vim.api.nvim_open_win(S.buf_inp, true, {
|
||||
relative = 'editor',
|
||||
@@ -717,32 +784,25 @@ local function open_layout(prompt)
|
||||
focusable = true,
|
||||
zindex = 200,
|
||||
})
|
||||
if S.buf_inp and vim.api.nvim_buf_is_valid(S.buf_inp) then
|
||||
vim.fn.prompt_setprompt(S.buf_inp, prompt or '')
|
||||
end
|
||||
|
||||
S.win_res = vim.api.nvim_open_win(S.buf_res, false, {
|
||||
relative = 'editor',
|
||||
style = 'minimal',
|
||||
border = 'single',
|
||||
border = 'rounded',
|
||||
width = width,
|
||||
height = math.max(1, height - 2),
|
||||
col = col,
|
||||
row = row + 2,
|
||||
row = row + 3,
|
||||
focusable = false,
|
||||
zindex = 199,
|
||||
})
|
||||
if S.win_res and vim.api.nvim_win_is_valid(S.win_res) then
|
||||
vim.wo[S.win_res].cursorline = false
|
||||
vim.wo[S.win_res].cursorlineopt = 'line'
|
||||
end
|
||||
|
||||
if S.aug then
|
||||
pcall(vim.api.nvim_del_augroup_by_id, S.aug)
|
||||
end
|
||||
S.aug = vim.api.nvim_create_augroup('finder_session', { clear = true })
|
||||
|
||||
-- Close if focus enters a non-floating window that isn't ours
|
||||
vim.api.nvim_create_autocmd('WinEnter', {
|
||||
group = S.aug,
|
||||
callback = function()
|
||||
@@ -760,8 +820,6 @@ local function open_layout(prompt)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Close if prompt buffer hides or leaves
|
||||
if S.buf_inp and vim.api.nvim_buf_is_valid(S.buf_inp) then
|
||||
vim.api.nvim_create_autocmd({ 'BufHidden', 'BufLeave' }, {
|
||||
group = S.aug,
|
||||
buffer = S.buf_inp,
|
||||
@@ -771,9 +829,7 @@ local function open_layout(prompt)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Re-render on resize to respect new viewport height
|
||||
vim.api.nvim_create_autocmd('VimResized', {
|
||||
group = S.aug,
|
||||
callback = function()
|
||||
@@ -784,7 +840,7 @@ local function open_layout(prompt)
|
||||
})
|
||||
|
||||
vim.cmd.startinsert()
|
||||
L('open_layout', { win_inp = S.win_inp, win_res = S.win_res })
|
||||
L('open_layout')
|
||||
end
|
||||
|
||||
local function close_layout()
|
||||
@@ -802,7 +858,6 @@ local function close_layout()
|
||||
pcall(vim.api.nvim_del_augroup_by_id, S.aug)
|
||||
S.aug = nil
|
||||
end
|
||||
L('close_layout')
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -810,25 +865,17 @@ end
|
||||
---------------------------------------------------------------------
|
||||
local function attach_handlers()
|
||||
local opts = { buffer = S.buf_inp, nowait = true, silent = true, noremap = true }
|
||||
|
||||
vim.keymap.set('i', '<C-n>', move_down, opts)
|
||||
vim.keymap.set('i', '<C-p>', move_up, opts)
|
||||
vim.keymap.set('i', '<Down>', move_down, opts)
|
||||
vim.keymap.set('i', '<Up>', move_up, opts)
|
||||
vim.keymap.set('i', '<CR>', function()
|
||||
if S.mode == 'grep' then
|
||||
accept_selection_grep()
|
||||
else
|
||||
accept_selection_files()
|
||||
end
|
||||
end, opts)
|
||||
vim.keymap.set('i', '<Esc>', function()
|
||||
M.close()
|
||||
end, opts)
|
||||
vim.keymap.set('i', '<C-c>', function()
|
||||
M.close()
|
||||
end, opts)
|
||||
vim.keymap.set('i', '<C-d>', page_down, opts)
|
||||
vim.keymap.set('i', '<C-u>', page_up, opts)
|
||||
vim.keymap.set('i', '<CR>', accept_selection, opts)
|
||||
vim.keymap.set('i', '<Esc>', M.close, opts)
|
||||
vim.keymap.set('i', '<C-c>', M.close, opts)
|
||||
|
||||
if S.buf_inp and vim.api.nvim_buf_is_valid(S.buf_inp) then
|
||||
vim.api.nvim_create_autocmd({ 'TextChangedI', 'TextChangedP' }, {
|
||||
group = S.aug,
|
||||
buffer = S.buf_inp,
|
||||
@@ -838,10 +885,10 @@ local function attach_handlers()
|
||||
if not (S.active and S.buf_inp and vim.api.nvim_buf_is_valid(S.buf_inp)) then
|
||||
return
|
||||
end
|
||||
local raw = vim.fn.getline('.')
|
||||
raw = type(raw) == 'string' and raw or ''
|
||||
local prompt_pat = (S.mode == 'files') and '^Search:%s*' or '^Grep:%s*'
|
||||
local q = raw:gsub(prompt_pat, '')
|
||||
local raw = vim.fn.getline('.') or ''
|
||||
local prompt_len = S.mode == 'files' and 8 or 6 -- "Search: " or "Grep: "
|
||||
local q = raw:sub(prompt_len + 1)
|
||||
|
||||
if S.mode == 'grep' then
|
||||
grep_async(q, function(list)
|
||||
if not S.active then
|
||||
@@ -856,13 +903,12 @@ local function attach_handlers()
|
||||
end, delay)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
L('keymaps attached', opts)
|
||||
L('handlers attached')
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Public
|
||||
-- Public API
|
||||
---------------------------------------------------------------------
|
||||
function M.files()
|
||||
if S.active then
|
||||
@@ -879,7 +925,7 @@ function M.files()
|
||||
if not S.active then
|
||||
return
|
||||
end
|
||||
set_items(list) -- render initial list (relative to root)
|
||||
set_items(list)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -902,7 +948,6 @@ function M.close()
|
||||
if not S.active then
|
||||
return
|
||||
end
|
||||
-- stop timers and jobs first
|
||||
if S.timer then
|
||||
pcall(function()
|
||||
S.timer:stop()
|
||||
@@ -922,26 +967,67 @@ function M.close()
|
||||
S.query, S.select, S.scroll = '', 1, 0
|
||||
S.user_moved = false
|
||||
S.files_cached = false
|
||||
L('session closed')
|
||||
L('closed')
|
||||
end
|
||||
|
||||
function M.clear_cache()
|
||||
local root = project_root()
|
||||
local file = root .. '/.devflow/finder_cache.json'
|
||||
local ok = pcall(os.remove, file)
|
||||
vim.notify(ok and 'Finder cache cleared' or 'No cache to clear')
|
||||
end
|
||||
|
||||
function M.diagnose()
|
||||
local root = project_root()
|
||||
local lines = { '=== Finder Diagnostics ===' }
|
||||
|
||||
local fd_cmd = M.config.file_cmd
|
||||
or (cmd_exists('fd') and 'fd')
|
||||
or (cmd_exists('fdfind') and 'fdfind')
|
||||
or nil
|
||||
table.insert(lines, 'fd command: ' .. tostring(fd_cmd))
|
||||
table.insert(
|
||||
lines,
|
||||
'rg command: '
|
||||
.. tostring(M.config.grep_cmd)
|
||||
.. ' (exists: '
|
||||
.. tostring(cmd_exists(M.config.grep_cmd))
|
||||
.. ')'
|
||||
)
|
||||
|
||||
local cache_file = root .. '/.devflow/finder_cache.json'
|
||||
local cache_stat = vim.loop.fs_stat(cache_file)
|
||||
if cache_stat then
|
||||
table.insert(lines, 'Cache file: ' .. cache_file)
|
||||
table.insert(lines, 'Cache size: ' .. cache_stat.size .. ' bytes')
|
||||
local cached = load_cache(root)
|
||||
if cached then
|
||||
table.insert(lines, 'Cache valid: true (' .. #cached .. ' files)')
|
||||
else
|
||||
table.insert(lines, 'Cache valid: false (expired or corrupt)')
|
||||
end
|
||||
else
|
||||
table.insert(lines, 'Cache: none')
|
||||
end
|
||||
|
||||
table.insert(lines, 'Exclude patterns: ' .. vim.inspect(M.config.exclude_patterns))
|
||||
table.insert(lines, 'Follow symlinks: ' .. tostring(M.config.follow_symlinks))
|
||||
|
||||
vim.notify(table.concat(lines, '\n'), vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = vim.tbl_deep_extend('force', M.config, opts or {})
|
||||
if M.config.file_cmd and not cmd_exists(M.config.file_cmd) then
|
||||
pcall(
|
||||
vim.notify,
|
||||
("finder: file_cmd '%s' not found"):format(M.config.file_cmd),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
|
||||
local fd_cmd = M.config.file_cmd
|
||||
if fd_cmd and not cmd_exists(fd_cmd) then
|
||||
vim.notify('[finder] file_cmd "' .. fd_cmd .. '" not found', vim.log.levels.WARN)
|
||||
end
|
||||
if M.config.grep_cmd and not cmd_exists(M.config.grep_cmd) then
|
||||
pcall(
|
||||
vim.notify,
|
||||
("finder: grep_cmd '%s' not found, will try 'rg'"):format(M.config.grep_cmd),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
vim.notify('[finder] grep_cmd "' .. M.config.grep_cmd .. '" not found', vim.log.levels.WARN)
|
||||
end
|
||||
L('setup', M.config)
|
||||
|
||||
L('setup complete', M.config)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -73,7 +73,8 @@ vim.api.nvim_create_user_command('Sync', function()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command('FetchLspConfigs', function()
|
||||
local base_url = 'https://raw.githubusercontent.com/neovim/nvim-lspconfig/master/lsp/'
|
||||
-- local base_url = 'https://raw.githubusercontent.com/neovim/nvim-lspconfig/master/lsp/'
|
||||
local base_url = 'https://raw.githubusercontent.com/neovim/nvim-lspconfig/refs/heads/master/lsp/'
|
||||
|
||||
local lm = require('plugins.language-manager')
|
||||
lm.invalidate_cache()
|
||||
|
||||
Reference in New Issue
Block a user