summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2022-10-31 23:06:24 +0100
committerMike Vink <mike1994vink@gmail.com>2022-10-31 23:06:24 +0100
commit91fb3eff2cf2cdc16a0bef278cd7fb64cde796b8 (patch)
tree5ff4151cd7122bfee03a2dbd6b11b9a90090de62
parent879650c4a49330425e0aad1bb79969dc0e11399b (diff)
add reload
-rw-r--r--home.nix2
-rw-r--r--neovim/init.lua2
-rw-r--r--neovim/lua/vimrc.lua20
3 files changed, 20 insertions, 4 deletions
diff --git a/home.nix b/home.nix
index 48158b5..cde7d32 100644
--- a/home.nix
+++ b/home.nix
@@ -16,7 +16,7 @@
stow
(nerdfonts.override { fonts = [ "FiraCode" ]; })
- firefox
+ firefox-wayland
swaylock
swayidle
diff --git a/neovim/init.lua b/neovim/init.lua
index 2daa115..c036f59 100644
--- a/neovim/init.lua
+++ b/neovim/init.lua
@@ -151,7 +151,7 @@ vim.api.nvim_set_keymap(
":call buffers#visual_selection('replace', '')<CR>",
{ silent = true, noremap = true }
)
-vim.cmd([[command -nargs=1 -complete=file E execute('silent! !mkdir -p "$(dirname "<args>")"') <Bar> e <args>]])
+vim.cmd([[command! -nargs=1 -complete=file E execute('silent! !mkdir -p "$(dirname "<args>")"') <Bar> e <args>]])
-- wiping buffers and wiping nofile-buffers
vim.cmd([[command! -nargs=1 -bang Bdeletes :call buffers#wipe_matching('<args>', <q-bang>)]])
vim.cmd([[command! Bdnonexisting :call buffers#wipe_nonexisting_files()]])
diff --git a/neovim/lua/vimrc.lua b/neovim/lua/vimrc.lua
index f8ae213..587f9e2 100644
--- a/neovim/lua/vimrc.lua
+++ b/neovim/lua/vimrc.lua
@@ -16,7 +16,9 @@ function M.setup_treesitter()
return
end
- assert(vim.fn.exists(":TSInstall") == 0, "TreeSitter is already configured.")
+ if vim.fn.exists(":TSInstall") == 1 then
+ return vim.notify "TreeSitter is already configured."
+ end
-- vim.cmd([[packadd nvim-treesitter]])
require 'nvim-treesitter.configs'.setup {
@@ -172,6 +174,20 @@ M.reload_package_complete = function(_, _, _)
return 'hi'
end
+M.reload_packages_and_init = function()
+ for name,_ in pairs(package.loaded) do
+ if name:match('^vimrc') then
+ package.loaded[name] = nil
+ end
+ end
+
+ vim.opt.runtimepath:prepend({ os.getenv("NVIM_RELOAD_PATH"), os.getenv("NVIM_RELOAD_PATH") .. [[/lua]] })
+ dofile(os.getenv("NVIM_RELOAD_PATH") .. [[/init.lua]])
+ vim.opt.runtimepath:remove({ os.getenv("NVIM_RELOAD_PATH"), os.getenv("NVIM_RELOAD_PATH") .. [[/lua]] })
+
+ vim.notify("Reloaded vim", vim.log.levels.INFO)
+end
+
M.reload_package = function(name)
P([[name=]] .. name)
if package.loaded[name] == nil then
@@ -183,7 +199,7 @@ M.reload_package = function(name)
end
vim.cmd(
- [[command! -complete=custom,reloadpackage#complete -nargs=1 LuaReload :lua require('vimrc').reload_package(<q-args>)]]
+ [[command! LuaReload :lua require('vimrc').reload_packages_and_init()]]
)
M.activate_reload_on_write = function(name)