Compare commits

..

10 commits

18 changed files with 363 additions and 103 deletions

View file

@ -97,7 +97,7 @@ with lib; {
mullvad.enable = true; mullvad.enable = true;
openconnect.enable = true; openconnect.enable = true;
printing.enable = true; printing.enable = true;
redshift.enable = true; gammastep.enable = true;
wireguard.enable = true; wireguard.enable = true;
}; };
}; };

View file

@ -69,34 +69,6 @@ vim.api.nvim_create_autocmd("InsertEnter", {
end, end,
}) })
---merge tables
---@param ... table[]
---@return table
local function table_merge(...)
local tables_to_merge = { ... }
assert(#tables_to_merge > 1, "There should be at least two tables to merge them")
for k, t in ipairs(tables_to_merge) do
assert(type(t) == "table", string.format("Expected a table as function parameter %d", k))
end
local result = tables_to_merge[1]
for i = 2, #tables_to_merge do
local from = tables_to_merge[i]
for k, v in pairs(from) do
if type(v) == "table" then
result[k] = result[k] or {}
result[k] = table_merge(result[k], v)
else
result[k] = v
end
end
end
return result
end
local lsp_lines = require("lsp_lines") local lsp_lines = require("lsp_lines")
lsp_lines.setup() lsp_lines.setup()
-- Disable virtual_text since it's redundant due to lsp_lines. -- Disable virtual_text since it's redundant due to lsp_lines.
@ -175,8 +147,6 @@ local on_attach_def = function(_, bufnr)
l = { l = {
name = "lsp", name = "lsp",
d = { "<cmd>Lspsaga show_cursor_diagnostics<cr>", "open diagnostic window" }, d = { "<cmd>Lspsaga show_cursor_diagnostics<cr>", "open diagnostic window" },
n = { "<cmd>Lspsaga diagnostic_jump_next<CR>", "next error" },
p = { "<cmd>Lspsaga diagnostic_jump_prev<CR>", "prev error" },
c = { "<cmd>Lspsaga code_action<cr>", "code action" }, c = { "<cmd>Lspsaga code_action<cr>", "code action" },
r = { "<cmd>Lspsaga rename<cr>", "rename" }, r = { "<cmd>Lspsaga rename<cr>", "rename" },
i = { "<cmd>Lspsaga hover_doc ++keep<cr>", "show info (sticky)" }, i = { "<cmd>Lspsaga hover_doc ++keep<cr>", "show info (sticky)" },
@ -188,17 +158,6 @@ local on_attach_def = function(_, bufnr)
mode = { "n", "v" }, mode = { "n", "v" },
}, },
}, },
w = {
name = "workspace",
a = { vim.lsp.buf.add_workspace_folder, "add workspace folder" },
r = { vim.lsp.buf.remove_workspace_folder, "remove workspace folder" },
l = {
function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end,
"list workspace folders",
},
},
t = { t = {
name = "toggle", name = "toggle",
l = { lsp_lines.toggle, "lsp lines" }, l = { lsp_lines.toggle, "lsp lines" },
@ -206,9 +165,18 @@ local on_attach_def = function(_, bufnr)
}, },
g = { g = {
name = "goto", name = "goto",
d = { "<cmd>Lspsaga peek_definition<cr>", "definition" }, d = { "<cmd>Lspsaga peek_definition<cr>", "Goto definition" },
t = { "<cmd>Lspsaga peek_type_definition<cr>", "type defininition" }, t = { "<cmd>Lspsaga peek_type_definition<cr>", "Goto type defininition" },
h = { "<cmd>Lspsaga lsp_finder<CR>", "lsp finder" }, h = { "<cmd>Lspsaga lsp_finder<CR>", "Lsp finder" },
r = { "<cmd>Telescope lsp_references<cr>", "Goto reference" },
D = { vim.lsp.buf.declaration, "Goto declaration" },
I = { "<cmd>Telescope lsp_implementations<cr>", "Goto implementation" },
},
["["] = {
d = { "<cmd>Lspsaga diagnostic_jump_prev<cr>", "Previous diagnostic" },
},
["]"] = {
d = { "<cmd>Lspsaga diagnostic_jump_next<cr>", "Next diagnostic" },
}, },
}, { buffer = bufnr, silent = true }) }, { buffer = bufnr, silent = true })
end end
@ -226,7 +194,7 @@ local lspconfig_default_options = {
---@param options table ---@param options table
---@return nil ---@return nil
local function lspconfig_setup(lsp, options) local function lspconfig_setup(lsp, options)
local final_options = table_merge(lspconfig_default_options, options) local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options)
lspconfig[lsp].setup(final_options) lspconfig[lsp].setup(final_options)
end end

