Skip to content

Commit

Permalink
feat(ts-context-commentstring)!: setup as a plugin (ayamir#1067)
Browse files Browse the repository at this point in the history
* feat(ts-context-commentstring)!: setup as a plugin

Ref: JoosepAlviste/nvim-ts-context-commentstring@5b02387

* fixup! feat(ts-context-commentstring)!: setup as a plugin
  • Loading branch information
Jint-lzxy authored and Vincent Wang committed Nov 27, 2023
1 parent 4a93237 commit 6d606dd
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 69 deletions.
111 changes: 55 additions & 56 deletions lua/modules/configs/editor/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
return vim.schedule_wrap(function()
local use_ssh = require("core.settings").use_ssh
local use_ssh = require("core.settings").use_ssh

vim.api.nvim_set_option_value("foldmethod", "expr", {})
vim.api.nvim_set_option_value("foldexpr", "nvim_treesitter#foldexpr()", {})

require("modules.utils").load_plugin("nvim-treesitter", {
ensure_installed = require("core.settings").treesitter_deps,
highlight = {
enable = true,
disable = function(ft, bufnr)
if vim.tbl_contains({ "vim" }, ft) then
return true
end
require("modules.utils").load_plugin("nvim-treesitter", {
ensure_installed = require("core.settings").treesitter_deps,
highlight = {
enable = true,
disable = function(ft, bufnr)
if vim.tbl_contains({ "vim" }, ft) then
return true
end

local ok, is_large_file = pcall(vim.api.nvim_buf_get_var, bufnr, "bigfile_disable_treesitter")
return ok and is_large_file
end,
additional_vim_regex_highlighting = false,
},
textobjects = {
select = {
enable = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]["] = "@function.outer",
["]m"] = "@class.outer",
},
goto_next_end = {
["]]"] = "@function.outer",
["]M"] = "@class.outer",
},
goto_previous_start = {
["[["] = "@function.outer",
["[m"] = "@class.outer",
},
goto_previous_end = {
["[]"] = "@function.outer",
["[M"] = "@class.outer",
},
},
},
context_commentstring = { enable = true, enable_autocmd = false },
indent = { enable = true },
matchup = { enable = true },
}, false, require("nvim-treesitter.configs").setup)
require("nvim-treesitter.install").prefer_git = true
if use_ssh then
local parsers = require("nvim-treesitter.parsers").get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:")
end
end
local ok, is_large_file = pcall(vim.api.nvim_buf_get_var, bufnr, "bigfile_disable_treesitter")
return ok and is_large_file
end,
additional_vim_regex_highlighting = false,
},
textobjects = {
select = {
enable = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]["] = "@function.outer",
["]m"] = "@class.outer",
},
goto_next_end = {
["]]"] = "@function.outer",
["]M"] = "@class.outer",
},
goto_previous_start = {
["[["] = "@function.outer",
["[m"] = "@class.outer",
},
goto_previous_end = {
["[]"] = "@function.outer",
["[M"] = "@class.outer",
},
},
},
indent = { enable = true },
matchup = { enable = true },
}, false, require("nvim-treesitter.configs").setup)
require("nvim-treesitter.install").prefer_git = true
if use_ssh then
local parsers = require("nvim-treesitter.parsers").get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:")
end
end
end)
7 changes: 7 additions & 0 deletions lua/modules/configs/editor/ts-context-commentstring.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return function()
vim.g.skip_ts_context_commentstring_module = true
require("modules.utils").load_plugin("ts_context_commentstring", {
-- Whether to update the `commentstring` on the `CursorHold` autocmd
enable_autocmd = false,
})
end
29 changes: 16 additions & 13 deletions lua/modules/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,18 @@ editor["nvim-treesitter/nvim-treesitter"] = {
lazy = true,
build = function()
if #vim.api.nvim_list_uis() ~= 0 then
vim.api.nvim_command("TSUpdate")
vim.api.nvim_command([[TSUpdate]])
end
end,
event = "BufReadPost",
event = "BufReadPre",
config = require("editor.treesitter"),
dependencies = {
{ "nvim-treesitter/nvim-treesitter-textobjects" },
{ "JoosepAlviste/nvim-ts-context-commentstring" },
{ "mfussenegger/nvim-treehopper" },
{ "andymass/vim-matchup" },
{ "mfussenegger/nvim-treehopper" },
{ "nvim-treesitter/nvim-treesitter-textobjects" },
{
"hiphish/rainbow-delimiters.nvim",
config = require("editor.rainbow_delims"),
},
{
"nvim-treesitter/nvim-treesitter-context",
config = require("editor.ts-context"),
"abecodes/tabout.nvim",
config = require("editor.tabout"),
},
{
"windwp/nvim-ts-autotag",
Expand All @@ -130,8 +125,16 @@ editor["nvim-treesitter/nvim-treesitter"] = {
config = require("editor.colorizer"),
},
{
"abecodes/tabout.nvim",
config = require("editor.tabout"),
"hiphish/rainbow-delimiters.nvim",
config = require("editor.rainbow_delims"),
},
{
"nvim-treesitter/nvim-treesitter-context",
config = require("editor.ts-context"),
},
{
"JoosepAlviste/nvim-ts-context-commentstring",
config = require("editor.ts-context-commentstring"),
},
},
}
Expand Down

0 comments on commit 6d606dd

Please sign in to comment.