diff options
Diffstat (limited to 'modules/by-name/nv')
-rw-r--r-- | modules/by-name/nv/nvim/plgs/flatten-nvim/default.nix | 3 | ||||
-rw-r--r-- | modules/by-name/nv/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua | 72 |
2 files changed, 40 insertions, 35 deletions
diff --git a/modules/by-name/nv/nvim/plgs/flatten-nvim/default.nix b/modules/by-name/nv/nvim/plgs/flatten-nvim/default.nix index 8d61d859..3257d661 100644 --- a/modules/by-name/nv/nvim/plgs/flatten-nvim/default.nix +++ b/modules/by-name/nv/nvim/plgs/flatten-nvim/default.nix @@ -16,7 +16,7 @@ cfg = config.soispha.programs.nvim; in { # TODO: Get this plugin working again <2025-01-29> - home-manager.users.soispha.programs.nixvim = lib.mkIf false { + home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable { # TODO: package flatten-nvim though a module extraConfigLuaPre = '' @@ -26,6 +26,7 @@ in { return end ''; + extraPlugins = [ pkgs.vimPlugins.flatten-nvim ]; diff --git a/modules/by-name/nv/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua b/modules/by-name/nv/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua index 0c86cd27..7e170098 100644 --- a/modules/by-name/nv/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua +++ b/modules/by-name/nv/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua @@ -8,6 +8,8 @@ -- You should have received a copy of the License along with this program. -- If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. +local flatten = require("flatten") + ---Types: -- -- Passed to callbacks that handle opening files @@ -27,20 +29,20 @@ ---@alias OpenHandler fun(files: BufInfo[], argv: string[], stdin_buf: BufInfo, guest_cwd: string):window, buffer -- require("flatten").setup({ - callbacks = { + hooks = { ---Called to determine if a nested session should wait for the host to close the file. ---param argv: a list of all the arguments in the nested session ---@type fun(argv: table): boolean - should_block = require("flatten").default_should_block, + should_block = flatten.hooks.should_block; ---If this returns true, the nested session will be opened. ---If false, default behavior is used, and ---config.nest_if_no_args is respected. ---@type fun(host: channel):boolean - should_nest = require("flatten").default_should_nest, + should_nest = flatten.hooks.should_nest; ---Called before a nested session is opened. - pre_open = function() end, + pre_open = flatten.hooks.pre_open; ---Called after a nested session is opened. ---@param bufnr buffer @@ -48,29 +50,36 @@ require("flatten").setup({ ---@param filetype string ---@param is_blocking boolean ---@param is_diff boolean - post_open = function(bufnr, winnr, filetype, is_blocking, is_diff) - -- If the file is a git commit, create one-shot autocmd to delete its buffer on write - if filetype == "gitcommit" or filetype == "gitrebase" then - vim.api.nvim_create_autocmd("BufWritePost", { - buffer = bufnr, - once = true, - callback = vim.schedule_wrap(function() vim.api.nvim_buf_delete(bufnr, {}) end), - }) - end - end, + post_open = flatten.hooks.post_open; ---Called when a nested session is done waiting for the host. ---@param filetype string - block_end = function(filetype) end, - }, + block_end = flatten.hooks.block_end; + + no_files = flatten.hooks.no_files; + guest_data = flatten.hooks.guest_data; + + -- Override this function to use a different socket to connect to the host + -- On the host side this can return nil or the socket address. + -- On the guest side this should return the socket address + -- or a non-zero channel id from `sockconnect` + -- flatten.nvim will detect if the address refers to this instance of nvim, to determine if this is a host or a guest + pipe_path = flatten.hooks.pipe_path; + }; + -- <String, Bool> dictionary of filetypes that should be blocking block_for = { - gitcommit = true, - }, + gitcommit = true; + gitrebase = true; + }; + -- Command passthrough - allow_cmd_passthrough = true, + disable_cmd_passthrough = false; + -- Allow a nested session to open if Neovim is opened without arguments - nest_if_no_args = false, + nest_if_no_args = false; + nest_if_cmds = false; + -- Window options window = { -- Options: @@ -83,7 +92,7 @@ require("flatten").setup({ -- OpenHandler -> allows you to handle file opening yourself (see Types) -- -- TODO: Open gitcommit filetypes in the current buffer, everything else in a new tab <2023-08-29> - open = "split", + open = "split"; -- Options: -- vsplit -> opens files in diff vsplits @@ -91,24 +100,19 @@ require("flatten").setup({ -- tab_vsplit -> creates a new tabpage, and opens diff vsplits -- tab_split -> creates a new tabpage, and opens diff splits -- OpenHandler -> allows you to handle file opening yourself (see Types) - diff = "tab_vsplit", + diff = "tab_vsplit"; -- Affects which file gets focused when opening multiple at once -- Options: -- "first" -> open first file of new files (default) -- "last" -> open last file of new files - focus = "first", - }, - -- Override this function to use a different socket to connect to the host - -- On the host side this can return nil or the socket address. - -- On the guest side this should return the socket address - -- or a non-zero channel id from `sockconnect` - -- flatten.nvim will detect if the address refers to this instance of nvim, to determine if this is a host or a guest - pipe_path = require("flatten").default_pipe_path, + focus = "first"; + }; + -- The `default_pipe_path` will treat the first nvim instance within a single kitty/wezterm session as the host -- You can configure this behaviour using the following: - one_per = { - kitty = true, -- Flatten all instance in the current Kitty session - wezterm = true, -- Flatten all instance in the current Wezterm session - }, + integrations = { + kitty = false; -- Flatten all instance in the current Kitty session + wezterm = false; -- Flatten all instance in the current Wezterm session + }; }) |