summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortalha <talha@talhaamir.xyz>2023-12-14 11:49:47 +0500
committertalha <talha@talhaamir.xyz>2023-12-14 11:49:47 +0500
commitdb929434fa2f29e5674a5f24d71901b4fa458363 (patch)
tree850a02a7c945a1a25040ae289a62385e6d0f47f8
parent27c1b5b9a5cadf1d1331e4cefeaa9c8a73707b26 (diff)
Fix autoreload, added autocmd:
- Added autoreload to fix reloading when file changed externally - Added autocmd to format python files on save
-rw-r--r--after/plugin/colors.lua16
-rw-r--r--after/plugin/lsp.lua1
-rw-r--r--lua/talha/autocmds.lua19
-rw-r--r--lua/talha/init.lua1
-rw-r--r--lua/talha/packer.lua2
-rw-r--r--lua/talha/set.lua2
6 files changed, 24 insertions, 17 deletions
diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua
index 37afa2f..b32344f 100644
--- a/after/plugin/colors.lua
+++ b/after/plugin/colors.lua
@@ -23,18 +23,4 @@ require("gruvbox").setup({
transparent_mode = false,
})
-vim.cmd("colorscheme gruvbox")
-
-function SetFocusColors(mode)
- if mode == 'light' then
- vim.opt.cursorline = false
- vim.opt.colorcolumn = '0'
- vim.cmd("colorscheme paper")
- end
-
- if mode == 'dark' then
- vim.opt.cursorline = true
- vim.opt.colorcolumn = '120'
- vim.cmd("colorscheme atlas")
- end
-end
+vim.cmd("colorscheme nightfly")
diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua
index f8dae3c..642328c 100644
--- a/after/plugin/lsp.lua
+++ b/after/plugin/lsp.lua
@@ -20,6 +20,7 @@ lsp.on_attach(function(client, bufnr)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
+ lsp.buffer_autoformat()
end)
lsp.setup()
diff --git a/lua/talha/autocmds.lua b/lua/talha/autocmds.lua
new file mode 100644
index 0000000..a892fa2
--- /dev/null
+++ b/lua/talha/autocmds.lua
@@ -0,0 +1,19 @@
+local autocmd_group = vim.api.nvim_create_augroup("Custom auto-commands", { clear = true })
+
+vim.api.nvim_create_autocmd({ "BufWritePost" }, {
+ pattern = { "*.py" },
+ desc = "Auto-format python files after saving",
+ callback = function()
+ local filename = vim.api.nvim_buf_get_name(0)
+ vim.cmd(":silent !autopep8 -i " .. filename)
+ vim.cmd(":silent !isort " .. filename)
+ end,
+ group = autocmd_group,
+})
+
+vim.api.nvim_create_autocmd({ "CursorHold" }, {
+ desc = "reload the file on changes",
+ command = "checktime",
+ group = autocmd_group,
+})
+
diff --git a/lua/talha/init.lua b/lua/talha/init.lua
index 2babaca..5dabc12 100644
--- a/lua/talha/init.lua
+++ b/lua/talha/init.lua
@@ -1,4 +1,5 @@
require("talha.remap")
require("talha.set")
require("talha.functions")
+require("talha.autocmds")
diff --git a/lua/talha/packer.lua b/lua/talha/packer.lua
index eea7520..7b97acf 100644
--- a/lua/talha/packer.lua
+++ b/lua/talha/packer.lua
@@ -15,6 +15,8 @@ return require('packer').startup(function(use)
-- colorschemes
use { "ellisonleao/gruvbox.nvim" }
+ use {"bluz71/vim-nightfly-colors"}
+ use {"dasupradyumna/midnight.nvim"}
use { "theprimeagen/harpoon" }
diff --git a/lua/talha/set.lua b/lua/talha/set.lua
index 0366b03..814a837 100644
--- a/lua/talha/set.lua
+++ b/lua/talha/set.lua
@@ -24,9 +24,7 @@ op.cursorline = true
op.scrolloff = 8
--- autoreload a file after inactivity
op.autoread = true
-vim.api.nvim_command([[au CursorHold * checktime]])
op.updatetime = 50