create more optional neovim settings

This commit is contained in:
Noah Masur
2023-11-05 20:40:18 -05:00
parent cf7d1b50f8
commit b471d0fa7a
9 changed files with 42 additions and 22 deletions

View File

@ -0,0 +1,14 @@
-- Keymap to open file in GitHub web
vim.keymap.set("n", "<Leader>gr", ":!gh browse %<CR><CR>", { silent = true })
-- Pop a terminal to watch the current run
local gitwatch =
require("toggleterm.terminal").Terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
-- Set a toggle for this terminal
function GITWATCH_TOGGLE()
gitwatch:toggle()
end
-- Keymap to toggle the run
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)

View File

@ -0,0 +1,6 @@
local k9s = require("toggleterm.terminal").Terminal:new({ cmd = "k9s" })
function K9S_TOGGLE()
k9s:toggle()
end
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)

View File

@ -1,13 +1,16 @@
{ pkgs, lib, config, dsl, ... }: {
# Terraform optional because non-free
options.useTerraform = lib.mkEnableOption "Whether to enable Terraform LSP";
options.terraform = lib.mkEnableOption "Whether to enable Terraform LSP";
options.github = lib.mkEnableOption "Whether to enable GitHub features";
options.kubernetes =
lib.mkEnableOption "Whether to enable Kubernetes features";
config =
let
terraformFormat = if config.useTerraform then ''
terraformFormat = if config.terraform then ''
require("null-ls").builtins.formatting.terraform_fmt.with({
command = "${pkgs.terraform}/bin/terraform",
extra_filetypes = { "hcl" },
@ -40,7 +43,11 @@
};
use.lspconfig.terraformls.setup = dsl.callWith {
cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ];
cmd = if config.terraform then [
"${pkgs.terraform-ls}/bin/terraform-ls"
"serve"
] else
[ "echo" ];
};
use.lspconfig.rust_analyzer.setup = dsl.callWith {

View File

@ -26,17 +26,5 @@ function NIXPKGS_TOGGLE()
nixpkgs:toggle()
end
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
function GITWATCH_TOGGLE()
gitwatch:toggle()
end
local k9s = terminal:new({ cmd = "k9s" })
function K9S_TOGGLE()
k9s:toggle()
end
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)

View File

@ -1,4 +1,4 @@
{ pkgs, dsl, ... }: {
{ pkgs, dsl, config, ... }: {
# Toggleterm provides a floating terminal inside the editor for quick access
@ -10,6 +10,10 @@
direction = "float";
};
lua = builtins.readFile ./toggleterm.lua;
lua = ''
${builtins.readFile ./toggleterm.lua}
${if config.github then (builtins.readFile ./github.lua) else ""}
${if config.kubernetes then (builtins.readFile ./kubernetes.lua) else ""}
'';
}