Refactor plugin layout, add AI autocomplete and direnv, update docs
This commit is contained in:
parent
3517caecde
commit
cc9a5dc0f5
20 changed files with 1195 additions and 414 deletions
|
|
@ -1,6 +1,8 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
dependencies = { "windwp/nvim-ts-autotag", "JoosepAlviste/nvim-ts-context-commentstring" },
|
||||
dependencies = { "windwp/nvim-ts-autotag" },
|
||||
lazy = false, -- nvim-treesitter does not support lazy-loading per docs
|
||||
build = ":TSUpdate",
|
||||
init = function()
|
||||
U.cmd_executable("tree-sitter", {
|
||||
[false] = function()
|
||||
|
|
@ -8,48 +10,70 @@ return {
|
|||
end,
|
||||
})
|
||||
end,
|
||||
event = "BufRead",
|
||||
cmd = {
|
||||
"TSBufDisable",
|
||||
"TSBufEnable",
|
||||
"TSBufToggle",
|
||||
"TSDisable",
|
||||
"TSEnable",
|
||||
"TSToggle",
|
||||
"TSInstall",
|
||||
"TSInstallInfo",
|
||||
"TSInstallSync",
|
||||
"TSModuleInfo",
|
||||
"TSUninstall",
|
||||
"TSUpdate",
|
||||
"TSUpdateSync",
|
||||
},
|
||||
opts = function()
|
||||
local nonNixOpts = {}
|
||||
config = function()
|
||||
-- New nvim-treesitter API (post-rewrite)
|
||||
-- Setup is optional and only needed for non-default install directory
|
||||
local ts = require("nvim-treesitter")
|
||||
|
||||
-- In nix mode, parsers are provided by the nix store, no installation needed
|
||||
if not NIX then
|
||||
nonNixOpts = {
|
||||
ensure_installed = "all",
|
||||
auto_install = true,
|
||||
}
|
||||
-- Install common parsers (async)
|
||||
ts.install({
|
||||
"bash",
|
||||
"c",
|
||||
"css",
|
||||
"dockerfile",
|
||||
"go",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"nix",
|
||||
"python",
|
||||
"rust",
|
||||
"svelte",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"yaml",
|
||||
})
|
||||
end
|
||||
return U.assign({
|
||||
highlight = {
|
||||
enable = true,
|
||||
use_languagetree = true,
|
||||
disable = function(lang, bufnr)
|
||||
if lang == "sql" then
|
||||
return true
|
||||
end
|
||||
return vim.api.nvim_buf_line_count(bufnr) > 4000
|
||||
end,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
incremental_selection = { enable = true },
|
||||
indent = { enable = true },
|
||||
autotag = { enable = true },
|
||||
}, nonNixOpts)
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
|
||||
-- Enable treesitter highlighting for all filetypes
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = vim.api.nvim_create_augroup("myconfig-treesitter-highlight", { clear = true }),
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local ft = args.match
|
||||
|
||||
-- Skip large files
|
||||
if vim.api.nvim_buf_line_count(bufnr) > 4000 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Skip sql (often has issues)
|
||||
if ft == "sql" then
|
||||
return
|
||||
end
|
||||
|
||||
-- Enable treesitter highlighting
|
||||
pcall(vim.treesitter.start, bufnr)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Enable treesitter-based folding
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = vim.api.nvim_create_augroup("myconfig-treesitter-fold", { clear = true }),
|
||||
callback = function(args)
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.wo[win][0].foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
vim.wo[win][0].foldmethod = "expr"
|
||||
vim.wo[win][0].foldenable = false -- Start with folds open
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue