nvim improvements

This commit is contained in:
jdonszelmann 2024-09-02 09:29:56 +02:00
parent a94e2ae578
commit e767060559
No known key found for this signature in database
GPG key ID: E0C1EA36407B2FF2
7 changed files with 181 additions and 42 deletions

View file

@ -15,8 +15,8 @@
t.url = "github:jdonszelmann/t-rs";
kitty-search = {
url = "github:trygveaa/kitty-kitten-search";
flake = false;
url = "github:trygveaa/kitty-kitten-search";
flake = false;
};
};
@ -39,27 +39,29 @@
} // {
inherit (args) extraSpecialArgs;
});
in flake-utils.lib.eachDefaultSystem (system: rec {
formatter = legacyPackages.nixfmt-classic;
legacyPackages = pkgsForSystem system;
pkgs = legacyPackages;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
(pkgs.writeShellScriptBin "fast-repl" ''
source /etc/set-environment
nix repl --file "${./.}/repl.nix" $@
'')
in
flake-utils.lib.eachDefaultSystem
(system: rec {
formatter = legacyPackages.nixfmt-classic;
legacyPackages = pkgsForSystem system;
pkgs = legacyPackages;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
(pkgs.writeShellScriptBin "fast-repl" ''
source /etc/set-environment
nix repl --file "${./.}/repl.nix" $@
'')
(pkgs.writeShellScriptBin "apply-home" ''
nix run .#home-manager -- switch --flake .#$@
'')
(pkgs.writeShellScriptBin "apply-home" ''
nix run .#home-manager -- switch --flake .#$@
'')
(pkgs.writeShellScriptBin "apply" ''
apply-home $(hostname -f)
'')
];
};
}) // {
(pkgs.writeShellScriptBin "apply" ''
apply-home $(hostname -f)
'')
];
};
}) // {
homeConfigurations = {
kili = mkHomeConfiguration (import ./hosts/kili/home.nix) {

View file

@ -8,6 +8,7 @@
../../programs/zsh
../../programs/kanata
../../programs/kitty
../../programs/tmux
];
# use the system-installed version of kitty on arch

View file

@ -16,15 +16,16 @@
grv 1 2 3 4 5 6 7 8 9 0 - = bspc
tab q w e r t y u i o p [ ] \
@cap a s d f g h j k l ; ' ret
lsft z x c v b n m , . / rsft
@lst z x c v b n m , . / rsft
lctl lmet lalt spc ralt rctl
)
(defalias
esc (tap-hold 200 800 esc caps)
esc (tap-hold 800 800 esc caps)
cap (tap-dance 300 (esc C-k esc))
qwr (layer-switch qwerty)
lst (tap-hold-release 200 200 C-k lsft)
)

View file

@ -31,10 +31,12 @@
keybindings = {
"ctrl+f" = "launch --location=hsplit --allow-remote-control kitty +kitten ${inputs.kitty-search}/search.py @active-kitty-window-id";
"ctrl+r" = "load_config_file";
"ctrl+alt+r" = "load_config_file";
"ctrl+shift+r" = "no_op";
"ctrl+EQUAL" = "change_font_size all +2.0";
"ctrl+minus" = "change_font_size all -2.0";
"ctrl+0" = "change_font_size all 0";
"ctrl+/" = "send_text all \x1b[47;5u";
};
};
}

View file

