From bdd0cc0932cbae49123858c07df0a70d32c8ea1f Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 26 Oct 2023 23:03:15 +0200 Subject: Fixed mapping for formatting and clang related config --- lua/plugins/lsp.lua | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 8884599..b081cb4 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -85,7 +85,7 @@ if not vim.g.lsp_setup_done then map('n', 'gt', "lua require('goto-preview').goto_preview_type_definition()") map('n', 'gn', 'lua vim.lsp.buf.rename()') map('n', 'ga', 'lua vim.lsp.buf.code_action()') - map('n', 'gf', 'lua vim.lsp.buf.formatting()') + map('n', 'gf', 'lua vim.lsp.buf.format()') map('n', 'go', 'lua vim.diagnostic.open_float()') map('n', 'go', ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") map('n', 'gq', 'lua vim.diagnostic.setloclist()') @@ -122,19 +122,19 @@ if not vim.g.lsp_setup_done then -- Open float for diagnostics automatically vim.cmd([[ -augroup OpenFloat + augroup OpenFloat " autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) autocmd CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) -augroup END -]]) + augroup END + ]]) -- Suppress error messages from lang servers vim.lsp.set_log_level('debug') local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.offsetEncoding = { 'utf-16' } + capabilities.offsetEncoding = { 'utf-8', 'utf-16' } local function prefer_null_ls_fmt(client) client.server_capabilities.documentHighlightProvider = true @@ -142,16 +142,24 @@ augroup END on_attach(client) end - local cmp_nvim_lsp = require('cmp_nvim_lsp') + --local cmp_nvim_lsp = require('cmp_nvim_lsp') local servers = { asm_lsp = {}, bashls = {}, clangd = { on_attach = on_attach, - capabilities = cmp_nvim_lsp.default_capabilities(), - cmd = { - 'clangd', - '--offset-encoding=utf-16', + capabilites = capabilities, + cmd = { 'clangd', '--offset-encoding=utf-16', '--cross-file-rename', '--header-insertion=never', '--suggest-missing-includes' }, + init_options = { + clangdFileStatus = true, + }, + root_files = { + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.ac', -- AutoTools }, }, cssls = { filetypes = { 'css', 'scss', 'less', 'sass' }, root_dir = lspconfig.util.root_pattern('package.json', '.git') }, -- ghcide = {}, @@ -316,7 +324,13 @@ augroup END builtins.formatting.shellharden, builtins.formatting.trim_whitespace.with({ filetypes = { 'tmux', 'teal', 'zsh' } }), -- builtins.formatting.beautysh, builtins.formatting.beautysh.with({ filetypes = 'zsh' }), - builtins.formatting.clang_format, + builtins.formatting.clang_format.with({ + filetypes = { 'c', 'cpp', 'cs', 'java', 'cuda', 'proto' }, + extra_args = { + '--style', + '{BasedOnStyle: Google, IndentWidth: 4, BreakBeforeBinaryOperators: NonAssignment, AllowShortFunctionsOnASingleLine: None}', + }, + }), builtins.formatting.rustfmt, builtins.formatting.sql_formatter, -- null_ls.builtins.formatting.cmake_format, -- cgit v1.2.3 From e2ced44967b24c628e9c69be83c1d4124886fdf4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 26 Oct 2023 23:04:14 +0200 Subject: Fixed find_books() not opening recent books --- lua/plugins/telescope.lua | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 8d8622f..5b9717b 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -443,7 +443,7 @@ function M.find_books() local recent_books_file = recent_books_directory .. 'recent_books.txt' local search_cmd = 'find ' .. vim.fn.expand(search_dir) .. ' -type d -o -type f -maxdepth 1' - local recent_books = vim.fn.systemlist('cat ' .. recent_books_file) + local recent_books = vim.fn.readfile(recent_books_file) local search_results = vim.fn.systemlist(search_cmd) local results = {} @@ -476,27 +476,16 @@ function M.find_books() if entry ~= nil then local path = entry.value - -- Handle selecting a recent book entry separately - if vim.fn.matchstr(path, '^Recent Books: ') ~= '' then - -- Extract the path of the selected recent book - path = vim.fn.matchstr(path, '^Recent Books: (.*)$') - end - actions.close(prompt_bufnr, false) - - -- Debugging statement to print the selected path - print('Selected Entry: ' .. path) - -- Determine whether it's a directory or a file local is_directory = vim.fn.isdirectory(path) if is_directory then -- It's a directory, navigate to it in the current buffer vim.cmd('e ' .. path) - print('Selected directory: ' .. path) else - -- It's a file, do something with it (open it, for example) - print('Selected file: ' .. path) + -- It's a file, open it + vim.cmd('edit ' .. path) end end end) -- cgit v1.2.3 From 00132fc7bbd88f59cd96dff7704e1463ae9b5cba Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 26 Oct 2023 23:04:45 +0200 Subject: Telescope find_files f. to find hidden files = true --- lua/user/keys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 53811a6..b7a4cfe 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -275,7 +275,7 @@ map('n', 'gm', ':Gmove') map('n', 'ff', ":cd %:p:h:pwdlua require('telescope.builtin').find_files()") -- find files with hidden option map('n', 'fF', ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = 'Find files in cwd' }) map('n', 'f.', function() - require('telescope.builtin').find_files({ hidden = false, no_ignore = true }) + require('telescope.builtin').find_files({ hidden = true, no_ignore = true }) end) -- find all files map('n', 'fg', "lua require('telescope.builtin').live_grep()") map('n', 'fb', "lua require('telescope.builtin').buffers()") -- cgit v1.2.3 From bb9f2f87380dd8fa5d626865288a2af7fa34b092 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 26 Oct 2023 23:15:58 +0200 Subject: Changed a few color foregrounds to black --- lua/plugins/heirline.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index a5cd2bf..11356d9 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -91,7 +91,7 @@ local ViMode = { return ' %2(' .. self.mode_names[self.mode] .. '%) ' end, hl = function(self) - return { fg = 'darkgray', bg = self.mode_color, bold = true } + return { fg = 'colors.black', bg = self.mode_color, bold = true } end, update = { 'ModeChanged', @@ -778,7 +778,7 @@ FileInfoBlock = utils.surround({ '', '' }, function(self) return self:mode_color() end, { FileInfoBlock, Space, hl = { bg = colors.gray, force = true } }) -Ruler = utils.surround({ '', '' }, colors.gray, { Ruler, hl = { fg = colors.gray, force = true } }) +Ruler = utils.surround({ '', '' }, colors.black, { Ruler, hl = { fg = colors.black, force = true } }) local left = { { RightSpace, hl = { bg = colors.nobg, force = true } }, -- cgit v1.2.3 From 9f0e36631257ca104d3e9f2e4caf0041a37a08f8 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 30 Oct 2023 22:23:52 +0200 Subject: Changed foreground color for ViMode and Ruler to black --- lua/plugins/heirline.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 11356d9..c41aff3 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -776,13 +776,19 @@ end, { Space, LSPActive, hl = { bg = colors.darkgray, force = true } }) FileInfoBlock = utils.surround({ '', '' }, function(self) return self:mode_color() -end, { FileInfoBlock, Space, hl = { bg = colors.gray, force = true } }) +end, { FileInfoBlock, Space, hl = { bg = colors.black, force = true } }) -Ruler = utils.surround({ '', '' }, colors.black, { Ruler, hl = { fg = colors.black, force = true } }) +ViMode = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { ViMode, hl = { fg = colors.black, force = true } }) + +Ruler = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { Ruler, hl = { fg = colors.black, force = true } }) local left = { { RightSpace, hl = { bg = colors.nobg, force = true } }, - { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { ViMode, hl = { bg = utils.get_highlight('statusline').bg, bold = false } }, { LeftSpace, hl = { bg = colors.nobg, force = true } }, { Space, hl = { bg = colors.nobg, force = true } }, { FileNameBlock, hl = { bg = colors.nobg, force = true } }, @@ -805,7 +811,7 @@ local right = { { Space, hl = { bg = colors.nobg, force = true } }, { FileInfoBlock, hl = { bg = colors.nobg, force = true } }, { RightSpace, hl = { bg = colors.nobg, force = true } }, - { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, bold = false } }, { LeftSpace, hl = { bg = colors.nobg, force = true } }, } @@ -814,7 +820,7 @@ local DefaultStatusline = { sections } local specialleft = { { RightSpace, hl = { bg = colors.nobg, force = true } }, - { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { ViMode, hl = { bg = utils.get_highlight('statusline').bg, bold = false } }, { LeftSpace, hl = { bg = colors.nobg, force = true } }, } @@ -826,7 +832,7 @@ local specialmiddle = { local specialright = { { RightSpace, hl = { bg = colors.nobg, force = true } }, - { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, bold = false } }, { LeftSpace, hl = { bg = colors.nobg, force = true } }, } -- cgit v1.2.3 From f0d5b88799ac7816b802a3c63b28eda31dddc5d4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 30 Oct 2023 22:30:32 +0200 Subject: Disabled filetype for dashboard --- lua/plugins/hardtime.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/hardtime.lua b/lua/plugins/hardtime.lua index 1fb58cc..153411d 100644 --- a/lua/plugins/hardtime.lua +++ b/lua/plugins/hardtime.lua @@ -12,6 +12,7 @@ end hardtime.setup({ -- hardtime config here + disabled_filetypes = { 'qf', 'netrw', 'NvimTree', 'lazy', 'mason', 'oil', 'dashboard' }, }) return { -- cgit v1.2.3 From e4064083004a312cc4b79165411aece39e31ede2 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 30 Oct 2023 22:30:53 +0200 Subject: Changed colorscheme to tokyonight-night --- lua/user/view.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/view.lua b/lua/user/view.lua index 4bafbd0..837fce4 100644 --- a/lua/user/view.lua +++ b/lua/user/view.lua @@ -18,7 +18,7 @@ require('tokyonight').setup({ }) -- Define default color scheme -local default_colorscheme = 'bamboo' +local default_colorscheme = 'tokyonight-night' local fallback_colorscheme = 'desert' -- Attempt to set the default color scheme -- cgit v1.2.3 From 07a5768cb8d6c92eb4e048d7ded71b495acc7f2c Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 30 Oct 2023 22:31:05 +0200 Subject: Enabled notify plugin --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index da19687..04b0bb9 100644 --- a/init.lua +++ b/init.lua @@ -96,7 +96,7 @@ local modules = { 'plugins.harpoon', 'plugins.leetcode', 'plugins.hardtime', - --'plugins.notify', + 'plugins.notify', --"plugins.modify-blend", } -- cgit v1.2.3 From 19b43a9d96ad49c0364b047102f110f7166672e9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 31 Oct 2023 21:43:43 +0200 Subject: Keybinding for RunCode() --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index b7a4cfe..e7a32f4 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -438,3 +438,6 @@ map('n', 'sv', 'lua require("user.mods").Scratch("vertical")') -- Hardtime map('n', 'H', 'lua require("plugins.hardtime").ToggleHardtime()') + +-- Code Run +map('n', 'rr', 'lua require("user.mods").RunCode()') -- cgit v1.2.3 From 6225a2060ba8c547d89e32af18623a2b3433bbb2 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 31 Oct 2023 21:44:09 +0200 Subject: RunCode() self code runner for various filetypes --- lua/user/mods.lua | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 6d357f5..a74d7fb 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -850,5 +850,96 @@ vim.api.nvim_create_autocmd('BufHidden', { -------------------------------------------------- +local function substitute(cmd) + cmd = cmd:gsub('%%', vim.fn.expand('%')) + cmd = cmd:gsub('$fileBase', vim.fn.expand('%:r')) + cmd = cmd:gsub('$filePath', vim.fn.expand('%:p')) + cmd = cmd:gsub('$file', vim.fn.expand('%')) + cmd = cmd:gsub('$dir', vim.fn.expand('%:p:h')) + cmd = cmd:gsub('#', vim.fn.expand('#')) + cmd = cmd:gsub('$altFile', vim.fn.expand('#')) + + return cmd +end + +function M.RunCode() + local file_extension = vim.fn.expand('%:e') + local selected_cmd = '' + local term_cmd = 'bot 10 new | term ' + local supported_filetypes = { + html = { + default = '%', + }, + c = { + default = 'gcc % -o $fileBase && ./$fileBase', + debug = 'gcc -g % -o $fileBase && ./$fileBase', + }, + cs = { + default = 'dotnet run', + }, + cpp = { + default = 'g++ % -o $fileBase && ./$fileBase', + debug = 'g++ -g % -o ./$fileBase', + competitive = 'g++ -std=c++17 -Wall -DAL -O2 % -o $fileBase && $fileBase Date: Tue, 31 Oct 2023 21:44:25 +0200 Subject: Install 'stevearc/overseer.nvim' --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 2a56e19..1a37d28 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -212,6 +212,7 @@ return packer.startup(function(use) --vim.cmd("let g:rooter_change_directory_for_non_project_files = 'current'") }) use({ 'michaelb/sniprun', run = 'bash ./install.sh' }) + use({ 'stevearc/overseer.nvim' }) --use("vim-test/vim-test") -- --use({ -- "rcarriga/vim-ultest", -- -- cgit v1.2.3 From 06318067250f86f054eafc512ba3b06829d37c34 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 31 Oct 2023 21:44:38 +0200 Subject: Allow plugin overseer --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 04b0bb9..42c7a64 100644 --- a/init.lua +++ b/init.lua @@ -97,6 +97,7 @@ local modules = { 'plugins.leetcode', 'plugins.hardtime', 'plugins.notify', + 'plugins.overseer', --"plugins.modify-blend", } -- cgit v1.2.3 From 34df5b06f465139c91a991c74b0ceb8729cf7660 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 31 Oct 2023 21:45:09 +0200 Subject: Changed to vertical split --- lua/plugins/sniprun.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/plugins/sniprun.lua b/lua/plugins/sniprun.lua index 2556c24..418e8cc 100644 --- a/lua/plugins/sniprun.lua +++ b/lua/plugins/sniprun.lua @@ -18,11 +18,11 @@ sniprun.setup({ --# you can combo different display modes as desired display = { -- "Classic", --# display results in the command-line area - 'VirtualTextOk', --# display ok results as virtual text (multiline is shortened) + --'VirtualTextOk', --# display ok results as virtual text (multiline is shortened) -- "VirtualTextErr", --# display error results as virtual text -- "TempFloatingWindow", --# display results in a floating window -- "LongTempFloatingWindow", --# same as above, but only long results. To use with VirtualText__ - -- "Terminal", --# display results in a vertical split + 'Terminal', --# display results in a vertical split -- "TerminalWithCode", --# display results and code history in a vertical split -- "NvimNotify", --# display with the nvim-notify plugin -- "Api" --# return output to a programming interface -- cgit v1.2.3 From a9f2488b4847ca3da43bce03bb01c42bbd080a0a Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 31 Oct 2023 21:45:25 +0200 Subject: Changed shading/background --- lua/plugins/toggleterm.lua | 103 +++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index 2f978a4..e67bdec 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -1,4 +1,4 @@ -local status_ok, toggleterm = pcall(require, "toggleterm") +local status_ok, toggleterm = pcall(require, 'toggleterm') if not status_ok then return end @@ -7,13 +7,13 @@ toggleterm.setup({ autochdir = true, hide_numbers = true, shade_filetypes = {}, - shade_terminals = true, - shading_factor = 1, + shade_terminals = false, + --shading_factor = 1, start_in_insert = true, insert_mappings = true, terminal_mappings = true, persist_size = true, - direction = "float", + direction = 'float', --direction = "vertical", --direction = "horizontal", close_on_exit = true, @@ -24,13 +24,12 @@ toggleterm.setup({ --Normal = { -- background = "#000000", --}, - Normal = { guibg = 'Black', guifg = 'DarkGray' }, - FloatBorder = { guibg = 'Black', guifg = 'DarkGray' }, - NormalFloat = { guibg = 'Black' }, - --float_opts = { - -- border = as.style.current.border, - -- winblend = 3, - --}, + --Normal = { guibg = 'Black', guifg = 'White' }, + --FloatBorder = { guibg = 'Black', guifg = 'DarkGray' }, + --NormalFloat = { guibg = 'Black' }, + float_opts = { + --winblend = 3, + }, }, size = function(term) if term.direction == 'horizontal' then @@ -42,16 +41,15 @@ toggleterm.setup({ float_opts = { width = 70, height = 15, - winblend = 3, - border = "curved", - --winblend = 0, + border = 'curved', highlights = { - border = "Normal", - background = "Normal", + border = 'Normal', + --background = 'Normal', }, + --winblend = 0, }, }) -local mods = require("user.mods") +local mods = require('user.mods') local float_handler = function(term) if not mods.empty(vim.fn.mapcheck('jk', 't')) then vim.keymap.del('t', 'jk', { buffer = term.bufnr }) @@ -63,41 +61,42 @@ function _G.set_terminal_keymaps() local opts = { noremap = true } --local opts = {buffer = 0} --vim.api.nvim_buf_set_keymap(0, "i", ";to", "[[]]Toggleterm", opts) - vim.api.nvim_buf_set_keymap(0, "t", "", [[]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "", [[]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "jk", [[]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "", [[h]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "", [[j]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "", [[k]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "", [[l]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') -local Terminal = require("toggleterm.terminal").Terminal +local Terminal = require('toggleterm.terminal').Terminal -local horizontal_term = Terminal:new({ hidden = true, direction = "horizontal" }) -local vertical_term = Terminal:new({ hidden = true, direction = "vertical" }) +local horizontal_term = Terminal:new({ hidden = true, direction = 'horizontal' }) +local vertical_term = Terminal:new({ hidden = true, direction = 'vertical' }) function Horizontal_term_toggle() - horizontal_term:toggle(8, "horizontal") + horizontal_term:toggle(8, 'horizontal') end + function Vertical_term_toggle() - horizontal_term:toggle(math.floor(vim.o.columns * 0.5), "vertical") + horizontal_term:toggle(math.floor(vim.o.columns * 0.5), 'vertical') end local lazygit = Terminal:new({ - cmd = "lazygit", + cmd = 'lazygit', count = 5, id = 1000, - dir = "git_dir", - direction = "float", + dir = 'git_dir', + direction = 'float', on_open = float_handler, hidden = true, float_opts = { border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, width = 150, - height = 40 + height = 40, }, ---- Function to run on opening the terminal @@ -123,54 +122,58 @@ function Lazygit_toggle() lazygit:close() lazygit = Terminal:new({ cmd = "zsh --login -c 'lazygit'", - dir = "git_dir", - direction = "float", + dir = 'git_dir', + direction = 'float', hidden = true, on_open = float_handler, float_opts = { border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, width = 150, - height = 40 + height = 40, }, }) end lazygit:toggle() end -local node = Terminal:new({ cmd = "node", hidden = true }) +local node = Terminal:new({ cmd = 'node', hidden = true }) function _NODE_TOGGLE() node:toggle() end -local ncdu = Terminal:new({ cmd = "ncdu", hidden = true }) +local ncdu = Terminal:new({ cmd = 'ncdu', hidden = true }) function _NCDU_TOGGLE() ncdu:toggle() end -local htop = Terminal:new({ cmd = "htop", hidden = true }) +local htop = Terminal:new({ cmd = 'htop', hidden = true }) function _HTOP_TOGGLE() htop:toggle() end -local python = Terminal:new({ cmd = "python", hidden = true }) +local python = Terminal:new({ cmd = 'python', hidden = true }) function _PYTHON_TOGGLE() python:toggle() end function Gh_dash() -Terminal:new({ - cmd = 'gh dash', - hidden = true, - direction = 'float', - on_open = float_handler, - float_opts = { - height = function() return math.floor(vim.o.lines * 0.8) end, - width = function() return math.floor(vim.o.columns * 0.95) end, - }, -}) + Terminal:new({ + cmd = 'gh dash', + hidden = true, + direction = 'float', + on_open = float_handler, + float_opts = { + height = function() + return math.floor(vim.o.lines * 0.8) + end, + width = function() + return math.floor(vim.o.columns * 0.95) + end, + }, + }) Gh_dash:toggle() end -- cgit v1.2.3 From 5bfddf88b927f2591dde63db2b4c1fff75975448 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 31 Oct 2023 21:45:43 +0200 Subject: Overseer plugin enabled --- lua/plugins/overseer.lua | 1 + 1 file changed, 1 insertion(+) create mode 100644 lua/plugins/overseer.lua diff --git a/lua/plugins/overseer.lua b/lua/plugins/overseer.lua new file mode 100644 index 0000000..6319d36 --- /dev/null +++ b/lua/plugins/overseer.lua @@ -0,0 +1 @@ +require('overseer').setup() -- cgit v1.2.3 From 81e2925092cdb6fe21791b32f6c6983b4e31b3d7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 1 Nov 2023 22:51:33 +0200 Subject: find_config() now tracks dotfiles (bare git repository), no need to manually add config files to search --- lua/plugins/telescope.lua | 50 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 5b9717b..fb1b3ee 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -311,50 +311,24 @@ require('telescope').load_extension('recent_files') --end function M.find_configs() + -- Track dotfiles (bare git repository) + -- Inside shell config file: + -- alias config='git --git-dir=$HOME/.cfg --work-tree=$HOME' + -- cfg_files=$(config ls-tree --name-only -r HEAD) + -- export CFG_FILES="$cfg_files" + local tracked_files = {} + + for file in string.gmatch(os.getenv('CFG_FILES'), '[^\n]+') do + table.insert(tracked_files, os.getenv('HOME') .. '/' .. file) + end + require('telescope.builtin').find_files({ hidden = true, no_ignore = false, prompt_title = ' Find Configs', results_title = 'Config Files', path_display = { 'smart' }, - search_dirs = { - '~/.vim', - '~/.config/nvim', - '~/.config/zsh', - '~/.config/tmux', - '~/.config/X11', - '~/.config/alacritty', - '~/.config/kitty', - '~/.config/wezterm', - '~/.config/bspwm', - '~/.config/sxhkd', - '~/.config/picom', - '~/.config/polybar', - '~/.bashrc', - '~/.profile', - '~/.zprofile', - '~/.gitconfig', - '~/.gitsubtrees', - '~/.gitignore', - '~/.editorconfig', - '~/.prettierrc.yml', - '~/.ssh', - '~/README.md', - '~/.config/inputrc', - }, - file_ignore_patterns = { - '/nvim/startup.log', - 'zsh/plugins', - 'packer_compiled.lua', - 'resurrect', - 'tmux/plugins', - --"^~/.config/tmux/plugins", - '%.txt', - '.git/', - 'autoload/plugged', - 'plug.vim', - 'zcompdump', - }, + search_dirs = tracked_files, layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, }) -- cgit v1.2.3 From d7a3c17b5c61351e2da551651f058960d1887ec2 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 2 Nov 2023 18:21:05 +0200 Subject: Changed feh to vimiv and mpv to vlc for 'intercept file open' --- lua/user/mods.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index a74d7fb..29d1b1c 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -803,12 +803,13 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { ['epub'] = function(buf, fpath, fname) open_in_prog(buf, fpath, fname, 'zathura') end, + ['mobi'] = 'pdf', ['png'] = function(buf, fpath, fname) - open_in_prog(buf, fpath, fname, 'feh') + open_in_prog(buf, fpath, fname, 'vimiv') end, ['jpg'] = 'png', ['mp4'] = function(buf, fpath, fname) - open_in_prog(buf, fpath, fname, 'mpv') + open_in_prog(buf, fpath, fname, 'vlc') end, ['gif'] = 'mp4', } -- cgit v1.2.3 From 1a8a25a258e39b3268742ef049d71b3a0297e06d Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 2 Nov 2023 22:48:33 +0200 Subject: Toggle code runner --- lua/user/keys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index e7a32f4..d1e0971 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -440,4 +440,4 @@ map('n', 'sv', 'lua require("user.mods").Scratch("vertical")') map('n', 'H', 'lua require("plugins.hardtime").ToggleHardtime()') -- Code Run -map('n', 'rr', 'lua require("user.mods").RunCode()') +map('n', 'rr', 'lua require("user.mods").toggleCodeRunner()') -- cgit v1.2.3 From 8516a102660ce0f5ff9f36cc3947966c7636359d Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 2 Nov 2023 22:48:41 +0200 Subject: Toggle code runner --- lua/user/mods.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 29d1b1c..7c2db16 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -851,6 +851,27 @@ vim.api.nvim_create_autocmd('BufHidden', { -------------------------------------------------- +local codeRunnerEnabled = false + +function M.toggleCodeRunner() + codeRunnerEnabled = not codeRunnerEnabled + if codeRunnerEnabled then + print('Code Runner enabled') + M.RunCode() -- Execute when enabled + else + print('Code Runner disabled') + -- Close the terminal window when disabled + local buffers = vim.fn.getbufinfo() + + for _, buf in ipairs(buffers) do + local type = vim.api.nvim_buf_get_option(buf.bufnr, 'buftype') + if type == 'terminal' then + vim.api.nvim_command('silent! bdelete ' .. buf.bufnr) + end + end + end +end + local function substitute(cmd) cmd = cmd:gsub('%%', vim.fn.expand('%')) cmd = cmd:gsub('$fileBase', vim.fn.expand('%:r')) @@ -864,6 +885,10 @@ local function substitute(cmd) end function M.RunCode() + if not codeRunnerEnabled then + print('Code Runner is currently disabled. Toggle it on to execute code.') + return + end local file_extension = vim.fn.expand('%:e') local selected_cmd = '' local term_cmd = 'bot 10 new | term ' @@ -896,6 +921,9 @@ function M.RunCode() default = 'node %', debug = 'node --inspect %', }, + lua = { + default = 'lua %', + }, ts = { default = 'tsc % && node $fileBase', }, -- cgit v1.2.3 From d4758b9b1e2a89c7258e055a9d167250efb75168 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 2 Nov 2023 23:18:13 +0200 Subject: Run executable file --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index d1e0971..a6be1e5 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -441,3 +441,6 @@ map('n', 'H', 'lua require("plugins.hardtime").ToggleHardtime() -- Code Run map('n', 'rr', 'lua require("user.mods").toggleCodeRunner()') + +-- Run executable file +map('n', 'rc', ":lua require('user.mods').RunCurrentFile():echom 'Running executable file...':sl!:echo ''") -- cgit v1.2.3 From f918f11a1ec574562ad15d23055490b615025862 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 2 Nov 2023 23:18:22 +0200 Subject: Run executable file --- lua/user/mods.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 7c2db16..883c1c7 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -970,5 +970,53 @@ end -------------------------------------------------- +-- Run executable file +local interpreters = { + python = 'python', + lua = 'lua', + bash = 'bash', + zsh = 'zsh', + perl = 'perl', + ruby = 'ruby', + node = 'node', + rust = 'rust', + php = 'php', +} + +function M.RunCurrentFile() + local file_path = vim.fn.expand('%:p') + local file = io.open(file_path, 'r') + + if not file then + print('Error: Unable to open the file') + return + end + + local shebang = file:read() + file:close() + + local interpreter = shebang:match('#!%s*(.-)$') + if not interpreter then + print('Error: No shebang line found in the file') + return + end + + -- Remove leading spaces and any arguments, extracting the interpreter name + interpreter = interpreter:gsub('^%s*([^%s]+).*', '%1') + + local cmd = interpreters[interpreter] + + if not cmd then + cmd = interpreter -- Set the command to the interpreter directly + end + + -- Run the file using the determined interpreter + vim.fn.jobstart(cmd .. ' ' .. file_path, { + cwd = vim.fn.expand('%:p:h'), + }) +end + +-------------------------------------------------- + -- ... return M -- cgit v1.2.3 From 1a1736ee14fc7bfe6c307da20b951d7ad08c65ef Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 2 Nov 2023 23:39:15 +0200 Subject: Made order of RunCode()'s 'choose a command' more consistent --- lua/user/mods.lua | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 883c1c7..49027da 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -891,7 +891,6 @@ function M.RunCode() end local file_extension = vim.fn.expand('%:e') local selected_cmd = '' - local term_cmd = 'bot 10 new | term ' local supported_filetypes = { html = { default = '%', @@ -947,23 +946,48 @@ function M.RunCode() }, } - if supported_filetypes[file_extension] then - local choices = vim.tbl_keys(supported_filetypes[file_extension]) + local term_cmd = 'bot 10 new | term ' + local choices = {} - if #choices == 0 then - vim.notify("It doesn't contain any command", vim.log.levels.WARN, { title = 'Code Runner' }) - elseif #choices == 1 then - selected_cmd = supported_filetypes[file_extension][choices[1]] - vim.cmd(term_cmd .. substitute(selected_cmd)) - else - vim.ui.select(choices, { prompt = 'Choose a command: ' }, function(choice) - selected_cmd = supported_filetypes[file_extension][choice] - if selected_cmd then - vim.cmd(term_cmd .. substitute(selected_cmd)) - end - end) + -- Add 'default' as the first option if available + if supported_filetypes[file_extension]['default'] then + table.insert(choices, 'default') + end + + -- Add 'debug' as the second option if available + if supported_filetypes[file_extension]['debug'] then + table.insert(choices, 'debug') + end + + -- Add other available options + for key, _ in pairs(supported_filetypes[file_extension]) do + if key ~= 'default' and key ~= 'debug' then + table.insert(choices, key) end + end + if #choices == 0 then + vim.notify("It doesn't contain any command", vim.log.levels.WARN, { title = 'Code Runner' }) + elseif #choices == 1 then + selected_cmd = supported_filetypes[file_extension][choices[1]] + vim.cmd(term_cmd .. substitute(selected_cmd)) else + vim.ui.select(choices, { + prompt = 'Choose a command: ', + layout_config = { + height = 10, + width = 40, + prompt_position = 'top', + -- other options as required + }, + }, function(choice) + selected_cmd = supported_filetypes[file_extension][choice] + if selected_cmd then + vim.cmd(term_cmd .. substitute(selected_cmd)) + end + end) + end + + if not supported_filetypes[file_extension] then vim.notify("The filetype isn't included in the list", vim.log.levels.WARN, { title = 'Code Runner' }) end end -- cgit v1.2.3