diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index ff1101f..e5780de 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -12,17 +12,25 @@ vim.api.nvim_create_autocmd("VimLeave", { end, }) +vim.api.nvim_create_autocmd("FileType", { + pattern = "nix", + callback = function() + vim.bo.tabstop = 2 + vim.bo.shiftwidth = 2 + vim.bo.expandtab = true + end, +}) + vim.api.nvim_create_augroup("RememberFolds", { clear = true }) -vim.api.nvim_create_autocmd({"BufWinLeave"}, { - group = "RememberFolds", - pattern = "*", - command = "silent! mkview", +vim.api.nvim_create_autocmd({ "BufWinLeave" }, { + group = "RememberFolds", + pattern = "*", + command = "silent! mkview", }) -vim.api.nvim_create_autocmd({"BufWinEnter"}, { - group = "RememberFolds", - pattern = "*", - command = "silent! loadview", +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + group = "RememberFolds", + pattern = "*", + command = "silent! loadview", }) - diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index d836f36..2a64be9 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -59,18 +59,18 @@ vim.keymap.set('n', 'ocp', ':e ~/.config/nvim/lua/plugins/misc.lua`. vim.keymap.set('n', 'ocf', ':e ~/.config/nvim/lua/utils/functions.lua`.zz') vim.keymap.set('n', 'oca', ':e ~/.config/nvim/lua/utils/after.lua`.zz') vim.keymap.set('n', 'oq', ':e ~/synced/brainstore/input.txt`.zz') -vim.keymap.set('n', 'ohh', ':e ~/configuration/nixos/users/' .. conf.user .. '/home.nix`.zz') -vim.keymap.set('n', 'op', ':e ~/configuration/nixos/users/' .. conf.user .. '/packages.nix`.zz') -vim.keymap.set('n', 'on', ':e ~/configuration/nixos/configuration.nix`.zz') -vim.keymap.set('n', 'om', ':e ~/configuration/nixos/modules') -vim.keymap.set('n', 'ow', ':e ~/synced/brainstore/waste.txt') -vim.keymap.set('n', 'oho', ':e ~/configuration/nixos/hosts') -vim.keymap.set('n', 'os', ':e ~/configuration/nixos/modules/server') vim.keymap.set('n', 'ot', ':e ~/synced/brainstore/todos/todo.txt`.zz') vim.keymap.set('n', 'od', ':e ~/synced/brainstore/todos/done.txt`.zz') vim.keymap.set('n', 'ou', ':e ~/projects/university/' .. conf.season .. '/input.txt`.zz') vim.keymap.set('n', 'oz', ':e ~/.zshrc`.zz') vim.keymap.set('n', 'oaa', ':e ~/.common_shell`.zz') +vim.keymap.set('n', 'ow', ':e ~/synced/brainstore/waste.txt') + +vim.keymap.set('n', 'ohh', ':e ~/nixos/user/home.nix`.zz') +vim.keymap.set('n', 'op', ':e ~/nixos/user/packages.nix`.zz') +vim.keymap.set('n', 'on', ':e ~/nixos/configuration.nix`.zz') +vim.keymap.set('n', 'om', ':e ~/nixos/modules/') +vim.keymap.set('n', 'oho', ':e ~/nixos/hosts') vim.keymap.set('n', 'll', ':Lazy') @@ -201,8 +201,8 @@ vim.keymap.set("n", "r", vim.fn.system(cmd) if vim.v.shell_error == 0 then local git_root = vim.fn.systemlist('git -C ' .. - vim.fn.fnameescape(current_file) .. ' rev-parse --show-toplevel') - [1] + vim.fn.fnameescape(current_file) .. ' rev-parse --show-toplevel') + [1] vim.cmd('cd ' .. vim.fn.fnameescape(git_root)) else vim.cmd('cd ' .. vim.fn.fnameescape(current_file)) @@ -214,8 +214,8 @@ vim.keymap.set('n', 'ok', function() local current_date = os.date("%Y-%m-%d") local week_number = os.date("%V") local day_of_week = os.date("%a") - local path = "~/synced/brainstore/calendar/calendar_" .. os.date("%Y") .. ".txt" + local path = "~/storage/notes/calendar/calendar_" .. os.date("%Y") .. ".txt" local keys = ":e " .. - path .. "/" .. current_date .. " w" .. tonumber(week_number) .. " " .. day_of_week .. "$" + path .. "/" .. current_date .. " w" .. tonumber(week_number) .. " " .. day_of_week .. "$" vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(keys, true, false, true), 'n', true) end) diff --git a/lua/config/options.lua b/lua/config/options.lua index 9876cc8..f11e46e 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -8,12 +8,14 @@ vim.o.mouse = ""; -- Turn on undofile vim.o.udf = true; +vim.opt.undolevels = 10000 -- Default is 1000 +vim.opt.undoreload = 10000 -- Enable more colors vim.opt.termguicolors = true -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 +--vim.g.loaded_netrw = 1 +--vim.g.loaded_netrwPlugin = 1 vim.opt.signcolumn = "yes" @@ -22,7 +24,3 @@ vim.opt.foldmethod = "expr" vim.opt.foldexpr = "nvim_treesitter#foldexpr()" vim.opt.foldlevelstart = 99 -- open all folds by default vim.opt.fillchars = "fold:╌" - --- 3. Persist folds using mkview/loadview - - diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index c50f47b..7c7d4ea 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -58,9 +58,17 @@ return { config = function() require("mason").setup() + -- Workaround for local zls + local servers_modified = servers + for i, v in ipairs(servers_modified) do + if v == "zls" then + table.remove(servers_modified, i) + break + end + end require("mason-lspconfig").setup({ - ensure_installed = servers, + ensure_installed = servers_modified, automatic_installation = true, }) end, @@ -90,9 +98,9 @@ return { { name = "nvim_lsp" }, { name = "luasnip" }, }, { - { name = "buffer" }, - { name = "path" }, - }), + { name = "buffer" }, + { name = "path" }, + }), }) end }, @@ -135,11 +143,11 @@ return { vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) --vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) - vim.keymap.set("n", "lq", vim.diagnostic.setloclist, opts) + -- vim.keymap.set("n", "lq", vim.diagnostic.setloclist, opts) - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set("n", "wl", function() + vim.keymap.set("n", "lwa", vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "lwr", vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set("n", "lwl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts) diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua index 0c82c33..4aebd0d 100644 --- a/lua/plugins/misc.lua +++ b/lua/plugins/misc.lua @@ -1,4 +1,3 @@ - return { { "ThePrimeagen/harpoon", diff --git a/lua/plugins/nvimtree.lua b/lua/plugins/nvimtree.lua index 46dbac4..518749c 100644 --- a/lua/plugins/nvimtree.lua +++ b/lua/plugins/nvimtree.lua @@ -1,5 +1,6 @@ return { "nvim-tree/nvim-tree.lua", + cmd = {"NvimTreeOpen"}, keys = { { "e", function() require("nvim-tree.api").tree.toggle({ diff --git a/lua/utils/after.lua b/lua/utils/after.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/utils/functions.lua b/lua/utils/functions.lua index 341f554..cae2091 100644 --- a/lua/utils/functions.lua +++ b/lua/utils/functions.lua @@ -63,7 +63,7 @@ function M.get_lsp_servers() if vim.fn.executable("nix") == 1 then table.insert(servers, "nil_ls") else - warn_once("nix", "[mason] Skipping nil_ls (nix not found)") + warn_once("nix", "[mason] Skipping nil_ls and nixfmt (nix not found)") end table.insert(servers, "rust_analyzer") else @@ -75,6 +75,11 @@ function M.get_lsp_servers() else warn_once("deno", "[mason] Skipping denols (deno not found)") end + + -- Only configure zig when in local environment + if vim.fn.executable("zls") == 1 then + table.insert(servers, "zls") + end end populate_servers()