View file

@ -1,7 +1,7 @@
-- buffers -- buffer
require("which-key").register({ require("which-key").register({
b = { b = {
name = "buffers", name = "buffer",
b = { "<cmd>Telescope buffers<cr>", "List buffers" }, b = { "<cmd>Telescope buffers<cr>", "List buffers" },
d = { "<cmd>bd<cr>", "Delete buffer" }, d = { "<cmd>bd<cr>", "Delete buffer" },
n = { "<cmd>bnext<cr>", "Next buffer" }, n = { "<cmd>bnext<cr>", "Next buffer" },
@ -9,6 +9,52 @@ require("which-key").register({
}, },
}) })
-- window
require("which-key").register({
w = {
name = "window",
["|"] = { "<C-w>v", "Split window horizontally" },
["-"] = { "<C-w>s", "Split window vertically" },
w = { "<C-w>w", "Switch window" },
d = { "<C-w>c", "Delete window" },
},
}, { prefix = "<leader>" })
-- fast window move
require("which-key").register({
["<C-h>"] = { "<C-w>h", "Move window left" },
["<C-j>"] = { "<C-w>j", "Move window down" },
["<C-k>"] = { "<C-w>k", "Move window up" },
["<C-l>"] = { "<C-w>l", "Move window right" },
})
-- tab
require("which-key").register({
["<tab>"] = {
name = "tab",
["<tab>"] = { "<cmd>tabnew<cr>", "New tab" },
n = { "<cmd>tabnext<cr>", "Next tab" },
p = { "<cmd>tabprevious<cr>", "Previous tab" },
d = { "<cmd>tabclose<cr>", "Close tab" },
},
}, { prefix = "<leader>" })
-- file
require("which-key").register({
f = {
name = "file/find",
n = { "<cmd>enew<cr>", "New file" },
},
}, { prefix = "<leader>" })
-- better descriptions for navigation
require("which-key").register({
["["] = { name = "prev" },
["]"] = { name = "next" },
o = { name = "org" },
x = { name = "diagnostics/quickfix" },
})
-- Clear search with <esc> -- Clear search with <esc>
require("which-key").register({ require("which-key").register({
["<esc>"] = { "<cmd>noh<cr><esc>", "Escape and clear hlsearch", mode = { "n", "i" } }, ["<esc>"] = { "<cmd>noh<cr><esc>", "Escape and clear hlsearch", mode = { "n", "i" } },

View file

@ -1,18 +0,0 @@
require("telescope").load_extension("advanced_git_search")
local advanced_git_search = require("telescope").extensions.advanced_git_search
vim.api.nvim_create_user_command(
"DiffCommitLine",
"lua require('telescope').extensions.advanced_git_search.diff_commit_line()",
{ range = true }
)
require("which-key").register({
g = {
name = "git",
b = { advanced_git_search.diff_branch_file, "diff branch file" },
l = { vim.cmd.DiffCommitLine, "diff commit line", mode = "v" },
f = { advanced_git_search.diff_commit_file, "diff commit file" },
c = { advanced_git_search.search_log_content, "search log content" },
C = { advanced_git_search.search_log_content_file, "search log content current file" },
r = { advanced_git_search.checkout_reflog, "checkout reflog" },
},
}, { prefix = "<leader>" })

View file

@ -1 +1,22 @@
require("gitsigns").setup() require("gitsigns").setup()
require("which-key").register({
["["] = {
h = { "<cmd>Gitsigns prev_hunk<cr>", "Previous hunk" },
},
["]"] = {
h = { "<cmd>Gitsigns next_hunk<cr>", "Next hunk" },
},
})
require("which-key").register({
h = {
name = "hunk",
s = { "<cmd>Gitsigns stage_hunk<cr>", "Stage hunk", mode = { "n", "v" } },
r = { "<cmd>Gitsigns reset_hunk<cr>", "Reset hunk", mode = { "n", "v" } },
S = { "<cmd>Gitsigns stage_buffer<cr>", "Stage buffer" },
R = { "<cmd>Gitsigns reset_buffer<cr>", "Reset buffer" },
u = { "<cmd>Gitsigns undo_stage_hunk<cr>", "Undo stage hunk" },
},
}, { prefix = "<leader>g" })
require("which-key").register({
h = { ":<C-U>Gitsigns select_hunk<cr>", "Gitsigns select hunk" },
}, { prefix = "i", mode = { "o", "x" } })

View file

@ -0,0 +1,195 @@
-- Unless you are still migrating, remove the deprecated commands from v1.x
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
require("neo-tree").setup({
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
popup_border_style = "rounded",
enable_git_status = true,
enable_diagnostics = true,
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
sort_case_insensitive = false, -- used when sorting files and directories in the tree
sort_function = nil, -- use a custom function for sorting files and directories in the tree
-- sort_function = function (a,b)
-- if a.type == b.type then
-- return a.path > b.path
-- else
-- return a.type > b.type
-- end
-- end , -- this sorts files and directories descendantly
default_component_configs = {
container = {
enable_character_fade = true,
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
indent_marker = "",
last_indent_marker = "",
highlight = "NeoTreeIndentMarker",
-- expander config, needed for nesting files
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "",
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon",
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
name = {
trailing_slash = false,
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
git_status = {
symbols = {
-- Change type
added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
deleted = "", -- this can only be used in the git_status source
renamed = "", -- this can only be used in the git_status source
-- Status type
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
},
},
window = {
position = "left",
width = 40,
mapping_options = {
noremap = true,
nowait = true,
},
mappings = {
["<cr>"] = "open",
["<esc>"] = "revert_preview",
["P"] = { "toggle_preview", config = { use_float = false } },
["S"] = "open_split",
["s"] = "open_vsplit",
["t"] = "open_tabnew",
["C"] = "close_node",
["z"] = "close_all_nodes",
["a"] = {
"add",
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none", -- "none", "relative", "absolute"
},
},
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
["d"] = "delete",
["r"] = "rename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
["q"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
},
},
nesting_rules = {},
filesystem = {
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_hidden = true, -- only works on Windows for hidden files/directories
hide_by_name = {
--"node_modules"
},
hide_by_pattern = { -- uses glob style patterns
--"*.meta",
--"*/src/*/tsconfig.json",
},
always_show = { -- remains visible even if other settings would normally hide it
--".gitignored",
},
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
--".DS_Store",
--"thumbs.db"
},
never_show_by_pattern = { -- uses glob style patterns
--".null-ls_*",
},
},
follow_current_file = false, -- This will find and focus the file in the active buffer every
-- time the current file is changed while the tree is open.
group_empty_dirs = false, -- when true, empty folders will be grouped together
hijack_netrw_behavior = "disabled", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
-- "open_current", -- netrw disabled, opening a directory opens within the
-- window like netrw would, regardless of window.position
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
-- instead of relying on nvim autocmd events.
window = {
mappings = {
["<bs>"] = "navigate_up",
["."] = "set_root",
["H"] = "toggle_hidden",
["/"] = "fuzzy_finder",
["D"] = "fuzzy_finder_directory",
["#"] = "fuzzy_sorter", -- fuzzy sorting using the fzy algorithm
["f"] = "filter_on_submit",
["<c-x>"] = "clear_filter",
["[g"] = "prev_git_modified",
["]g"] = "next_git_modified",
},
fuzzy_finder_mappings = { -- define keymaps for filter popup window in fuzzy_finder_mode
["<S-tab>"] = "move_cursor_up",
["<tab>"] = "move_cursor_down",
},
},
},
buffers = {
follow_current_file = true, -- This will find and focus the file in the active buffer every
-- time the current file is changed while the tree is open.
group_empty_dirs = true, -- when true, empty folders will be grouped together
show_unloaded = true,
window = {
mappings = {
["bd"] = "buffer_delete",
["<bs>"] = "navigate_up",
["."] = "set_root",
},
},
},
git_status = {
window = {
position = "float",
mappings = {
["A"] = "git_add_all",
["gu"] = "git_unstage_file",
["ga"] = "git_add_file",
["gr"] = "git_revert_file",
["gc"] = "git_commit",
["gp"] = "git_push",
["gg"] = "git_commit_and_push",
},
},
},
})
require("which-key").register({
t = { "<cmd>Neotree toggle reveal<cr>", "Neotree" },
}, { prefix = "<leader>t", silent = true })

View file

@ -1 +1 @@
require("nvim-surround").setup({}) require("nvim-surround").setup()

View file

@ -1,10 +0,0 @@
-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true
-- empty setup using defaults
require("nvim-tree").setup()
require("which-key").register({
t = { "<cmd>NvimTreeFindFileToggle<cr>", "nvim tree" },
}, { prefix = "<leader>t", silent = true })

View file

@ -1,9 +1,20 @@
require("which-key").register({ require("which-key").register({
f = { f = {
name = "find", name = "file/find",
f = { "<cmd>Telescope find_files<cr>", "find file" }, f = { "<cmd>Telescope find_files<cr>", "Find files" },
l = { "<cmd>Telescope current_buffer_fuzzy_find<cr>", "find line" }, b = { "<cmd>Telescope buffers<cr>", "Find buffers" },
g = { "<cmd>Telescope live_grep<cr>", "live grep" }, r = { "<cmd>Telescope oldfiles<cr>", "Find recent files" },
b = { "<cmd>Telescope buffers<cr>", "find buffer" }, },
s = {
name = "search",
l = { "<cmd>Telescope current_buffer_fuzzy_find<cr>", "Search lines" },
g = { "<cmd>Telescope live_grep<cr>", "Live grep" },
c = { "<cmd>Telescope command_history<cr>", "Command history" },
C = { "<cmd>Telescope commands<cr>", "Commands" },
d = { "<cmd>Telescope diagnostics<cr>", "Diagnostics" },
h = { "<cmd>Telescope help_tags<cr>", "Help tags" },
k = { "<cmd>Telescope keymaps<cr>", "Keymaps" },
s = { "<cmd>Telescope lsp_document_symbols<cr>", "Symbols (Document)" },
S = { "<cmd>Telescope lsp_workspace_symbols<cr>", "Symbols (Workspace)" },
}, },
}, { prefix = "<leader>" }) }, { prefix = "<leader>" })

View file

@ -1,7 +1,7 @@
require("telescope").load_extension("zoxide") require("telescope").load_extension("zoxide")
require("which-key").register({ require("which-key").register({
f = { f = {
name = "find", name = "file/find",
z = { "<cmd>Telescope zoxide list<cr>", "find location" }, z = { "<cmd>Telescope zoxide list<cr>", "Find location (Zoxide)" },
}, },
}, { prefix = "<leader>" }) }, { prefix = "<leader>" })

View file

@ -1 +1 @@
require("todo-comments").setup({}) require("todo-comments").setup()

View file

@ -0,0 +1,38 @@
require("trouble").setup()
require("which-key").register({
x = { "<cmd>TroubleToggle document_diagnostics<cr>", "Document Diagnostics (Trouble)" },
X = { "<cmd>TroubleToggle workspace_diagnostics<cr>", "Workspace Diagnostics (Troule)" },
l = { "<cmd>TroubleToggle loclist<cr>", "Location List (Trouble)" },
q = { "<cmd>TroubleToggle quickfix<cr>", "Quickfix List (Trouble)" },
t = { "<cmd>TodoTrouble<cr>", "Todo (Trouble)" },
T = { "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", "Todo/Fix/Fixme (Trouble)" },
}, { prefix = "<leader>x" })
require("which-key").register({
t = { "<cmd>TodoTelescope<cr>", "Todo" },
}, { prefix = "<leader>s" })
require("which-key").register({
["["] = {
q = {
function()
if require("trouble").is_open() then
require("trouble").previous({ skip_groups = true, jump = true })
else
vim.cmd.cprev()
end
end,
"Previous trouble/quickfix item",
},
},
["]"] = {
q = {
function()
if require("trouble").is_open() then
require("trouble").next({ skip_groups = true, jump = true })
else
vim.cmd.cnext()
end
end,
"Next trouble/quickfix item",
},
},
})

View file

@ -0,0 +1,3 @@
require("twilight").setup({
context = 20,
})

View file

@ -0,0 +1,2 @@
vim.g.startuptime_tries = 10
vim.g.startuptime_exe_path = "vim"

View file

@ -0,0 +1,4 @@
require("zen-mode").setup()
require("which-key").register({
z = { "<cmd>ZenMode<cr>", "Zen mode" },
}, { prefix = "<leader>t" })

View file

@ -10,7 +10,7 @@
./openconnect.nix ./openconnect.nix
./picom.nix ./picom.nix
./printing.nix ./printing.nix
./redshift.nix ./gammastep.nix
./wireguard.nix ./wireguard.nix
]; ];
} }

View file

@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.my.services.gammastep;
in
{
options.my.services.gammastep.enable = mkEnableOption "gammastep";
config = lib.mkIf cfg.enable {
home-manager.users.moritz.services.gammastep = {
enable = true;
latitude = 52.3;
longitude = 12.4;
};
};
}

View file

@ -1,17 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.my.services.redshift;
in
{
options.my.services.redshift.enable = mkEnableOption "redshift";
config = lib.mkIf cfg.enable {
services.redshift.enable = true;
location = {
latitude = 52.3;
longitude = 12.4;
};
};
}