aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/nv/nvim/plgs/femaco
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/by-name/nv/nvim/plgs/femaco/default.nix22
-rw-r--r--modules/by-name/nv/nvim/plgs/femaco/lua/femaco.lua23
2 files changed, 36 insertions, 9 deletions
diff --git a/modules/by-name/nv/nvim/plgs/femaco/default.nix b/modules/by-name/nv/nvim/plgs/femaco/default.nix
index adf0ba63..eac6b393 100644
--- a/modules/by-name/nv/nvim/plgs/femaco/default.nix
+++ b/modules/by-name/nv/nvim/plgs/femaco/default.nix
@@ -1,19 +1,29 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# 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>.
{
- pkgs,
lib,
config,
...
}: let
cfg = config.soispha.programs.nvim;
in {
- home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable {
- # TODO: package femaco through a module
+ # TODO: Re-active this plugin, when it does no longer depend on `treesitter-legacy` <2026-01-18>
+ home-manager.users.soispha.programs.nixvim = lib.mkIf false {
+ plugins.femaco = {
+ enable = true;
+ };
+
extraConfigLuaPost = ''
${lib.strings.fileContents ./lua/femaco.lua}
'';
- extraPlugins = [
- pkgs.vimPlugins.nvim-FeMaco-lua
- ];
+
keymaps = [
{
key = "<leader>cc";
diff --git a/modules/by-name/nv/nvim/plgs/femaco/lua/femaco.lua b/modules/by-name/nv/nvim/plgs/femaco/lua/femaco.lua
index c113e4c7..4dc9ce97 100644
--- a/modules/by-name/nv/nvim/plgs/femaco/lua/femaco.lua
+++ b/modules/by-name/nv/nvim/plgs/femaco/lua/femaco.lua
@@ -1,4 +1,15 @@
+-- nixos-config - My current NixOS configuration
+--
+-- Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+-- SPDX-License-Identifier: GPL-3.0-or-later
+--
+-- This file is part of my nixos-config.
+--
+-- 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 clip_val = require("femaco.utils").clip_val
+
require("femaco").setup({
-- should prepare a new buffer and return the winid
-- by default opens a floating window
@@ -8,6 +19,7 @@ require("femaco").setup({
local buf = vim.api.nvim_create_buf(false, false)
return vim.api.nvim_open_win(buf, true, opts)
end,
+
-- should return options passed to nvim_open_win
-- @param code_block: data about the code-block with the keys
-- * range
@@ -16,7 +28,7 @@ require("femaco").setup({
float_opts = function(code_block)
return {
relative = "cursor",
- width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10), -- TODO: how to offset sign column etc?
+ width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10), -- TODO how to offset sign column etc?
height = clip_val(5, #code_block.lines, vim.api.nvim_win_get_height(0) - 6),
anchor = "NW",
row = 0,
@@ -26,19 +38,24 @@ require("femaco").setup({
zindex = 1,
}
end,
+
-- return filetype to use for a given lang
-- lang can be nil
ft_from_lang = function(lang) return lang end,
+
-- what to do after opening the float
post_open_float = function(winnr) vim.wo.signcolumn = "no" end,
+
-- create the path to a temporary file
create_tmp_filepath = function(filetype) return os.tmpname() end,
+
-- if a newline should always be used, useful for multiline injections
-- which separators needs to be on separate lines such as markdown, neorg etc
-- @param base_filetype: The filetype which FeMaco is called from, not the
-- filetype of the injected language (this is the current buffer so you can
-- get it from vim.bo.filetyp).
- ensure_newline = function(base_filetype) return false end,
+ ensure_newline = function(base_filetype) return base_filetype == "nix" end,
+
-- Return true if the indentation should be normalized. Useful when the
-- injected language inherits indentation from the construction scope (e.g. an
-- inline multiline sql string). If true, the leading indentation is detected,
@@ -47,5 +64,5 @@ require("femaco").setup({
-- @param base_filetype: The filetype which FeMaco is called from, not the
-- filetype of the injected language (this is the current buffer, so you can
-- get it from vim.bo.filetype).
- normalize_indent = function(base_filetype) return false end,
+ normalize_indent = function(base_filetype) return base_filetype == "nix" end,
})