Compare commits
4 Commits
70486dda84
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c8524df9d | |||
| b84e46bda1 | |||
| 65680cb255 | |||
| f54bbc5676 |
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
|
||||||
|
```
|
||||||
143
docs/docs.md
143
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
|
```lua
|
||||||
--[[
|
--[[
|
||||||
Neovim Lua config: ways to set things
|
Neovim Lua config: ways to set things
|
||||||
@@ -31,121 +21,125 @@ TODO:
|
|||||||
## check macos fileS: https://github.com/dsully/dotfiles/blob/main/.data/macos-defaults/globals.yaml
|
## check macos fileS: https://github.com/dsully/dotfiles/blob/main/.data/macos-defaults/globals.yaml
|
||||||
|
|
||||||
# Used pacakges:
|
# 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)
|
|
||||||
|
|
||||||
- fd-find (fd) Alternative to `find`. (optional)
|
- rockspaces Metadata files describing how to build and install a Lua package.
|
||||||
- ripgrep (rg) Line-oriented search tool. (recommended)
|
- luarocks Package manager for Lua modules. (optional)
|
||||||
|
- tree-sitter Parser generator. Not needed except for using CLI. (optional)
|
||||||
|
|
||||||
- git Revision control system. (requirement)
|
- fd-find (fd) Alternative to `find`. (optional)
|
||||||
- lazygit Terminal UI for git commands. (optional)
|
- ripgrep (rg) Line-oriented search tool. (recommended)
|
||||||
|
|
||||||
- fzf Command-line fuzzy finder.
|
- git Revision control system. (requirement)
|
||||||
- bat "cat" but with colors
|
- lazygit Terminal UI for git commands. (optional)
|
||||||
- curl Command-line for transferring data specified with URL syntax.
|
|
||||||
- wget Utility for downloading files from the Web.
|
|
||||||
- make
|
|
||||||
- cc Collection of compilers.
|
|
||||||
- build-essential Meta-package that installs standard C/C++ libraries and headers.
|
|
||||||
These are needed to compile tree-sitter parsers. Run only on the first time.
|
|
||||||
cc (gcc, clang) C compiler. Usually it points to `clang` (on macos) or `gcc` (on linux).
|
|
||||||
g++ C++ compiler.
|
|
||||||
make Build automation tool from source code.
|
|
||||||
|
|
||||||
- unzip Extraction utility for archives compressed in .zip.
|
- fzf Command-line fuzzy finder.
|
||||||
- ca-certificates Provides a set of trusted Certificate Authority (CA) certificates.
|
- bat "cat" but with colors
|
||||||
- openssh-client Tools for connecting to remote servers securely over SSH.
|
- curl Command-line for transferring data specified with URL syntax.
|
||||||
- libssl-dev Development libraries and headers for OpenSSL.
|
- wget Utility for downloading files from the Web.
|
||||||
|
- make
|
||||||
|
- cc Collection of compilers.
|
||||||
|
- build-essential Meta-package that installs standard C/C++ libraries and headers.
|
||||||
|
These are needed to compile tree-sitter parsers. Run only on the first time.
|
||||||
|
cc (gcc, clang) C compiler. Usually it points to `clang` (on macos) or `gcc` (on linux).
|
||||||
|
g++ C++ compiler.
|
||||||
|
make Build automation tool from source code.
|
||||||
|
|
||||||
|
- unzip Extraction utility for archives compressed in .zip.
|
||||||
|
- ca-certificates Provides a set of trusted Certificate Authority (CA) certificates.
|
||||||
|
- openssh-client Tools for connecting to remote servers securely over SSH.
|
||||||
|
- libssl-dev Development libraries and headers for OpenSSL.
|
||||||
- sudo
|
- sudo
|
||||||
- tree
|
- tree
|
||||||
- jq
|
- jq
|
||||||
- man-db
|
- man-db
|
||||||
- python3
|
- python3
|
||||||
- volta Node manager
|
- volta Node manager
|
||||||
- ncurses ncurses-dev ncurses-libs ncurses-terminfo \
|
- ncurses ncurses-dev ncurses-libs ncurses-terminfo \
|
||||||
- check: https://github.com/glepnir/nvim/blob/main/Dockerfile
|
- check: https://github.com/glepnir/nvim/blob/main/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
# Currently installed
|
# Currently installed
|
||||||
|
|
||||||
- plenary.nvim
|
- plenary.nvim
|
||||||
- lazy.nvim
|
- lazy.nvim
|
||||||
|
|
||||||
- nvim-treesitter
|
- nvim-treesitter
|
||||||
- neovim/nvim-lspconfig
|
- neovim/nvim-lspconfig
|
||||||
- williamboman/mason.nvim
|
- williamboman/mason.nvim
|
||||||
- williamboman/mason-lspconfig.nvim
|
- williamboman/mason-lspconfig.nvim
|
||||||
- j-hui/fidget.nvim
|
- j-hui/fidget.nvim
|
||||||
- hrsh7th/cmp-nvim-lsp
|
- hrsh7th/cmp-nvim-lsp
|
||||||
- b0o/schemastore.nvim
|
- b0o/schemastore.nvim
|
||||||
|
|
||||||
- windwp/nvim-ts-autotag # auto close,rename tags
|
- windwp/nvim-ts-autotag # auto close,rename tags
|
||||||
- nvim-autopairs # auto pair chars
|
- nvim-autopairs # auto pair chars
|
||||||
- stevearc/conform.nvim # formatter
|
- stevearc/conform.nvim # formatter
|
||||||
- nvim-cmp # completion
|
- nvim-cmp # completion
|
||||||
- cmp-path
|
- cmp-path
|
||||||
- cmp-nvim-lsp
|
- cmp-nvim-lsp
|
||||||
|
|
||||||
- nvim-tree.lua # file explorer
|
- nvim-tree.lua # file explorer
|
||||||
- telescope.nvim
|
- telescope.nvim
|
||||||
- telescope-fzf-native.nvim
|
- telescope-fzf-native.nvim
|
||||||
- telescope-ui-select.nvim
|
- telescope-ui-select.nvim
|
||||||
- plenary.nvim
|
- plenary.nvim
|
||||||
- harpoon # tags
|
- harpoon # tags
|
||||||
|
|
||||||
|
|
||||||
# Notes:
|
# Notes:
|
||||||
|
|
||||||
- in lsp change tsserver to vtsls
|
- in lsp change tsserver to vtsls
|
||||||
|
|
||||||
# New package definition
|
# New package definition
|
||||||
|
|
||||||
- Plugin and Package managers
|
- Plugin and Package managers
|
||||||
- folke/lazy.nvim
|
- folke/lazy.nvim
|
||||||
- mason-org/mason.nvim
|
- mason-org/mason.nvim
|
||||||
- TS
|
- TS
|
||||||
- nvim-treesitter
|
- nvim-treesitter
|
||||||
- nvim-treesitter-textobjects
|
- nvim-treesitter-textobjects
|
||||||
- LSP
|
- LSP
|
||||||
- neovim/nvim-lspconfig
|
- neovim/nvim-lspconfig
|
||||||
|
- nvim-ts-autotag tag elements (`</>`)
|
||||||
- nvim-ts-autotag tag elements (`</>`)
|
- windwp/nvim-autopairs auto pairs
|
||||||
- windwp/nvim-autopairs auto pairs
|
- blink.cmp autocompletion
|
||||||
- blink.cmp autocompletion
|
- stevearc/conform.nvim autoformat
|
||||||
- stevearc/conform.nvim autoformat
|
- mini.ai `a/i` motions
|
||||||
- mini.ai `a/i` motions
|
|
||||||
- mini.pairs
|
- mini.pairs
|
||||||
- mini.surround
|
- mini.surround
|
||||||
- mfussenegger/nvim-lint
|
- mfussenegger/nvim-lint
|
||||||
- nvim-lspconfig
|
- nvim-lspconfig
|
||||||
- fzf-lua (replace telescope)
|
- fzf-lua (replace telescope)
|
||||||
- ? indent guides
|
- ? indent guides
|
||||||
- lukas-reineke/indent-blankline.nvim
|
- lukas-reineke/indent-blankline.nvim
|
||||||
- snacks.indent
|
- snacks.indent
|
||||||
- mini.indentscope
|
- mini.indentscope
|
||||||
|
|
||||||
## Deps:
|
## Deps:
|
||||||
|
|
||||||
- SchemaStore.nvim
|
- SchemaStore.nvim
|
||||||
- mason-lspconfig.nvim
|
- mason-lspconfig.nvim
|
||||||
- mason.nvim
|
- mason.nvim
|
||||||
|
|
||||||
## Maybe:
|
## Maybe:
|
||||||
- folke/ts-comments.nvim better comments
|
|
||||||
- grug-far.nvim find and replace
|
- folke/ts-comments.nvim better comments
|
||||||
- markdown-preview.nvim side by side md (disabled in folke)
|
- grug-far.nvim find and replace
|
||||||
- toppair/peek.nvim another markdown preview?
|
- markdown-preview.nvim side by side md (disabled in folke)
|
||||||
- render-markdown.nvim inline viewer
|
- toppair/peek.nvim another markdown preview?
|
||||||
|
- render-markdown.nvim inline viewer
|
||||||
- markview.nvim
|
- markview.nvim
|
||||||
- diffview.nvim
|
- diffview.nvim
|
||||||
- octo.nvim edit and review GH issues and pr
|
- octo.nvim edit and review GH issues and pr
|
||||||
- yanky.nvim better yank+put. has history
|
- yanky.nvim better yank+put. has history
|
||||||
- inc-rename.nvim LSP renaming with visual feedback
|
- inc-rename.nvim LSP renaming with visual feedback
|
||||||
- mini.basics defaults options
|
- mini.basics defaults options
|
||||||
- mini.test run tests under cursor
|
- mini.test run tests under cursor
|
||||||
- mini.diff inline diff
|
- mini.diff inline diff
|
||||||
- mini.hipatters hilight patters and hex colors
|
- mini.hipatters hilight patters and hex colors
|
||||||
- mini.move move chunks (like vscode)
|
- mini.move move chunks (like vscode)
|
||||||
- undo tree (find a plugin)
|
- undo tree (find a plugin)
|
||||||
|
|
||||||
## AI help
|
## AI help
|
||||||
|
|
||||||
- jackMort/ChatGPT.nvim
|
- jackMort/ChatGPT.nvim
|
||||||
- MunifTanjim/nui.nvim (dep)
|
- MunifTanjim/nui.nvim (dep)
|
||||||
- nvim-lua/plenary.nvim (dep)
|
- nvim-lua/plenary.nvim (dep)
|
||||||
@@ -155,6 +149,7 @@ TODO:
|
|||||||
- milanglacier/minuet-ai.nvim (folke)
|
- milanglacier/minuet-ai.nvim (folke)
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
opt.backup = true
|
opt.backup = true
|
||||||
@@ -178,6 +173,7 @@ vim.keymap.set("n", "<C-c>", "ciw")
|
|||||||
```
|
```
|
||||||
|
|
||||||
folke cmd
|
folke cmd
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- show cursor line only in active window
|
-- show cursor line only in active window
|
||||||
vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, {
|
vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, {
|
||||||
@@ -210,6 +206,7 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Enable folding with TS:
|
Enable folding with TS:
|
||||||
|
|
||||||
```
|
```
|
||||||
vim.opt.foldmethod = "expr"
|
vim.opt.foldmethod = "expr"
|
||||||
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
|
|||||||
19
init.lua
19
init.lua
@@ -5,6 +5,25 @@ end
|
|||||||
|
|
||||||
vim.env.PATH = vim.fn.stdpath('data') .. '/mason/bin:' .. vim.env.PATH
|
vim.env.PATH = vim.fn.stdpath('data') .. '/mason/bin:' .. vim.env.PATH
|
||||||
|
|
||||||
|
vim.filetype.add({
|
||||||
|
pattern = {
|
||||||
|
['.*/templates/.*%.ya?ml'] = 'helm',
|
||||||
|
['.*/manifests/.*%.ya?ml'] = 'helm',
|
||||||
|
['.*/crds/.*%.ya?ml'] = 'helm',
|
||||||
|
['.*/kubernetes/.*%.ya?ml'] = 'helm',
|
||||||
|
['.*/k8s/.*%.ya?ml'] = 'helm',
|
||||||
|
['.*/charts/.*%.ya?ml'] = 'helm',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function _G.see(val)
|
||||||
|
local lines = vim.split(vim.inspect(val), '\n')
|
||||||
|
vim.cmd('new')
|
||||||
|
vim.api.nvim_buf_set_lines(0, 0, -1, false, lines)
|
||||||
|
vim.bo.buftype = 'nofile'
|
||||||
|
vim.bo.bufhidden = 'wipe'
|
||||||
|
end
|
||||||
|
|
||||||
require('core.options')
|
require('core.options')
|
||||||
require('core.keymaps')
|
require('core.keymaps')
|
||||||
require('core.events')
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
83
lsp/yamlls.lua
Normal file
83
lsp/yamlls.lua
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
---@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 = { '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 },
|
||||||
|
validate = false, -- Disable all schema validation
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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,
|
||||||
|
}
|
||||||
@@ -1,23 +1,48 @@
|
|||||||
local M = {}
|
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()
|
function M.get()
|
||||||
return {
|
return {
|
||||||
{ ts = { 'yaml', 'toml', 'sql', 'diff', 'dockerfile', 'gitcommit', 'gitignore' } },
|
-- {
|
||||||
{ ts = { 'c', 'cpp', 'go', 'rust', 'python' } },
|
-- ft = 'helm',
|
||||||
|
-- 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' } },
|
||||||
|
|
||||||
{ ft = 'markdown', ts = { 'markdown', 'markdown_inline' }, format = 'prettier' },
|
{ ft = 'markdown', ts = { 'markdown', 'markdown_inline' }, format = 'prettier' },
|
||||||
{ ft = 'bash', lsp = 'bash-language-server', lint = 'shellcheck', format = 'shfmt' },
|
{ ft = 'bash', lsp = 'bash-language-server', lint = 'shellcheck', format = 'shfmt' },
|
||||||
{ ft = 'lua', lsp = 'lua-language-server', lint = 'luacheck', format = 'stylua' },
|
{ ft = 'lua', lsp = 'lua-language-server', lint = 'luacheck', format = 'stylua' },
|
||||||
{ ft = { 'json', 'jsonc' }, lsp = 'json-lsp' },
|
{ ft = { 'json', 'jsonc' }, lsp = 'json-lsp' },
|
||||||
{ ft = 'html', lsp = 'html-lsp' },
|
{ ft = 'html', lsp = 'html-lsp' },
|
||||||
{ ft = 'css', lsp = { 'css-lsp', 'tailwindcss-language-server' } },
|
{ ft = 'css', lsp = { 'css-lsp', 'tailwindcss-language-server' } },
|
||||||
{
|
{
|
||||||
ft = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' },
|
ft = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' },
|
||||||
ts = { 'javascript', 'typescript', 'tsx' },
|
ts = { 'javascript', 'typescript', 'tsx' },
|
||||||
lsp = { 'vtsls', 'eslint-lsp' },
|
lsp = { 'vtsls', 'eslint-lsp' },
|
||||||
format = { 'prettierd', 'prettier' },
|
format = { 'prettierd', 'prettier' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ M.config = {
|
|||||||
max_items = 5000, -- safety cap for massive outputs
|
max_items = 5000, -- safety cap for massive outputs
|
||||||
debug = false,
|
debug = false,
|
||||||
follow_symlinks = true, -- pass -L to fd
|
follow_symlinks = true, -- pass -L to fd
|
||||||
|
grep_path_width = 30,
|
||||||
|
|
||||||
-- Exclusion patterns (used by fd/rg in addition to their gitignore handling)
|
-- Exclusion patterns (used by fd/rg in addition to their gitignore handling)
|
||||||
exclude_patterns = { 'node_modules', 'dist', 'build', '.git' },
|
exclude_patterns = { 'node_modules', 'dist', 'build', '.git' },
|
||||||
@@ -151,13 +152,17 @@ local function save_cache(root, files)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function project_root()
|
local function project_root()
|
||||||
local obj = vim.system({ 'git', 'rev-parse', '--show-toplevel' }, { text = true }):wait()
|
|
||||||
if obj.code == 0 and obj.stdout and obj.stdout ~= '' then
|
|
||||||
return vim.trim(obj.stdout)
|
|
||||||
end
|
|
||||||
return vim.fn.getcwd(0, 0)
|
return vim.fn.getcwd(0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- local function project_root()
|
||||||
|
-- local obj = vim.system({ 'git', 'rev-parse', '--show-toplevel' }, { text = true }):wait()
|
||||||
|
-- if obj.code == 0 and obj.stdout and obj.stdout ~= '' then
|
||||||
|
-- return vim.trim(obj.stdout)
|
||||||
|
-- end
|
||||||
|
-- return vim.fn.getcwd(0, 0)
|
||||||
|
-- end
|
||||||
|
|
||||||
local function normalize_rel(root, p)
|
local function normalize_rel(root, p)
|
||||||
if not p or p == '' then
|
if not p or p == '' then
|
||||||
return ''
|
return ''
|
||||||
@@ -241,6 +246,56 @@ local function render()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- For grep mode, reformat lines with fixed-width path column
|
||||||
|
local offset_map = {} -- maps display line -> character offset for highlighting
|
||||||
|
-- In render(), replace the grep reformatting section:
|
||||||
|
-- In render(), replace the grep reformatting section:
|
||||||
|
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
|
||||||
|
local file, lnum, col, content_start_pos = line:match('^(.-):(%d+):(%d+):()')
|
||||||
|
if file and lnum and col and content_start_pos then
|
||||||
|
local padded_lnum = lnum
|
||||||
|
while #padded_lnum < 3 do
|
||||||
|
padded_lnum = ' ' .. padded_lnum
|
||||||
|
end
|
||||||
|
|
||||||
|
local lineinfo = ':' .. padded_lnum .. '|'
|
||||||
|
local content_part = line:sub(content_start_pos)
|
||||||
|
|
||||||
|
local prefix_len = #file + #lineinfo
|
||||||
|
local formatted_line
|
||||||
|
local new_content_start -- 1-based position where content starts in formatted line
|
||||||
|
|
||||||
|
if prefix_len > path_width then
|
||||||
|
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
|
||||||
|
new_content_start = #truncated_file + #lineinfo + 1
|
||||||
|
else
|
||||||
|
formatted_line = ('…' .. file):sub(1, path_width) .. lineinfo .. content_part
|
||||||
|
new_content_start = path_width + #lineinfo + 1
|
||||||
|
end
|
||||||
|
elseif prefix_len < path_width then
|
||||||
|
local padding = string.rep(' ', path_width - prefix_len)
|
||||||
|
formatted_line = padding .. file .. lineinfo .. content_part
|
||||||
|
new_content_start = #padding + #file + #lineinfo + 1
|
||||||
|
else
|
||||||
|
formatted_line = file .. lineinfo .. content_part
|
||||||
|
new_content_start = #file + #lineinfo + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
view[i] = formatted_line
|
||||||
|
offset_map[i] = content_start_pos - new_content_start
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
vim.bo[S.buf_res].modifiable = true
|
vim.bo[S.buf_res].modifiable = true
|
||||||
vim.api.nvim_buf_set_lines(S.buf_res, 0, -1, false, view)
|
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)
|
vim.api.nvim_buf_clear_namespace(S.buf_res, S.ns, 0, -1)
|
||||||
@@ -253,17 +308,15 @@ local function render()
|
|||||||
local idx = S.scroll + i
|
local idx = S.scroll + i
|
||||||
local line = view[i]
|
local line = view[i]
|
||||||
|
|
||||||
-- In grep mode, highlight the "file:line:col:" prefix in gray
|
-- In grep mode, highlight the entire "file:line|" prefix in gray
|
||||||
if S.mode == 'grep' and line then
|
if S.mode == 'grep' and line then
|
||||||
local prefix_end = line:find('^.-:%d+:%d+:')
|
-- Find the end of the full prefix including the pipe
|
||||||
|
local _, prefix_end = line:find(':[ 0-9]+|')
|
||||||
if prefix_end then
|
if prefix_end then
|
||||||
local _, epos = line:find('^.-:%d+:%d+:')
|
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, i - 1, 0, {
|
||||||
if epos then
|
end_col = prefix_end,
|
||||||
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, i - 1, 0, {
|
hl_group = 'FinderPath',
|
||||||
end_col = epos,
|
})
|
||||||
hl_group = 'FinderPath',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -272,7 +325,14 @@ local function render()
|
|||||||
if spans then
|
if spans then
|
||||||
for _, se in ipairs(spans) do
|
for _, se in ipairs(spans) do
|
||||||
local scol, ecol = se[1], se[2]
|
local scol, ecol = se[1], se[2]
|
||||||
if ecol > scol then
|
|
||||||
|
-- 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, {
|
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, i - 1, scol, {
|
||||||
end_col = ecol,
|
end_col = ecol,
|
||||||
hl_group = 'FinderMatch',
|
hl_group = 'FinderMatch',
|
||||||
@@ -337,26 +397,32 @@ local function compute_positions_grep(lines, q)
|
|||||||
if q == '' then
|
if q == '' then
|
||||||
return lines, {}
|
return lines, {}
|
||||||
end
|
end
|
||||||
-- Match rg's --smart-case: case-insensitive unless query has uppercase
|
|
||||||
local case_insensitive = not q:match('[A-Z]')
|
local case_insensitive = not q:match('[A-Z]')
|
||||||
local qmatch = case_insensitive and q:lower() or q
|
local qmatch = case_insensitive and q:lower() or q
|
||||||
local positions = {}
|
local positions = {}
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
local lmatch = case_insensitive and tostring(line or ''):lower() or tostring(line or '')
|
local file, lnum, col, content_start_pos = line:match('^(.-):(%d+):(%d+):()')
|
||||||
local spans = {}
|
if not content_start_pos then
|
||||||
local sidx = 1
|
positions[i] = nil
|
||||||
while true do
|
else
|
||||||
local s, e = lmatch:find(qmatch, sidx, true)
|
local content = line:sub(content_start_pos)
|
||||||
if not s then
|
local lmatch = case_insensitive and content:lower() or content
|
||||||
break
|
local spans = {}
|
||||||
end
|
local sidx = 1
|
||||||
table.insert(spans, { s - 1, e })
|
while true do
|
||||||
sidx = e + 1
|
local s, e = lmatch:find(qmatch, sidx, true)
|
||||||
if #spans > 64 then
|
if not s then
|
||||||
break
|
break
|
||||||
|
end
|
||||||
|
-- Use content_start_pos from the pattern match, not manual calculation
|
||||||
|
table.insert(spans, { content_start_pos - 1 + s - 1, content_start_pos - 1 + e })
|
||||||
|
sidx = e + 1
|
||||||
|
if #spans > 64 then
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
positions[i] = (#spans > 0) and spans or nil
|
||||||
end
|
end
|
||||||
positions[i] = (#spans > 0) and spans or nil
|
|
||||||
end
|
end
|
||||||
return lines, positions
|
return lines, positions
|
||||||
end
|
end
|
||||||
@@ -655,7 +721,6 @@ local function grep_async(query, cb)
|
|||||||
'/',
|
'/',
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Add excludes before the pattern
|
|
||||||
for _, p in ipairs(M.config.exclude_patterns or {}) do
|
for _, p in ipairs(M.config.exclude_patterns or {}) do
|
||||||
table.insert(args, '--glob')
|
table.insert(args, '--glob')
|
||||||
table.insert(args, '!' .. p)
|
table.insert(args, '!' .. p)
|
||||||
@@ -670,9 +735,17 @@ local function grep_async(query, cb)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local list = {}
|
local list = {}
|
||||||
|
local seen = {} -- track file:line to deduplicate
|
||||||
if obj.stdout and #obj.stdout > 0 then
|
if obj.stdout and #obj.stdout > 0 then
|
||||||
for line in obj.stdout:gmatch('[^\n]+') do
|
for line in obj.stdout:gmatch('[^\n]+') do
|
||||||
list[#list + 1] = line
|
local file, lnum = line:match('^(.-):(%d+):%d+:')
|
||||||
|
if file and lnum then
|
||||||
|
local key = file .. ':' .. lnum
|
||||||
|
if not seen[key] then
|
||||||
|
seen[key] = true
|
||||||
|
list[#list + 1] = line
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #list > M.config.max_items then
|
if #list > M.config.max_items then
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ vim.api.nvim_create_user_command('Sync', function()
|
|||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('FetchLspConfigs', function()
|
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')
|
local lm = require('plugins.language-manager')
|
||||||
lm.invalidate_cache()
|
lm.invalidate_cache()
|
||||||
|
|||||||
Reference in New Issue
Block a user