mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-25 06:49:49 +01:00
treewide: make the entire generated config lua based
This commit is contained in:
parent
b42a98696c
commit
eba3fa831e
17 changed files with 168 additions and 288 deletions
|
@ -146,9 +146,4 @@ in {
|
||||||
-- SECTION: ${section.name}
|
-- SECTION: ${section.name}
|
||||||
${section.data}
|
${section.data}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mkVimrcSection = section: ''
|
|
||||||
" SECTION: ${section.name}
|
|
||||||
${section.data}
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,5 @@
|
||||||
languages = import ./languages.nix {inherit lib;};
|
languages = import ./languages.nix {inherit lib;};
|
||||||
lists = import ./lists.nix {inherit lib;};
|
lists = import ./lists.nix {inherit lib;};
|
||||||
lua = import ./lua.nix {inherit lib;};
|
lua = import ./lua.nix {inherit lib;};
|
||||||
vim = import ./vim.nix;
|
|
||||||
neovimConfiguration = import ./configuration.nix {inherit inputs lib;};
|
neovimConfiguration = import ./configuration.nix {inherit inputs lib;};
|
||||||
}
|
}
|
||||||
|
|
10
lib/lua.nix
10
lib/lua.nix
|
@ -5,16 +5,6 @@
|
||||||
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
|
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
|
||||||
inherit (lib.trivial) boolToString warn;
|
inherit (lib.trivial) boolToString warn;
|
||||||
in rec {
|
in rec {
|
||||||
wrapLuaConfig = {
|
|
||||||
luaBefore ? "",
|
|
||||||
luaConfig,
|
|
||||||
luaAfter ? "",
|
|
||||||
}: ''
|
|
||||||
lua << EOF
|
|
||||||
${concatLines [luaBefore luaConfig luaAfter]}
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Convert a null value to lua's nil
|
# Convert a null value to lua's nil
|
||||||
nullString = value:
|
nullString = value:
|
||||||
if value == null
|
if value == null
|
||||||
|
|
26
lib/vim.nix
26
lib/vim.nix
|
@ -1,26 +0,0 @@
|
||||||
let
|
|
||||||
inherit (builtins) isInt isBool toJSON toString;
|
|
||||||
in rec {
|
|
||||||
# yes? no.
|
|
||||||
yesNo = value:
|
|
||||||
if value
|
|
||||||
then "yes"
|
|
||||||
else "no";
|
|
||||||
|
|
||||||
# convert a boolean to a vim compliant boolean string
|
|
||||||
mkVimBool = val:
|
|
||||||
if val
|
|
||||||
then "1"
|
|
||||||
else "0";
|
|
||||||
|
|
||||||
# convert a literal value to a vim compliant value
|
|
||||||
valToVim = val:
|
|
||||||
if (isInt val)
|
|
||||||
then (toString val)
|
|
||||||
else
|
|
||||||
(
|
|
||||||
if (isBool val)
|
|
||||||
then (mkVimBool val)
|
|
||||||
else (toJSON val)
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -98,8 +98,9 @@ inputs: {
|
||||||
neovim = vimOptions.package;
|
neovim = vimOptions.package;
|
||||||
plugins = concatLists [builtStartPlugins builtOptPlugins];
|
plugins = concatLists [builtStartPlugins builtOptPlugins];
|
||||||
appName = "nvf";
|
appName = "nvf";
|
||||||
initViml = vimOptions.builtConfigRC;
|
|
||||||
extraBinPath = vimOptions.extraPackages;
|
extraBinPath = vimOptions.extraPackages;
|
||||||
|
initLua = vimOptions.builtLuaConfigRC;
|
||||||
|
luaFiles = vimOptions.extraLuaFiles;
|
||||||
|
|
||||||
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||||
inherit extraLuaPackages extraPython3Packages;
|
inherit extraLuaPackages extraPython3Packages;
|
||||||
|
|
|
@ -5,16 +5,17 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkOption literalExpression;
|
inherit (lib.options) mkOption literalExpression;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.types) enum bool str int nullOr;
|
inherit (lib.types) enum bool str int ;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
leaderKey = mkOption {
|
leaderKey = mkOption {
|
||||||
type = nullOr str;
|
type = str;
|
||||||
default = null;
|
default = " ";
|
||||||
description = "The leader key to be used internally";
|
description = "The leader key used for `<leader>` mappings";
|
||||||
};
|
};
|
||||||
|
|
||||||
colourTerm = mkOption {
|
colourTerm = mkOption {
|
||||||
|
@ -53,12 +54,6 @@ in {
|
||||||
description = "Enable syntax highlighting";
|
description = "Enable syntax highlighting";
|
||||||
};
|
};
|
||||||
|
|
||||||
mapLeaderSpace = mkOption {
|
|
||||||
type = bool;
|
|
||||||
default = true;
|
|
||||||
description = "Map the space key to leader key";
|
|
||||||
};
|
|
||||||
|
|
||||||
useSystemClipboard = mkOption {
|
useSystemClipboard = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -165,117 +160,110 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.vim.configRC.basic = entryAfter ["globalsScript"] ''
|
config.vim.luaConfigRC.basic = entryAfter ["globalsScript"] ''
|
||||||
" Settings that are set for everything
|
-- Settings that are set for everything
|
||||||
set encoding=utf-8
|
vim.o.encoding = "utf-8"
|
||||||
set hidden
|
vim.o.hidden = true
|
||||||
set shortmess+=c
|
vim.opt.shortmess:append("c")
|
||||||
set expandtab
|
vim.o.expandtab = true
|
||||||
set mouse=${cfg.mouseSupport}
|
vim.o.mouse = ${toLuaObject cfg.mouseSupport}
|
||||||
set tabstop=${toString cfg.tabWidth}
|
vim.o.tabstop = ${toLuaObject cfg.tabWidth}
|
||||||
set shiftwidth=${toString cfg.tabWidth}
|
vim.o.shiftwidth = ${toLuaObject cfg.tabWidth}
|
||||||
set softtabstop=${toString cfg.tabWidth}
|
vim.o.softtabstop = ${toLuaObject cfg.tabWidth}
|
||||||
set cmdheight=${toString cfg.cmdHeight}
|
vim.o.cmdheight = ${toLuaObject cfg.cmdHeight}
|
||||||
set updatetime=${toString cfg.updateTime}
|
vim.o.updatetime = ${toLuaObject cfg.updateTime}
|
||||||
set tm=${toString cfg.mapTimeout}
|
vim.o.tm = ${toLuaObject cfg.mapTimeout}
|
||||||
set cursorlineopt=${toString cfg.cursorlineOpt}
|
vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt}
|
||||||
set scrolloff=${toString cfg.scrollOffset}
|
vim.o.scrolloff = ${toLuaObject cfg.scrollOffset}
|
||||||
|
vim.g.mapleader = ${toLuaObject cfg.leaderKey}
|
||||||
|
vim.g.maplocalleader = ${toLuaObject cfg.leaderKey}
|
||||||
|
|
||||||
${optionalString cfg.splitBelow ''
|
${optionalString cfg.splitBelow ''
|
||||||
set splitbelow
|
vim.o.splitbelow = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.splitRight ''
|
${optionalString cfg.splitRight ''
|
||||||
set splitright
|
vim.o.splitright = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.showSignColumn ''
|
${optionalString cfg.showSignColumn ''
|
||||||
set signcolumn=yes
|
vim.o.signcolumn = "yes"
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.autoIndent ''
|
${optionalString cfg.autoIndent ''
|
||||||
set autoindent
|
vim.o.autoindent = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.preventJunkFiles ''
|
${optionalString cfg.preventJunkFiles ''
|
||||||
set noswapfile
|
vim.o.swapfile = false
|
||||||
set nobackup
|
vim.o.backup = false
|
||||||
set nowritebackup
|
vim.o.writebackup = false
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.bell == "none") ''
|
${optionalString (cfg.bell == "none") ''
|
||||||
set noerrorbells
|
vim.o.errorbells = false
|
||||||
set novisualbell
|
vim.o.visualbell = false
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.bell == "on") ''
|
${optionalString (cfg.bell == "on") ''
|
||||||
set novisualbell
|
vim.o.visualbell = false
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.bell == "visual") ''
|
${optionalString (cfg.bell == "visual") ''
|
||||||
set noerrorbells
|
vim.o.errorbells = false
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "relative") ''
|
${optionalString (cfg.lineNumberMode == "relative") ''
|
||||||
set relativenumber
|
vim.o.relativenumber = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "number") ''
|
${optionalString (cfg.lineNumberMode == "number") ''
|
||||||
set number
|
vim.o.number = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "relNumber") ''
|
${optionalString (cfg.lineNumberMode == "relNumber") ''
|
||||||
set number relativenumber
|
vim.o.number = true
|
||||||
|
vim.o.relativenumber = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.useSystemClipboard ''
|
${optionalString cfg.useSystemClipboard ''
|
||||||
set clipboard+=unnamedplus
|
vim.opt.clipboard:append("unnamedplus")
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.mapLeaderSpace ''
|
|
||||||
let mapleader=" "
|
|
||||||
let maplocalleader=" "
|
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.syntaxHighlighting ''
|
${optionalString cfg.syntaxHighlighting ''
|
||||||
syntax on
|
vim.cmd("syntax on")
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (!cfg.wordWrap) ''
|
${optionalString (!cfg.wordWrap) ''
|
||||||
set nowrap
|
vim.o.wrap = false
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.hideSearchHighlight ''
|
${optionalString cfg.hideSearchHighlight ''
|
||||||
set nohlsearch
|
vim.o.hlsearch = false
|
||||||
set incsearch
|
vim.o.incsearch = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString cfg.colourTerm ''
|
${optionalString cfg.colourTerm ''
|
||||||
set termguicolors
|
vim.o.termguicolors = true
|
||||||
set t_Co=256
|
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (!cfg.enableEditorconfig) ''
|
${optionalString (!cfg.enableEditorconfig) ''
|
||||||
let g:editorconfig = v:false
|
vim.g.editorconfig = false
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.leaderKey != null) ''
|
|
||||||
let mapleader = "${toString cfg.leaderKey}"
|
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.searchCase == "ignore") ''
|
${optionalString (cfg.searchCase == "ignore") ''
|
||||||
set nosmartcase
|
vim.o.smartcase = false
|
||||||
set ignorecase
|
vim.o.ignorecase = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.searchCase == "smart") ''
|
${optionalString (cfg.searchCase == "smart") ''
|
||||||
set smartcase
|
vim.o.smartcase = true
|
||||||
set ignorecase
|
vim.o.ignorecase = true
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString (cfg.searchCase == "sensitive") ''
|
${optionalString (cfg.searchCase == "sensitive") ''
|
||||||
set nosmartcase
|
vim.o.smartcase = false
|
||||||
set noignorecase
|
vim.o.ignorecase = false
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
in {
|
in {
|
||||||
config = {
|
config = {
|
||||||
vim.maps = {
|
vim.maps = {
|
||||||
normal =
|
normal = mkIf cfg.disableArrows {
|
||||||
mkIf cfg.disableArrows {
|
|
||||||
"<up>" = {
|
"<up>" = {
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
|
|
||||||
|
@ -29,11 +28,6 @@ in {
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
// mkIf cfg.mapLeaderSpace {
|
|
||||||
"<space>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
insert = mkIf cfg.disableArrows {
|
insert = mkIf cfg.disableArrows {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.vim) mkVimBool;
|
|
||||||
|
|
||||||
cfg = config.vim.dashboard.startify;
|
cfg = config.vim.dashboard.startify;
|
||||||
in {
|
in {
|
||||||
|
@ -23,28 +22,28 @@ in {
|
||||||
else cfg.customFooter;
|
else cfg.customFooter;
|
||||||
"startify_bookmarks" = cfg.bookmarks;
|
"startify_bookmarks" = cfg.bookmarks;
|
||||||
"startify_lists" = cfg.lists;
|
"startify_lists" = cfg.lists;
|
||||||
"startify_change_to_dir" = mkVimBool cfg.changeToDir;
|
"startify_change_to_dir" = cfg.changeToDir;
|
||||||
"startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot;
|
"startify_change_to_vcs_root" = cfg.changeToVCRoot;
|
||||||
"startify_change_cmd" = cfg.changeDirCmd;
|
"startify_change_cmd" = cfg.changeDirCmd;
|
||||||
"startify_skiplist" = cfg.skipList;
|
"startify_skiplist" = cfg.skipList;
|
||||||
"startify_update_oldfiles" = mkVimBool cfg.updateOldFiles;
|
"startify_update_oldfiles" = cfg.updateOldFiles;
|
||||||
"startify_session_autoload" = mkVimBool cfg.sessionAutoload;
|
"startify_session_autoload" = cfg.sessionAutoload;
|
||||||
"startify_commands" = cfg.commands;
|
"startify_commands" = cfg.commands;
|
||||||
"startify_files_number" = cfg.filesNumber;
|
"startify_files_number" = cfg.filesNumber;
|
||||||
"startify_custom_indices" = cfg.customIndices;
|
"startify_custom_indices" = cfg.customIndices;
|
||||||
"startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup;
|
"startify_disable_at_vimenter" = cfg.disableOnStartup;
|
||||||
"startify_enable_unsafe" = mkVimBool cfg.unsafe;
|
"startify_enable_unsafe" = cfg.unsafe;
|
||||||
"startify_padding_left" = cfg.paddingLeft;
|
"startify_padding_left" = cfg.paddingLeft;
|
||||||
"startify_use_env" = mkVimBool cfg.useEnv;
|
"startify_use_env" = cfg.useEnv;
|
||||||
"startify_session_before_save" = cfg.sessionBeforeSave;
|
"startify_session_before_save" = cfg.sessionBeforeSave;
|
||||||
"startify_session_persistence" = mkVimBool cfg.sessionPersistence;
|
"startify_session_persistence" = cfg.sessionPersistence;
|
||||||
"startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers;
|
"startify_session_delete_buffers" = cfg.sessionDeleteBuffers;
|
||||||
"startify_session_dir" = cfg.sessionDir;
|
"startify_session_dir" = cfg.sessionDir;
|
||||||
"startify_skiplist_server" = cfg.skipListServer;
|
"startify_skiplist_server" = cfg.skipListServer;
|
||||||
"startify_session_remove_lines" = cfg.sessionRemoveLines;
|
"startify_session_remove_lines" = cfg.sessionRemoveLines;
|
||||||
"startify_session_savevars" = cfg.sessionSavevars;
|
"startify_session_savevars" = cfg.sessionSavevars;
|
||||||
"startify_session_savecmds" = cfg.sessionSavecmds;
|
"startify_session_savecmds" = cfg.sessionSavecmds;
|
||||||
"startify_session_sort" = mkVimBool cfg.sessionSort;
|
"startify_session_sort" = cfg.sessionSort;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
|
||||||
packageToCmd = package: defaultCmd:
|
packageToCmd = package: defaultCmd:
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
|
@ -141,7 +141,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.cHeader {
|
(mkIf cfg.cHeader {
|
||||||
vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1";
|
vim.luaConfigRC.c-header = entryAfter ["basic"] "vim.g.c_syntax_for_h = 1";
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
|
|
|
@ -176,8 +176,16 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
{
|
{
|
||||||
vim.configRC.nix = entryAnywhere ''
|
vim.luaConfigRC.nix = ''
|
||||||
autocmd filetype nix setlocal tabstop=2 shiftwidth=2 softtabstop=2
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "nix",
|
||||||
|
callback = function(opts)
|
||||||
|
bo = vim.bo[opts.buf]
|
||||||
|
bo.tabstop = 2
|
||||||
|
bo.shiftwidth = 2
|
||||||
|
bo.softtabstop = 2
|
||||||
|
end
|
||||||
|
})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
inherit (lib.attrsets) attrNames;
|
inherit (lib.attrsets) attrNames;
|
||||||
inherit (lib.types) bool lines enum;
|
inherit (lib.types) bool lines enum;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.dag) entryBefore;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
|
||||||
cfg = config.vim.theme;
|
cfg = config.vim.theme;
|
||||||
supported_themes = import ./supported_themes.nix {
|
supportedThemes = import ./supported-themes.nix {
|
||||||
inherit lib config;
|
inherit lib config;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -21,12 +21,12 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = enum (attrNames supported_themes);
|
type = enum (attrNames supportedThemes);
|
||||||
description = "Supported themes can be found in `supported_themes.nix`";
|
description = "Supported themes can be found in `supportedThemes.nix`";
|
||||||
};
|
};
|
||||||
|
|
||||||
style = mkOption {
|
style = mkOption {
|
||||||
type = enum supported_themes.${cfg.name}.styles;
|
type = enum supportedThemes.${cfg.name}.styles;
|
||||||
description = "Specific style for theme if it supports it";
|
description = "Specific style for theme if it supports it";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,11 +45,9 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = [cfg.name];
|
startPlugins = [cfg.name];
|
||||||
configRC.theme = entryBefore ["luaScript"] ''
|
luaConfigRC.theme = entryAfter ["basic"] ''
|
||||||
lua << EOF
|
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
${supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;})}
|
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}}
|
||||||
EOF
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,15 +37,16 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
||||||
configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] ''
|
# HACK: is there a way to convert the foldexpr line to lua?
|
||||||
" This is required by treesitter-context to handle folds
|
luaConfigRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] ''
|
||||||
set foldmethod=expr
|
-- This is required by treesitter-context to handle folds
|
||||||
set foldexpr=nvim_treesitter#foldexpr()
|
vim.o.foldmethod = "expr"
|
||||||
|
vim.cmd("set foldexpr=nvim_treesitter#foldexpr())"
|
||||||
|
|
||||||
" This is optional, but is set rather as a sane default.
|
-- This is optional, but is set rather as a sane default.
|
||||||
" If unset, opened files will be folded by automatically as
|
-- If unset, opened files will be folded by automatically as
|
||||||
" the files are opened
|
-- the files are opened
|
||||||
set nofoldenable
|
vim.o.foldenable = false
|
||||||
'');
|
'');
|
||||||
|
|
||||||
luaConfigRC.treesitter = entryAfter ["basic"] ''
|
luaConfigRC.treesitter = entryAfter ["basic"] ''
|
||||||
|
|
|
@ -4,25 +4,23 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.strings) optionalString stringLength concatMapStringsSep;
|
inherit (lib.strings) stringLength concatMapStringsSep;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.vim) mkVimBool;
|
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
|
||||||
|
|
||||||
cfg = config.vim.utility.preview.markdownPreview;
|
cfg = config.vim.utility.preview.markdownPreview;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim];
|
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim];
|
||||||
|
|
||||||
vim.configRC.markdown-preview = entryAnywhere ''
|
vim.globals = {
|
||||||
let g:mkdp_auto_start = ${mkVimBool cfg.autoStart}
|
mkdp_auto_start = cfg.autoStart;
|
||||||
let g:mkdp_auto_close = ${mkVimBool cfg.autoClose}
|
mkdp_auto_close = cfg.autoClose;
|
||||||
let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh}
|
mkdp_refresh_slow = cfg.lazyRefresh;
|
||||||
let g:mkdp_filetypes = [${concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes}]
|
mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)];
|
||||||
let g:mkdp_command_for_global = ${mkVimBool cfg.alwaysAllowPreview}
|
mkdp_command_for_global = cfg.alwaysAllowPreview;
|
||||||
let g:mkdp_open_to_the_world = ${mkVimBool cfg.broadcastServer}
|
mkdp_open_to_the_world = cfg.broadcastServer;
|
||||||
${optionalString (stringLength cfg.customIP > 0) "let g:mkdp_open_ip = '${cfg.customIP}'"}
|
mkdp_open_ip = mkIf (stringLength cfg.customIP > 0) cfg.customIP;
|
||||||
${optionalString (stringLength cfg.customPort > 0) "let g:mkdp_port = '${cfg.customPort}'"}
|
mkdp_port = mkIf (stringLength cfg.customPort > 0) cfg.customPort;
|
||||||
'';
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,14 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
|
||||||
|
|
||||||
cfg = config.vim.utility.vim-wakatime;
|
cfg = config.vim.utility.vim-wakatime;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [pkgs.vimPlugins.vim-wakatime];
|
||||||
pkgs.vimPlugins.vim-wakatime
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.configRC.vim-wakatime = entryAnywhere ''
|
vim.luaConfigRC.vim-wakatime = mkIf (cfg.cli-package != null) ''
|
||||||
${
|
vim.g.wakatime_CLIPath = "${cfg.cli-package}"
|
||||||
if cfg.cli-package == null
|
|
||||||
then ""
|
|
||||||
else ''let g:wakatime_CLIPath = "${cfg.cli-package}"''
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,8 @@
|
||||||
inherit (lib.trivial) showWarnings;
|
inherit (lib.trivial) showWarnings;
|
||||||
inherit (lib.types) str nullOr;
|
inherit (lib.types) str nullOr;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort mkLuarcSection mkVimrcSection;
|
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort mkLuarcSection;
|
||||||
inherit (lib.nvim.lua) toLuaObject wrapLuaConfig;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.vim) valToVim;
|
|
||||||
inherit (lib.nvim.config) mkBool;
|
inherit (lib.nvim.config) mkBool;
|
||||||
|
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
|
@ -82,9 +81,9 @@
|
||||||
maps);
|
maps);
|
||||||
in {
|
in {
|
||||||
config = let
|
config = let
|
||||||
filterNonNull = mappings: filterAttrs (_name: value: value != null) mappings;
|
filterNonNull = attrs: filterAttrs (_: value: value != null) attrs;
|
||||||
globalsScript =
|
globalsScript =
|
||||||
mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}")
|
mapAttrsFlatten (name: value: "vim.g.${name} = ${toLuaObject value}")
|
||||||
(filterNonNull cfg.globals);
|
(filterNonNull cfg.globals);
|
||||||
|
|
||||||
toLuaBindings = mode: maps:
|
toLuaBindings = mode: maps:
|
||||||
|
@ -123,59 +122,13 @@ in {
|
||||||
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
|
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
|
||||||
in
|
in
|
||||||
result;
|
result;
|
||||||
in {
|
|
||||||
vim = {
|
|
||||||
configRC = {
|
|
||||||
globalsScript = entryAnywhere (concatLines globalsScript);
|
|
||||||
|
|
||||||
# Call additional lua files with :luafile in Vimscript
|
extraPluginConfigs = resolveDag {
|
||||||
# section of the configuration, only after
|
|
||||||
# the luaScript section has been evaluated
|
|
||||||
extraLuaFiles = let
|
|
||||||
callLuaFiles = map (file: "luafile ${file}") cfg.extraLuaFiles;
|
|
||||||
in
|
|
||||||
entryAfter ["globalScript"] (concatLines callLuaFiles);
|
|
||||||
|
|
||||||
# wrap the lua config in a lua block
|
|
||||||
# using the wrapLuaConfic function from the lib
|
|
||||||
luaScript = let
|
|
||||||
mapResult = result: (wrapLuaConfig {
|
|
||||||
luaBefore = "${cfg.luaConfigPre}";
|
|
||||||
luaConfig = concatLines (map mkLuarcSection result);
|
|
||||||
luaAfter = "${cfg.luaConfigPost}";
|
|
||||||
});
|
|
||||||
|
|
||||||
luaConfig = resolveDag {
|
|
||||||
name = "lua config script";
|
|
||||||
dag = cfg.luaConfigRC;
|
|
||||||
inherit mapResult;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
entryAnywhere luaConfig;
|
|
||||||
|
|
||||||
extraPluginConfigs = let
|
|
||||||
mapResult = result: (wrapLuaConfig {
|
|
||||||
luaConfig = concatLines (map mkLuarcSection result);
|
|
||||||
});
|
|
||||||
|
|
||||||
extraPluginsDag = mapAttrs (_: {
|
|
||||||
after,
|
|
||||||
setup,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
entryAfter after setup)
|
|
||||||
cfg.extraPlugins;
|
|
||||||
|
|
||||||
pluginConfig = resolveDag {
|
|
||||||
name = "extra plugins config";
|
name = "extra plugins config";
|
||||||
dag = extraPluginsDag;
|
dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins;
|
||||||
inherit mapResult;
|
mapResult = result: concatLines (map mkLuarcSection result);
|
||||||
};
|
};
|
||||||
in
|
|
||||||
entryAfter ["luaScript"] pluginConfig;
|
|
||||||
|
|
||||||
# This is probably not the right way to set the config. I'm not sure how it should look like.
|
|
||||||
mappings = let
|
|
||||||
maps = [
|
maps = [
|
||||||
nmap
|
nmap
|
||||||
imap
|
imap
|
||||||
|
@ -189,12 +142,14 @@ in {
|
||||||
icmap
|
icmap
|
||||||
allmap
|
allmap
|
||||||
];
|
];
|
||||||
mapConfig = wrapLuaConfig {luaConfig = concatLines (map concatLines maps);};
|
mappings = concatLines (map concatLines maps);
|
||||||
in
|
in {
|
||||||
entryAfter ["globalsScript"] mapConfig;
|
vim = {
|
||||||
|
luaConfigRC = {
|
||||||
|
globalsScript = concatLines globalsScript;
|
||||||
};
|
};
|
||||||
|
|
||||||
builtConfigRC = let
|
builtLuaConfigRC = let
|
||||||
# Catch assertions and warnings
|
# Catch assertions and warnings
|
||||||
# and throw for each failed assertion. If no assertions are found, show warnings.
|
# and throw for each failed assertion. If no assertions are found, show warnings.
|
||||||
failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
|
failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
|
||||||
|
@ -203,14 +158,22 @@ in {
|
||||||
then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}"
|
then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}"
|
||||||
else showWarnings config.warnings;
|
else showWarnings config.warnings;
|
||||||
|
|
||||||
mapResult = result: concatMapStringsSep "\n" mkVimrcSection result;
|
luaConfig = resolveDag {
|
||||||
vimConfig = resolveDag {
|
name = "lua config script";
|
||||||
name = "vim config script";
|
dag = cfg.luaConfigRC;
|
||||||
dag = cfg.configRC;
|
mapResult = result:
|
||||||
inherit mapResult;
|
concatLines [
|
||||||
|
cfg.luaConfigPre
|
||||||
|
|
||||||
|
(concatMapStringsSep "\n" mkLuarcSection result)
|
||||||
|
extraPluginConfigs
|
||||||
|
mappings
|
||||||
|
|
||||||
|
cfg.luaConfigPost
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
baseSystemAssertWarn vimConfig;
|
baseSystemAssertWarn luaConfig;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,36 +121,15 @@ in {
|
||||||
An attribute set containing global variable values
|
An attribute set containing global variable values
|
||||||
for storing vim variables as early as possible. If
|
for storing vim variables as early as possible. If
|
||||||
populated, this soption will set vim variables in the
|
populated, this soption will set vim variables in the
|
||||||
built configRC as the first item.
|
built luaConfigRC as the first item.
|
||||||
|
|
||||||
E.g. {foo = "bar"} will set `g:foo` to "bar" where
|
E.g. {foo = "bar"} will set `vim.g.foo` to "bar" where
|
||||||
the type of `bar` in the resulting vimscript will be
|
the type of `bar` in the resulting vimscript will be
|
||||||
infered from the type of the value in the `{name = value}`
|
infered from the type of the value in the `{name = value}`
|
||||||
pair.
|
pair.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
configRC = mkOption {
|
|
||||||
type = oneOf [(dagOf lines) str];
|
|
||||||
default = {};
|
|
||||||
description = ''
|
|
||||||
Contents of vimrc, either as a string or a DAG.
|
|
||||||
|
|
||||||
If this option is passed as a DAG, it will be resolved
|
|
||||||
according to the DAG resolution rules (e.g. entryBefore
|
|
||||||
or entryAfter) as per the **nvf** extended library.
|
|
||||||
'';
|
|
||||||
|
|
||||||
example = literalMD ''
|
|
||||||
```vim
|
|
||||||
" Set the tab size to 4 spaces
|
|
||||||
set tabstop=4
|
|
||||||
set shiftwidth=4
|
|
||||||
set expandtab
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
luaConfigPre = mkOption {
|
luaConfigPre = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = ''
|
default = ''
|
||||||
|
@ -245,10 +224,10 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
builtConfigRC = mkOption {
|
builtLuaConfigRC = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
type = lines;
|
type = lines;
|
||||||
description = "The built config for neovim after resolving the DAG";
|
description = "The built lua config for neovim after resolving the DAG";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue