aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/user
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/user')
-rw-r--r--.config/nvim/lua/user/keys.lua11
-rw-r--r--.config/nvim/lua/user/mods.lua204
-rw-r--r--.config/nvim/lua/user/pack.lua27
3 files changed, 223 insertions, 19 deletions
diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua
index e5e7099..a20b0ea 100644
--- a/.config/nvim/lua/user/keys.lua
+++ b/.config/nvim/lua/user/keys.lua
@@ -170,7 +170,8 @@ map("i", "<C-l>", "<Del>")
map("n", "<leader><C-l>", "<Cmd>!clear<CR>")
-- Change file to an executable
-map("n", "<leader>x", ":!chmod +x %<CR>")
+map("n", "<Leader>x", ":lua require('user.mods').Toggle_executable()<CR> | :echom ('Toggle executable')<CR> | :sl! | echo ('')<CR>")
+--map("n", "<leader>x", ":!chmod +x %<CR>")
-- Paste without replace clipboard
map("v", "p", '"_dP')
@@ -291,8 +292,8 @@ map("n", "<leader>gm", ":Gmove<Space>")
--end
-- Telescope
-map("n", "<leader>ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files
-map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option
+map("n", "<leader>ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = false } end) -- find all files
+--map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option
map("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>")
map("n", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>")
map("n", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>")
@@ -310,6 +311,8 @@ map("n", "<leader>fs", [[<Cmd>lua require'plugins.telescope'.find_scripts()<CR>]
map("n", "<leader>fw", [[<Cmd>lua require'plugins.telescope'.find_projects()<CR>]]) -- find projects
map("n", "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>") -- find media files
map("n", "<leader>fi", "<cmd>lua require('telescope').extensions.notify.notify({})<cr>") -- find notifications
+--map("n", "<leader>f/", "<cmd>lua require('plugins.telescope').curbuf()<cr>") -- find files with hidden option
+map("n", "<leader>fF", ":cd %:p:h<CR>:pwd<CR><cmd>lua require('user.mods').findFilesInCwd()<CR>", { noremap = true, silent = true, desc = "Find files in cwd" })
-- FZF
map("n", "<leader>fz", "<cmd>lua require('fzf-lua').files()<CR>")
@@ -396,7 +399,7 @@ map("n", "<leader>dq", function()
require("nvim-dap-virtual-text").refresh()
end, { desc = "Terminate Debug" })
map("n", "<leader>dc", function()
- require("telescope").extensions.dap.commands()
+ require("telescope").extensions.dap.commands()
end, { desc = "DAP-Telescope: Commands" })
--vim.keymap.set("n", "<leader>B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
--vim.keymap.set("v", "<leader>B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
diff --git a/.config/nvim/lua/user/mods.lua b/.config/nvim/lua/user/mods.lua
index 725ca6e..f00621d 100644
--- a/.config/nvim/lua/user/mods.lua
+++ b/.config/nvim/lua/user/mods.lua
@@ -40,7 +40,8 @@ require("null-ls").setup({
buffer = bufnr,
callback = function()
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
- vim.lsp.buf.formatting_seq_sync()
+ --vim.lsp.buf.formatting_seq_sync()
+ vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
@@ -157,6 +158,38 @@ end
--autocmd User RooterChDir :sleep! | call LogTrigger(timer) | call ConfigureChDir()
--]])
+function M.findFilesInCwd()
+ vim.cmd("let g:rooter_manual_only = 1") -- Toggle the rooter plugin
+ require("plugins.telescope").findhere()
+ vim.defer_fn(function()
+ vim.cmd("let g:rooter_manual_only = 0") -- Change back to automatic rooter
+ end, 100)
+end
+--function M.findFilesInCwd()
+-- vim.cmd("let g:rooter_manual_only = 1") -- Toggle the rooter plugin
+-- require("plugins.telescope").findhere()
+-- --vim.cmd("let g:rooter_manual_only = 0") -- Change back to automatic rooter
+--end
+
+--------------------------------------------------
+
+-- Toggle the executable permission
+function M.Toggle_executable()
+ local current_file = vim.fn.expand('%:p')
+ local executable = vim.fn.executable(current_file) == 1
+
+ if executable then
+ -- File is executable, unset the executable permission
+ vim.fn.system('chmod -x ' .. current_file)
+ --print(current_file .. ' is no longer executable.')
+ print("No longer executable")
+ else
+ -- File is not executable, set the executable permission
+ vim.fn.system('chmod +x ' .. current_file)
+ --print(current_file .. ' is now executable.')
+ print("Now executable")
+ end
+end
--------------------------------------------------
@@ -233,7 +266,7 @@ function M.update_tmux_status()
file:close()
if nvim_running then
-- Neovim is running, update the mode file and refresh tmux
- VI_MODE = "" -- Clear VI_MODE to show Neovim mode
+ VI_MODE = "" -- Clear VI_MODE to show Neovim mode
vim.cmd("silent !tmux refresh-client -S")
end
---- Force tmux to update the status
@@ -253,14 +286,163 @@ vim.cmd([[
-- Add autocmd for <esc>
-- Add autocmd to check when tmux switches panes/windows
- --autocmd InsertLeave,InsertEnter * lua require("user.mods").update_tmux_status()
- --autocmd BufEnter * lua require("user.mods").update_tmux_status()
- --autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status()
-
- --autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status()
- --autocmd VimResized * lua require("user.mods").update_tmux_status()
- --autocmd FocusGained * lua require("user.mods").update_tmux_status()
- --autocmd FocusLost * lua require("user.mods").update_tmux_status()
- --autocmd CmdwinEnter,CmdwinLeave * lua require("user.mods").update_tmux_status()
+--autocmd InsertLeave,InsertEnter * lua require("user.mods").update_tmux_status()
+--autocmd BufEnter * lua require("user.mods").update_tmux_status()
+--autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status()
+
+--autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status()
+--autocmd VimResized * lua require("user.mods").update_tmux_status()
+--autocmd FocusGained * lua require("user.mods").update_tmux_status()
+--autocmd FocusLost * lua require("user.mods").update_tmux_status()
+--autocmd CmdwinEnter,CmdwinLeave * lua require("user.mods").update_tmux_status()
--------------------------------------------------
+
+-- function OpenEmulatorList()
+-- local emulatorsBuffer = vim.api.nvim_create_buf(false, true)
+-- vim.api.nvim_buf_set_lines(emulatorsBuffer, 0, 0, true, {"Some text"})
+-- vim.api.nvim_open_win(
+-- emulatorsBuffer,
+-- false,
+-- {
+-- relative='win', row=3, col=3, width=12, height=3
+-- }
+-- )
+-- end
+--
+-- vim.api.nvim_create_user_command('OpenEmulators', OpenEmulatorList, {})
+
+
+
+--local api = vim.api
+--local fn = vim.fn
+--local cmd = vim.cmd
+--
+--local function bufremove(opts)
+-- local target_buf_id = api.nvim_get_current_buf()
+--
+-- -- Do nothing if buffer is in modified state.
+-- if not opts.force and api.nvim_buf_get_option(target_buf_id, 'modified') then
+-- return false
+-- end
+--
+-- -- Hide target buffer from all windows.
+-- vim.tbl_map(function(win_id)
+-- win_id = win_id or 0
+--
+-- local current_buf_id = api.nvim_win_get_buf(win_id)
+--
+-- api.nvim_win_call(win_id, function()
+-- -- Try using alternate buffer
+-- local alt_buf_id = fn.bufnr('#')
+-- if alt_buf_id ~= current_buf_id and fn.buflisted(alt_buf_id) == 1 then
+-- api.nvim_win_set_buf(win_id, alt_buf_id)
+-- return
+-- end
+--
+-- -- Try using previous buffer
+-- cmd('bprevious')
+-- if current_buf_id ~= api.nvim_win_get_buf(win_id) then
+-- return
+-- end
+--
+-- -- Create new listed scratch buffer
+-- local new_buf = api.nvim_create_buf(true, true)
+-- api.nvim_win_set_buf(win_id, new_buf)
+-- end)
+--
+-- return true
+-- end, fn.win_findbuf(target_buf_id))
+--
+-- cmd(string.format('bdelete%s %d', opts.force and '!' or '', target_buf_id))
+--end
+--
+---- Assign bufremove to a global variable
+--_G.bufremove = bufremove
+
+--vim.cmd([[
+-- augroup NvimTreeDelete
+-- autocmd!
+-- autocmd FileType NvimTree lua require('user.mods').enew_on_delete()
+-- augroup END
+--]])
+--
+--function M.enew_on_delete()
+-- if vim.bo.buftype == 'nofile' then
+-- vim.cmd('enew')
+-- end
+--end
+
+-- Update Neovim
+--function M.Update_neovim()
+-- -- Run the commands to download and extract the latest version
+-- os.execute("curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz")
+-- os.execute("tar xzvf nvim-linux64.tar.gz")
+-- -- Replace the existing Neovim installation with the new version
+-- os.execute("rm -rf $HOME/.local/bin/nvim")
+-- os.execute("mv nvim-linux64 $HOME/.local/bin/nvim")
+--
+-- -- Clean up the downloaded file
+-- os.execute("rm nvim-linux64.tar.gz")
+--
+-- -- Print a message to indicate the update is complete
+-- print("Neovim has been updated to the latest version.")
+--end
+--
+---- Bind a keymap to the update_neovim function (optional)
+--vim.api.nvim_set_keymap('n', '<leader>u', '<cmd> lua require("user.mods").Update_neovim()<CR>', { noremap = true, silent = true })
+
+-- Define a function to create a floating window and run the update process inside it
+function M.Update_neovim()
+ -- Create a new floating window
+ local bufnr, winid = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_open_win(bufnr, true, {
+ relative = "editor",
+ width = 80,
+ height = 20,
+ row = 2,
+ col = 2,
+ style = "minimal",
+ border = "single",
+ })
+
+ -- Function to append a line to the buffer in the floating window
+ local function append_line(line)
+ vim.api.nvim_buf_set_option(bufnr, "modifiable", true)
+ vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { line })
+ vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
+ end
+
+ -- Download the latest version of Neovim
+ append_line("Downloading the latest version of Neovim...")
+ os.execute(
+ "curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz")
+ append_line("Download complete.")
+
+ -- Extract the downloaded archive
+ append_line("Extracting the downloaded archive...")
+ os.execute("tar xzvf nvim-linux64.tar.gz")
+ append_line("Extraction complete.")
+
+ -- Replace the existing Neovim installation with the new version
+ append_line("Replacing the existing Neovim installation...")
+ os.execute("rm -rf $HOME/nvim")
+ os.execute("mv nvim-linux64 $HOME/nvim")
+ append_line("Update complete.")
+
+ -- Clean up the downloaded file
+ append_line("Cleaning up the downloaded file...")
+ os.execute("rm nvim-linux64.tar.gz")
+ append_line("Cleanup complete.")
+
+ -- Close the floating window after a delay
+ vim.defer_fn(function()
+ vim.api.nvim_win_close(winid, true)
+ end, 5000) -- Adjust the delay as needed
+end
+
+-- Bind a keymap to the update_neovim function (optional)
+vim.api.nvim_set_keymap('n', '<leader>u', '<cmd> lua require("user.mods").Update_neovim()<CR>',
+ { noremap = true, silent = true })
+
+
return M
diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua
index e416baf..d2fad3c 100644
--- a/.config/nvim/lua/user/pack.lua
+++ b/.config/nvim/lua/user/pack.lua
@@ -63,8 +63,8 @@ return packer.startup(function(use)
-- lsp
use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters
- use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together
use("neovim/nvim-lspconfig") -- Collection of LSP configs
+ use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together
use({
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
config = function()
@@ -167,7 +167,7 @@ return packer.startup(function(use)
use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }) -- Handy unix commands inside Vim (Rename, Move etc.)
--use("tpope/vim-surround") --
--use("tpope/vim-obsession") --
- --use("tpope/vim-unimpaired") --
+ use("tpope/vim-unimpaired") --
--use("vimpostor/vim-tpipeline") --
--use("nathom/filetype.nvim") --
use({ "myusuf3/numbers.vim", --
@@ -200,7 +200,11 @@ return packer.startup(function(use)
"folke/trouble.nvim",
requires = "nvim-tree/nvim-web-devicons",
})
- use("airblade/vim-rooter") --
+ use({ "airblade/vim-rooter", --
+ --vim.cmd("let g:rooter_change_directory_for_non_project_files = ''"),
+ --vim.cmd("let g:rooter_change_directory_for_non_project_files = 'current'")
+ })
+
--use("vim-test/vim-test") --
--use({
-- "rcarriga/vim-ultest", --
@@ -276,7 +280,7 @@ return packer.startup(function(use)
})
use("rcarriga/nvim-notify") -- Notification plugin
use("karb94/neoscroll.nvim") -- Faster/smooth scrolling
- use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client
+ --use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client
use({
'norcalli/nvim-colorizer.lua', -- colorize hexa and rgb strings
cmd = { 'ColorizerToggle', 'ColorizerAttachToBuffer' },
@@ -329,6 +333,21 @@ return packer.startup(function(use)
end,
})
use({
+ "akinsho/flutter-tools.nvim",
+ requires = {
+ "nvim-lua/plenary.nvim",
+ "stevearc/dressing.nvim", -- optional for vim.ui.select
+ },
+ config = function()
+ require('flutter-tools').setup({
+ debugger = {
+ enabled = true,
+ run_via_dap = true,
+ },
+ })
+ end,
+ })
+ use({
"iamcco/markdown-preview.nvim", -- Markdown Preview
run = function() vim.fn["mkdp#util#install"]() end,
})