Merge branch 'main' into feature/custom-keybinds

This commit is contained in:
Michał 2023-05-03 00:18:25 +02:00 committed by GitHub
commit 933fa2a8ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 190 additions and 130 deletions

View file

@ -133,8 +133,8 @@ in {
set termguicolors
set t_Co=256
''}
${optionalString cfg.enableEditorconfig ''
vim.g.editorconfig = false
${optionalString (!cfg.enableEditorconfig) ''
let g:editorconfig = v:false
''}
'';
};

View file

@ -141,7 +141,7 @@ with builtins; {
};
enableEditorconfig = mkOption {
type = types.bool;
default = false;
default = true;
description = "Follow editorconfig rules in current directory";
};
};

View file

@ -16,8 +16,19 @@ with builtins; let
lspconfig.ccls.setup{
capabilities = capabilities;
on_attach=default_on_attach;
cmd = {"${pkgs.ccls}/bin/ccls"};
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.cclsOpts}"}
cmd = {"${cfg.lsp.package}/bin/ccls"};
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
}
'';
};
clangd = {
package = pkgs.clang-tools;
lspConfig = ''
lspconfig.clangd.setup{
capabilities = capabilities;
on_attach=default_on_attach;
cmd = {"${cfg.lsp.package}/bin/clangd"};
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
}
'';
};

View file

@ -64,7 +64,11 @@ in {
type = with types; enum (attrNames servers);
default = defaultServer;
};
package = nvim.types.mkGrammarOption pkgs "python";
package = mkOption {
description = "python LSP server package";
type = types.package;
default = servers.${cfg.lsp.server}.package;
};
};
format = {

View file

@ -55,7 +55,7 @@ with builtins; let
};
in {
options.vim.languages.ts = {
enable = mkEnableOption "SQL language support";
enable = mkEnableOption "Typescript/Javascript language support";
treesitter = {
enable = mkOption {

View file

@ -28,7 +28,7 @@ in {
package = mkOption {
description = "ZLS package";
type = types.package;
default = pkgs.nodePackages.pyright;
default = pkgs.zls;
};
zigPackage = mkOption {
description = "Zig package used by ZLS";
@ -37,7 +37,6 @@ in {
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;

View file

@ -21,6 +21,7 @@ in {
'';
vim.luaConfigRC.null_ls = nvim.dag.entryAfter ["null_ls-setup" "lsp-setup"] ''
require('null-ls').setup({
debug = false,
diagnostics_format = "[#{m}] #{s} (#{c})",
debounce = 250,
default_timeout = 5000,

View file

@ -6,33 +6,64 @@
with lib;
with builtins; let
cfg = config.vim.terminal.toggleterm;
toggleKey = "<c-t>";
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"toggleterm-nvim"
];
config = mkMerge [
(
mkIf cfg.enable {
vim.startPlugins = [
"toggleterm-nvim"
];
vim.maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
require("toggleterm").setup({
open_mapping = null,
direction = '${toString cfg.direction}',
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
size = function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
winbar = {
enabled = '${toString cfg.enable_winbar}',
name_formatter = function(term) -- term: Terminal
return term.name
end
},
})
'';
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
require("toggleterm").setup({
open_mapping = null,
direction = '${toString cfg.direction}',
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
size = function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
winbar = {
enabled = '${toString cfg.enable_winbar}',
name_formatter = function(term) -- term: Terminal
return term.name
end
},
})
'';
}
)
(
mkIf (cfg.enable && cfg.lazygit.enable)
{
vim.startPlugins = lib.optionals (cfg.lazygit.package != null) [
cfg.lazygit.package
];
vim.luaConfigRC.toggleterm-lazygit = nvim.dag.entryAfter ["toggleterm"] ''
local terminal = require 'toggleterm.terminal'
local lazygit = terminal.Terminal:new({
cmd = '${
if (cfg.lazygit.package != null)
then getExe cfg.lazygit.package
else "lazygit"
}',
direction = '${cfg.lazygit.direction}',
hidden = true,
on_open = function(term)
vim.cmd("startinsert!")
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
end
})
vim.maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
};
vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
'';
}
)
];
}

View file

@ -1,4 +1,5 @@
{
pkgs,
config,
lib,
...
@ -24,5 +25,18 @@ with builtins; {
default = false;
description = "Enable winbar";
};
lazygit = {
enable = mkEnableOption "Enable LazyGit integration";
direction = mkOption {
type = types.enum ["horizontal" "vertical" "tab" "float"];
default = "float";
description = "Direction of the lazygit window";
};
package = mkOption {
type = with types; nullOr package;
default = pkgs.lazygit;
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
};
};
};
}

View file

@ -1,6 +1,9 @@
{lib}: {
onedark = {
setup = {style ? "dark"}: ''
setup = {
style ? "dark",
transparent,
}: ''
-- OneDark theme
require('onedark').setup {
style = "${style}"
@ -11,12 +14,13 @@
};
tokyonight = {
setup = {style ? "night"}: ''
-- need to set style before colorscheme to apply
vim.g.tokyonight_style = '${style}'
vim.cmd[[colorscheme tokyonight]]
setup = {
style ? "night",
transparent,
}: ''
vim.cmd[[colorscheme tokyonight-${style}]]
'';
styles = ["day" "night" "storm"];
styles = ["day" "night" "storm" "moon"];
};
dracula = {
@ -34,7 +38,7 @@
-- Catppuccin theme
require('catppuccin').setup {
flavour = "${style}",
transparent_background = "${builtins.toString transparent}",
transparent_background = ${lib.boolToString transparent},
integrations = {
nvimtree = {
enabled = true,

View file

@ -40,6 +40,8 @@ in {
config = mkIf cfg.enable {
vim.startPlugins = [cfg.name];
vim.luaConfigRC.themeSetup = nvim.dag.entryBefore ["theme"] cfg.extraConfig;
vim.luaConfigRC.theme = supported_themes.${cfg.name}.setup {style = cfg.style;};
vim.luaConfigRC.theme = supported_themes.${cfg.name}.setup (with cfg; {
inherit style transparent;
});
};
}

View file

@ -7,7 +7,6 @@ _: {
./colorizer
./icon-picker
./telescope
./venn
./diffview
];
}

View file

@ -1,42 +0,0 @@
{
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.utility.venn-nvim;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"venn-nvim"
];
# TODO: https://github.com/jbyuki/venn.nvim#using-toggle-command
# add keybindings for drawing diagrams
vim.luaConfigRC.venn-nvim = nvim.dag.entryAnywhere ''
local venn = require('venn')
-- venn.nvim: enable or disable keymappings
function _G.Toggle_venn()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == "nil" then
vim.b.venn_enabled = true
vim.cmd[[setlocal ve=all]]
-- draw a line on HJKL keystokes
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", {noremap = true})
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true})
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true})
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true})
-- draw a box by pressing "f" with visual selection
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true})
else
vim.cmd[[setlocal ve=]]
vim.cmd[[mapclear <buffer>]]
vim.b.venn_enabled = nil
end
end
-- toggle keymappings for venn using <leader>v
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true})
'';
};
}

View file

@ -1,6 +0,0 @@
_: {
imports = [
./config.nix
./venn.nix
];
}

View file

@ -1,11 +0,0 @@
{
config,
lib,
...
}:
with lib;
with builtins; {
options.vim.utility.venn-nvim = {
enable = mkEnableOption "Enable venn.nvim: draw ASCII diagrams in Neovim";
};
}