Update keybinds

This commit is contained in:
Alex Davies 2024-06-12 14:56:39 -03:00
parent 87a21720f2
commit 12e292260d
3 changed files with 167 additions and 17 deletions

View File

@ -388,16 +388,16 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1717786204,
"narHash": "sha256-4q0s6m0GUcN7q+Y2DqD27iLvbcd1G50T2lv08kKxkSI=",
"lastModified": 1718086528,
"narHash": "sha256-hoB7B7oPgypePz16cKWawPfhVvMSXj4G/qLsfFuhFjw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "051f920625ab5aabe37c920346e3e69d7d34400e",
"rev": "47b604b07d1e8146d5398b42d3306fdebd343986",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}

View File

@ -3,7 +3,7 @@
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nix-index-database.url = "github:nix-community/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";

View File

@ -14,7 +14,6 @@
inputs.nix-index-database.hmModules.nix-index
];
nixpkgs = {
# You can add overlays here
overlays = [
@ -51,7 +50,7 @@
enable = true;
userName = "Alex Davies";
userEmail = "traverse.da@gmail.com";
extraConfig = {
core = {
editor = "vim"; # Set default editor for Git
@ -79,7 +78,7 @@
programs.nixvim = {
enable = true;
defaultEditor = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
#We use bufferline for the top line
@ -88,22 +87,56 @@
plugins.lualine = {
enable = true;
sections = {
lualine_c = [ "os.date('%X')"];
lualine_x = [
{name= "hostname";}
];
};
};
};
#Enable which key
plugins.which-key.enable = true;
extraPlugins = with pkgs.vimPlugins; [
vim-suda
];
plugins.cmp.enable = true;
plugins.cmp-treesitter.enable = true;
#enable autocomplete
plugins.cmp = {
enable = true;
settings = {
mapping = {
__raw = ''
cmp.mapping.preset.insert({
['<C-j>'] = cmp.mapping.select_next_item(),
['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-e>'] = cmp.mapping.abort(),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<S-CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
})
'';
};
sources = [
{name = "path";}
{name = "nvim_lsp";}
{name = "buffer";}
{name = "treesitter";}
{name = "copilot";}
];
};
};
plugins.indent-blankline.enable = true;
plugins.lsp-format.enable = true;
plugins.lsp-status.enable = true;
plugins.lsp = {
enable = true;
servers = {
@ -111,9 +144,19 @@
html.enable = true;
nixd.enable = true;
dockerls.enable = true;
yamlls.enable = true;
yamlls.enable = true;
};
};
plugins.lsp-lines.enable = true;
plugins.lint = {
enable = true;
};
plugins.nix.enable = true;
plugins.clipboard-image = {
enable = true;
clipboardPackage = pkgs.xclip;
};
colorschemes.tokyonight = {
enable = true;
@ -126,26 +169,57 @@
pattern = "*",
command = "startinsert"
})
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "term://*",
command = "startinsert"
})
-- Open files with sudo if needed
vim.g.suda_smart_edit = 1
-- Make my cursor a block
vim.opt.guicursor = "n-v-c:block"
-- Disable ctrl+a incrementing numbers
vim.api.nvim_set_keymap('i', '<C-a>', '<nop>', { noremap = true })
-- Use system clipboard by default
vim.opt.clipboard:append("unnamedplus")
-- Keep selection when changing indentation
-- keep visual mode after indent
vim.api.nvim_set_keymap('v', '<', '<gv', { noremap = true })
vim.api.nvim_set_keymap('v', '>', '>gv', { noremap = true })
-- Basic indentation settings
vim.o.tabstop = 4 -- Number of spaces that a <Tab> in the file counts for
vim.o.shiftwidth = 4 -- Number of spaces to use for each step of (auto)indent
vim.o.expandtab = true -- Use spaces instead of tabs
vim.o.autoindent = true -- Copy indent from current line when starting a new line
vim.o.smartindent = true -- Do smart autoindenting when starting a new line
-- Enable list mode
vim.opt.list = true
vim.opt.listchars:append({ tab = '>-', trail = 'x' })
-- Enable undofile support
vim.o.undofile = true
'';
globals.mapleader = " ";
keymaps = [
{
mode = "n";
mode = ["n" "t"];
key = "<C-a>c";
options = { noremap = true; desc = "Open new terminal"; };
action = "<cmd>:term<cr>";
}
{
mode = "n";
mode = ["n"];
key = "<C-a>x";
options = { noremap = true; desc = "Close tab"; };
action = "<cmd>:bd<cr>";
}
{
mode = "n";
mode = ["t"];
key = "<C-a>x";
options = { noremap = true; desc = "Close tab"; };
action = "<cmd>:bd!<cr>";
}
{
mode = ["n" "t"];
key = "<C-a>s";
options = { noremap = true; desc = "Pick buffer"; };
action = "<cmd>:BufferLinePick<CR>";
@ -156,6 +230,60 @@
options = { noremap = true; };
action = "<C-\\><C-n>";
}
{
mode = ["n"];
key = "<leader>w";
options = { noremap = true; desc = "+windows"; };
action = "+windows";
}
{
mode = ["n"];
key = "<leader>w<Left>";
options = { noremap = true; desc = "Move Left"; };
action = "<C-w>h";
}
{
mode = ["n"];
key = "<leader>w<Right>";
options = { noremap = true; desc = "Move Right"; };
action = "<C-w>l";
}
{
mode = ["n"];
key = "<leader>w<Up>";
options = { noremap = true; desc = "Move Up"; };
action = "<C-w>k";
}
{
mode = ["n"];
key = "<leader>w<Down>";
options = { noremap = true; desc = "Move Down"; };
action = "<C-w>j";
}
{
mode = ["n"];
key = "<leader>wx";
options = { noremap = true; desc = "Close Window"; };
action = "<cmd>:close<cr>";
}
{
mode = ["n"];
key = "<leader>ws";
options = { noremap = true; desc = "+splits"; };
action = "+splits";
}
{
mode = ["n"];
key = "<leader>wsh";
options = { noremap = true; desc = "Horizontal Split"; };
action = "<cmd>:split<cr>";
}
{
mode = ["n"];
key = "<leader>wsv";
options = { noremap = true; desc = "Vertical Split"; };
action = "<cmd>:vsplit<cr>";
}
];
};
@ -176,7 +304,6 @@
pkgs.ripgrep
pkgs.waypipe
pkgs.pwgen
pkgs.chezmoi
pkgs.neovim-remote
pkgs.pipx
pkgs.rclone
@ -201,6 +328,29 @@
(pkgs.writeShellScriptBin "nvr-edit" ''
nvr --remote-wait $@
'')
# (pkgs.writeShellScriptBin "copyfile" ''
# set -e
# if [ "x$1" = "x" ]; then
# echo "Usage: [options] $0 file..." >&2
# echo "-p Copy path information; preserve tree structure"
# exit 1
# fi
# archive=`mktemp` || exit 1
# trap 'rm -f "''${archive}"' 1 2 3 15
# if [ "x$1" = "x-p" ]; then
# tar cf "''${archive}" "$@"
# else
# flags="cf"
# for file in "$@"; do
# filedir=`dirname "''${file}"`
# filename=`basename "''${file}"`
# tar "''${flags}" "''${archive}" -C "''${filedir}" "''${filename}"
# flags="rf"
# done
# fi
# gzip -c "''${archive}" | xclip -selection clipboard -loops 1 -i
# rm "''${archive}"
# '')
];
programs.zsh = {