feat: switch to fish as an interactive shell
All checks were successful
/ check (push) Successful in 8s
/ check-renovaterc (push) Successful in 4s
/ build-packages (push) Successful in 14s
/ build-vm (push) Successful in 2s
/ report-size (push) Successful in 4s

Now that it is written in Rust I am interested!
This commit is contained in:
Jalil David Salamé Messina 2025-03-23 21:44:28 +01:00
parent 6bf3851d5a
commit cd4fb19335
Signed by: jalil
GPG key ID: F016B9E770737A0B
6 changed files with 117 additions and 139 deletions

View file

@ -12,7 +12,7 @@ in
modules = [
inputs.self.nixosModules.default
../example-vm # import vm configuration
{ nix.registry.nixpkgs.flake = inputs.nixpkgs; }
{ nix.registry.nixpkgs.flake = inputs.nixpkgs; } # pin nixpkgs to the one used by the system
];
};

View file

@ -58,6 +58,11 @@ in
git = true;
icons = "auto";
};
# Shell
fish = {
enable = true;
preferAbbrs = true; # when defining an alias, prefer instead to define an abbreviation
};
# GnuPG
gpg = {
enable = true;
@ -75,16 +80,6 @@ in
ssh.enable = true;
# cd replacement
zoxide.enable = true;
# Shell
zsh = {
enable = true;
autosuggestion.enable = true;
enableCompletion = true;
autocd = true;
dotDir = ".config/zsh";
history.path = "${config.xdg.dataHome}/zsh/zsh_history";
syntaxHighlighting.enable = true;
};
};
services = {

View file

@ -129,13 +129,13 @@ in
# PDF reader
zathura.enable = true;
# Auto start sway
zsh.loginExtra =
lib.optionalString cfg.sway.autostart # sh
fish.loginShellInit =
lib.optionalString cfg.sway.autostart # fish
''
# Start Sway on login to TTY 1
if [ "$TTY" = /dev/tty1 ]; then
if test "$(tty)" = /dev/tty1
exec sway
fi
end
'';
};
services = {

View file

@ -35,6 +35,17 @@ in
];
programs = {
# Launch fish if shell is interactive (from https://wiki.nixos.org/wiki/Fish)
bash.interactiveShellInit = # bash
''
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
'';
# Default shell
fish.enable = true;
# Shell prompt
starship = {
enable = true;
@ -58,8 +69,6 @@ in
(import ./starship-shorter-text.nix)
];
};
# Default shell
zsh.enable = true;
};
environment.etc = keysFromGithub;
@ -74,7 +83,6 @@ in
builtins.attrNames keysFromGithub
);
};
users.defaultUserShell = pkgs.zsh;
# Open ports for spotifyd
networking.firewall = {
allowedUDPPorts = [ 5353 ];

View file

@ -21,6 +21,7 @@ let
"typos_lsp"
# "typst_lsp" # Not using it
"zls"
"fish_lsp"
];
in
{
@ -95,6 +96,7 @@ in
pkgs.stylua
pkgs.taplo
pkgs.yamlfmt
pkgs.fish
];
plugins.conform-nvim = {
enable = true;
@ -111,6 +113,7 @@ in
toml = [ "taplo" ];
yaml = [ "yamlfmt" ];
zig = [ "zigfmt" ];
fish = [ "fish_indent" ];
};
};
};
@ -127,7 +130,6 @@ in
# latex = [ "chktex" ]; # Not in use
nix = [ "statix" ];
sh = [ "dash" ];
zsh = [ "zsh" ];
};
};
}

View file

@ -4,129 +4,102 @@ let
in
{
config.plugins = {
cmp = {
enable = true;
cmdline = {
"/" = {
mapping =
mkRaw
# lua
''
cmp.mapping.preset.cmdline()
'';
sources = [
{ name = "rg"; }
{ name = "buffer"; }
];
cmp =
let
srcWithIndex = groupIndex: name: { inherit name groupIndex; };
in
{
enable = true;
cmdline = {
"/" = {
mapping =
mkRaw
# lua
''
cmp.mapping.preset.cmdline()
'';
sources = [
{ name = "rg"; }
{ name = "buffer"; }
];
};
":" = {
mapping =
mkRaw
# lua
"cmp.mapping.preset.cmdline()";
sources = [
{ name = "path"; }
{ name = "cmdline"; }
];
};
};
":" = {
mapping =
mkRaw
# lua
''
cmp.mapping.preset.cmdline()
'';
sources = [
{ name = "path"; }
{ name = "cmdline"; }
];
};
};
settings = {
# Snippets
snippet.expand =
# lua
''
function(args) require('luasnip').lsp_expand(args.body) end
'';
# Completion Sources
sources = [
{
name = "buffer";
groupIndex = 3;
}
{
name = "calc";
groupIndex = 2;
}
{
name = "conventionalcommits";
groupIndex = 1;
}
{
name = "crates";
groupIndex = 1;
}
{
name = "luasnip";
groupIndex = 1;
}
{
name = "nvim_lsp";
groupIndex = 1;
}
{
name = "nvim_lsp_document_symbol";
groupIndex = 1;
}
{
name = "nvim_lsp_signature_help";
groupIndex = 1;
}
{
name = "path";
groupIndex = 2;
}
{
name = "spell";
groupIndex = 2;
}
{
name = "treesitter";
groupIndex = 2;
}
];
mapping =
mkRaw
settings = {
# Snippets
snippet.expand =
# lua
''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
"function(args) require('luasnip').lsp_expand(args.body) end";
# Completion Sources
sources = [
# very specific (not noisy)
(srcWithIndex 1 "calc")
(srcWithIndex 1 "crates")
(srcWithIndex 1 "fish")
(srcWithIndex 1 "luasnip")
(srcWithIndex 1 "nvim_lsp")
# Generally ok
(srcWithIndex 2 "conventionalcommits")
(srcWithIndex 2 "nvim_lsp_document_symbol")
(srcWithIndex 2 "nvim_lsp_signature_help")
# Noisy
(srcWithIndex 2 "path")
(srcWithIndex 3 "spell")
(srcWithIndex 3 "treesitter")
# Very noisy
(srcWithIndex 4 "buffer")
];
mapping =
mkRaw
# lua
''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
};
};
};
cmp-fish.enable = true;
gitsigns.enable = true;
lualine = {
enable = true;