WIP: Switch to NixOS #5

Draft
FunctionalHacker wants to merge 1349 commits from nix into main
2 changed files with 118 additions and 46 deletions
Showing only changes of commit 5d47465266 - Show all commits

View file

@ -9,8 +9,8 @@ return {
config = function() config = function()
local gitsigns = require("gitsigns") local gitsigns = require("gitsigns")
require("which-key").register({ require("which-key").register({
["["] = { c = { gitsigns.prev_hunk, "Previous hunk" } }, ["["] = { h = { gitsigns.prev_hunk, "Previous hunk" } },
["]"] = { c = { gitsigns.next_hunk, "Next hunk" } }, ["]"] = { h = { gitsigns.next_hunk, "Next hunk" } },
}) })
local builtin = require("statuscol.builtin") local builtin = require("statuscol.builtin")

View file

@ -1,13 +1,19 @@
return { return {
{
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = function() build = ":TSUpdate",
init = function(plugin)
require("nvim-treesitter.install").update({ with_sync = true }) require("nvim-treesitter.install").update({ with_sync = true })
end, end,
---@type TSConfig ---@type TSConfig
---@diagnostic disable-next-line: missing-fields
opts = { opts = {
highlight = { enable = true },
indent = { enable = true },
ensure_installed = { ensure_installed = {
"bash", "bash",
"css", "css",
"diff",
"dockerfile", "dockerfile",
"git_config", "git_config",
"git_rebase", "git_rebase",
@ -18,15 +24,20 @@ return {
"http", "http",
"java", "java",
"javascript", "javascript",
"jsdoc",
"json", "json",
"json5", "json5",
"jsonc",
"latex", "latex",
"lua", "lua",
"luadoc",
"luap",
"make", "make",
"markdown", "markdown",
"markdown_inline", "markdown_inline",
"php", "php",
"python", "python",
"query",
"rasi", "rasi",
"regex", "regex",
"rst", "rst",
@ -35,14 +46,75 @@ return {
"tsx", "tsx",
"typescript", "typescript",
"vim", "vim",
"vimdoc",
"yaml", "yaml",
}, },
highlight = { enable = true }, incremental_selection = {
indent = { enable = true }, enable = true,
incremental_selection = { enable = true }, keymaps = {
context_commentstring = { enable = true }, init_selection = "<C-space>",
sync_install = true, node_incremental = "<C-space>",
ignore_install = {}, scope_incremental = false,
auto_install = true, node_decremental = "<bs>",
},
},
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
},
},
---@param opts TSConfig
config = function(_, opts)
if type(opts.ensure_installed) == "table" then
---@type table<string, boolean>
local added = {}
opts.ensure_installed = vim.tbl_filter(function(lang)
if added[lang] then
return false
end
added[lang] = true
return true
end, opts.ensure_installed)
end
require("nvim-treesitter.configs").setup(opts)
end,
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
config = function()
-- When in diff mode, we want to use the default
-- vim text objects c & C instead of the treesitter ones.
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end
return fn(q, ...)
end
end
end
end,
},
},
},
-- Automatically add closing tags for HTML and JSX
{
"windwp/nvim-ts-autotag",
opts = {},
}, },
} }