@ -19,7 +19,10 @@ vim.filetype.add({
require("onedark").setup {
style = "deep",
highlights = {
["@comment"] = {fg = '#77B767'}
["@lsp.type.comment"] = {fg = '#77B767'},
["@comment.documentation.rust"] = {fg = '#77B767'},
["@comment.documentation"] = {fg = '#77B767'},
["@comment"] = {fg = '#426639'}
}
}
require("onedark").load()
@ -68,10 +71,14 @@ local opts = { noremap = true, silent = true }
local builtin = require('telescope.builtin')
-- comment
vim.keymap.set("n", "<C-/>", ":lua require('Comment.api').toggle.linewise.current()<CR> j", opts)
vim.keymap.set("v", "<C-/>", ":lua require('Comment.api').toggle.linewise.current()<CR> j", opts)
vim.keymap.set("n", "<leader>c", ":lua require('Comment.api').toggle.linewise.current()<CR> j", { remap = true })
vim.keymap.set("v", "<leader>c", ":lua require('Comment.api').toggle.linewise.current()<CR> j", { remap = true })
-- indent and dedent using tab/shift-tab
vim.keymap.set("n", "<C-/>", ":lua require('Comment.api').toggle.linewise.current()<CR> j", { remap = true })
vim.keymap.set("v", "<C-/>", ":lua require('Comment.api').toggle.linewise.current()<CR> j", { remap = true })
-- indent and dedent using tab/shift-ta
vim.keymap.set("n", "<tab>", ">>_")
vim.keymap.set("n", "<s-tab>", "<<_")
vim.keymap.set("i", "<s-tab>", "<c-d>")
@ -85,7 +92,7 @@ vim.keymap.set('n', 'gt', builtin.lsp_type_definitions, {})
-- format on wq and x and replace X, W and Q with x, w and q
vim.cmd [[cabbrev wq execute "Format sync" <bar> wq]]
vim.cmd [[cabbrev x execute "Format sync" <bar> x]# ]]
vim.cmd [[cabbrev x execute "Format sync" <bar> x]]
vim.cmd [[cnoreabbrev W w]]
vim.cmd [[cnoreabbrev X execute "Format sync" <bar> x]]
vim.cmd [[cnoreabbrev Q q]]
@ -94,14 +101,21 @@ vim.cmd [[nnoremap ; :]]
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>s', "<cmd>vertical sb<cr>", {})
vim.keymap.set('n', '<leader>f', builtin.find_files, {})
vim.keymap.set('n', '<leader><leader>', builtin.live_grep, {})
vim.keymap.set('n', '<leader><leader>', builtin.find_files, {})
vim.keymap.set('n', '<leader>f', builtin.live_grep, {})
vim.keymap.set('n', '<leader>h', builtin.search_history, {})
vim.keymap.set('n', '<leader>d', "<cmd>Telescope diagnostics bufnr=0<cr>", {})
vim.keymap.set('n', '<leader>ad', builtin.diagnostics, {})
vim.keymap.set('n', '<leader>em', "<cmd>RustLsp expandMacro<cr>")
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "<leader>x", require("telescope.builtin").resume, {
noremap = true,
silent = true,
desc = "Resume",
})
local gitsigns = require('gitsigns')
vim.keymap.set('n', '<leader>gr', gitsigns.reset_hunk)
vim.keymap.set('n', '<leader>gd', gitsigns.diffthis)
@ -221,3 +235,10 @@ vim.cmd([[
filetype plugin indent on
]])
-- multicursor
vim.g.VM_default_mappings = 1
vim.g.VM_reselect_first = 1
vim.g.VM_notify_previously_selected = 1
vim.g.VM_theme = "iceblue"

View file

@ -62,6 +62,7 @@ in
nixGrammars = true;
ensureInstalled = "all";
};
rainbow-delimiters.enable = true;
surround.enable = true;
cmp-nvim-lsp.enable = true;
lsp-format.enable = true;
@ -240,7 +241,6 @@ in
};
};
lsp = {
enable = true;
@ -260,6 +260,7 @@ in
};
};
};
clangd = {
enable = true;
filetypes = [ "c" "cpp" "objc" "objcpp" ];
@ -281,10 +282,10 @@ in
enable = true;
filetypes = [ "python" ];
};
taplo = {
enable = true;
filetypes = [ "toml" ];
};
# taplo = {
# enable = true;
# filetypes = [ "toml" ];
# };
bashls = {
enable = true;
@ -306,8 +307,8 @@ in
keymaps = {
lspBuf = {
"<leader>fmt" = "format";
"<leader>h" = "hover";
"<leader>;" = "format";
"gh" = "hover";
};
};
};
@ -338,6 +339,20 @@ in
enable = true;
diagnostics = "nvim_lsp";
};
none-ls = {
enable = true;
sources = {
formatting.nixpkgs_fmt.enable = true;
code_actions.statix.enable = true;
diagnostics = {
statix.enable = true;
deadnix.enable = true;
};
};
};
nix.enable = true;
};
extraPlugins = with pkgs.vimPlugins; [
onedark-nvim
@ -352,13 +367,14 @@ in
render-markdown
otter
vim-astro
nvim-web-devicons
nvim-web-devicons
vim-visual-multi
];
extraConfigLua = ''
require("render-markdown").setup {
latex_converter = '${pkgs.python312Packages.pylatexenc}/bin/latex2text',
}
require("render-markdown").setup {
latex_converter = '${pkgs.python312Packages.pylatexenc}/bin/latex2text',
}
'' + (builtins.readFile ./config.lua);
opts = {

96
programs/tmux/default.nix Normal file
View file

@ -0,0 +1,96 @@
{ pkgs, ... }: {
programs.tmux = {
enable = true;
mouse = true;
clock24 = true;
shortcut = "k";
extraConfig = ''
# unbind every single normal keybinding
unbind-key -a
set -g set-titles on
set -s escape-time 0
set-window-option -g mode-keys vi
# clipboard stuff
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel
bind v copy-mode
bind p paste-buffer -p
set -s set-clipboard on
# get back normal terminal emulator bindings
bind-key -n S-PPage copy-mode -u
bind-key -T copy-mode -n S-NPage send-keys -X page-down
# don't scroll to end when copying with mouse
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe
bind-key -T copy-mode DoubleClick1Pane select-pane \; send-keys -X select-word \; run-shell -d 0.3 \; send-keys -X copy-pipe
bind-key -T copy-mode TripleClick1Pane select-pane \; send-keys -X select-line \; run-shell -d 0.3 \; send-keys -X copy-pipe
bind-key -T copy-mode-vi DoubleClick1Pane select-pane \; send-keys -X select-word \; run-shell -d 0.3 \; send-keys -X copy-pipe
bind-key -T copy-mode-vi TripleClick1Pane select-pane \; send-keys -X select-line \; run-shell -d 0.3 \; send-keys -X copy-pipe
# window control
bind t new-window -c "#{pane_current_path}"
bind-key Tab next-window
bind-key BTab previous-window
set -g automatic-rename-format "#{?#{==:#{pane_current_path},$HOME},~,#{b:pane_current_path}} (#{pane_current_command})"
set -g renumber-windows on
bind-key Q confirm-before -p "kill-window #W? (y/n)" kill-window
bind A last-window
bind-key 1 select-window -t :0
bind-key 2 select-window -t :1
bind-key 3 select-window -t :2
bind-key 4 select-window -t :3
bind-key 5 select-window -t :4
bind-key 6 select-window -t :5
bind-key 7 select-window -t :6
bind-key 8 select-window -t :7
bind-key 9 select-window -t :8
bind-key 0 select-window -t :9
# pane control
bind h select-pane -L
bind j select-pane -S
bind k select-pane -U
bind l select-pane -R
bind L split-window -h -c "#{pane_current_path}"
bind J split-window -v -c "#{pane_current_path}"
bind H split-window -h -b -c "#{pane_current_path}"
bind K split-window -v -b -c "#{pane_current_path}"
bind x swap-pane -D
bind -r a select-pane -l
bind-key q confirm-before -p "kill-pane #P? (y/n)" kill-pane
bind-key o choose-tree -wZ
bind-key O choose-tree -sZ
# get back command mode and some other basics...
bind : command-prompt
bind r source-file ~/.config/tmux/tmux.conf \; display "config reloaded"
bind-key ? list-keys
# Scroll oin man etc
tmux_commands_with_legacy_scroll="nano less more man git"
bind-key -T root WheelUpPane \
if-shell -Ft= '#{?mouse_any_flag,1,#{pane_in_mode}}' \
'send -Mt=' \
'if-shell -t= "#{?alternate_on,true,false} || echo \"#{tmux_commands_with_legacy_scroll}\" | grep -q \"#{pane_current_command}\"" \
"send -t= Up" "copy-mode -et="'
bind-key -T root WheelDownPane \
if-shell -Ft = '#{?pane_in_mode,1,#{mouse_any_flag}}' \
'send -Mt=' \
'if-shell -t= "#{?alternate_on,true,false} || echo \"#{tmux_commands_with_legacy_scroll}\" | grep -q \"#{pane_current_command}\"" \
"send -t= Down" "send -Mt="'
# bind -n DoubleClick1Pane run-shell "${pkgs.xdragon}/bin/dragon -x '#{pane_current_path}/#{mouse_word}'"
'';
};
}