From f20f9acb88c4bfd09e5a087a0da4697e08e81163 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 8 Aug 2023 23:52:46 +0200 Subject: Fixed ToggleHiddenAll() function not being called in keys.lua --- autoload/utils.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/utils.vim b/autoload/utils.vim index d244e90..1ca005f 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -57,7 +57,7 @@ endfunction " Toggle statusline let s:hidden_all = 0 -function! ToggleHiddenAll() +function! utils#ToggleHiddenAll() if s:hidden_all == 0 let s:hidden_all = 1 set noshowmode -- cgit v1.2.3 From 162a5a5425432abadd44cafcdae16e28f76e391a Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 8 Aug 2023 23:53:04 +0200 Subject: Ignore .config/zsh/plugins --- lua/plugins/telescope.lua | 77 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 079f88b..72f8a01 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -11,8 +11,7 @@ local fb_actions = require("telescope").extensions.file_browser.actions --local pickers = require("telescope.pickers") local themes = require("telescope.themes") - -require('telescope').setup({ +require("telescope").setup({ defaults = { vimgrep_arguments = { "rg", @@ -150,13 +149,13 @@ require('telescope').setup({ sorting_strategy = "ascending", scroll_strategy = "limit", color_devicons = true, - layout_strategy = 'horizontal', + layout_strategy = "horizontal", layout_config = { horizontal = { height = 0.95, preview_cutoff = 70, width = 0.92, - preview_width = { 0.55, max = 50 } + preview_width = { 0.55, max = 50 }, }, bottom_pane = { height = 12, @@ -209,9 +208,9 @@ require('telescope').setup({ -- show_line = false, --}, find_files = { - cwd = '%:p:h', + cwd = "%:p:h", --cwd = vim.fn.getcwd(), - prompt_prefix = ' ', + prompt_prefix = " ", hidden = true, follow = true, }, @@ -279,14 +278,14 @@ require('telescope').setup({ -- Load extensions: -- have to be loaded after telescope setup/config -require('telescope').load_extension('fzf') -require('telescope').load_extension('ui-select') +require("telescope").load_extension("fzf") +require("telescope").load_extension("ui-select") require("telescope").load_extension("file_browser") -require('telescope').load_extension('changed_files') -require('telescope').load_extension('media_files') +require("telescope").load_extension("changed_files") +require("telescope").load_extension("media_files") --require('telescope').extensions.notify.notify() -require('telescope').load_extension('notify') -require('telescope').load_extension('dap') +require("telescope").load_extension("notify") +require("telescope").load_extension("dap") require("telescope").load_extension("session-lens") require("telescope").load_extension("flutter") @@ -301,7 +300,7 @@ require("telescope").load_extension("flutter") --end function M.find_configs() - require("telescope.builtin").find_files { + require("telescope.builtin").find_files({ hidden = true, no_ignore = false, prompt_title = " Find Configs", @@ -329,6 +328,7 @@ function M.find_configs() -- cwd = "~/.config/nvim/", file_ignore_patterns = { "~/.config/nvim/startup.log", + "~/.config/zsh/plugins", "packer_compiled.lua", "resurrect", "tmux/plugins", @@ -341,11 +341,11 @@ function M.find_configs() }, layout_strategy = "horizontal", layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) end function M.find_scripts() - require("telescope.builtin").find_files { + require("telescope.builtin").find_files({ hidden = true, no_ignore = true, prompt_title = " Find Scripts", @@ -355,11 +355,11 @@ function M.find_scripts() }, layout_strategy = "horizontal", layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) end function M.find_projects() - require("telescope.builtin").find_files { + require("telescope.builtin").find_files({ hidden = true, no_ignore = true, prompt_title = " Find Projects", @@ -369,7 +369,7 @@ function M.find_projects() }, layout_strategy = "horizontal", layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) end function M.grep_notes() @@ -385,7 +385,7 @@ function M.grep_notes() end function M.find_notes() - require("telescope.builtin").find_files { + require("telescope.builtin").find_files({ hidden = false, prompt_title = " Find Notes", path_display = { "smart" }, @@ -396,7 +396,7 @@ function M.find_notes() --cwd = "~documents/notes", layout_strategy = "horizontal", layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) end function M.file_explorer() @@ -418,16 +418,16 @@ end -------------------------------------------------------------------------------- -local dropdown = require('telescope.themes').get_dropdown({ +local dropdown = require("telescope.themes").get_dropdown({ hidden = true, no_ignore = true, previewer = false, - prompt_title = '', - preview_title = '', - results_title = '', + prompt_title = "", + preview_title = "", + results_title = "", layout_config = { --anchor = "S", - prompt_position = 'top' + prompt_position = "top", }, }) @@ -440,17 +440,17 @@ local dropdown = require('telescope.themes').get_dropdown({ local with_title = function(opts, extra) extra = extra or {} local path = opts.cwd or opts.path or extra.cwd or extra.path or nil - local title = '' - local buf_path = vim.fn.expand('%:p:h') + local title = "" + local buf_path = vim.fn.expand("%:p:h") local cwd = vim.fn.getcwd() if path ~= nil and buf_path ~= cwd then - title = require('plenary.path'):new(buf_path):make_relative(cwd) + title = require("plenary.path"):new(buf_path):make_relative(cwd) else - title = vim.fn.fnamemodify(cwd, ':t') + title = vim.fn.fnamemodify(cwd, ":t") end - return vim.tbl_extend('force', opts, { - prompt_title = title + return vim.tbl_extend("force", opts, { + prompt_title = title, }, extra or {}) end @@ -460,19 +460,18 @@ end --vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') --vim.api.nvim_command('augroup END') - --local findhere = function() function M.findhere() -- Open file browser if argument is a folder - local arg = vim.api.nvim_eval('argv(0)') + local arg = vim.api.nvim_eval("argv(0)") if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == "") then vim.defer_fn(function() - require('telescope.builtin').find_files(with_title(dropdown)) --- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ --- hidden = true, --- results_title = '', --- layout_config = { prompt_position = 'top' }, --- })) + require("telescope.builtin").find_files(with_title(dropdown)) + -- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ + -- hidden = true, + -- results_title = '', + -- layout_config = { prompt_position = 'top' }, + -- })) end, 10) end end -- cgit v1.2.3 From e924fced276e08c1e31c124a0f23854cb83504aa Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 9 Aug 2023 23:44:42 +0200 Subject: Fixed ToggleHiddenAll() from not working --- lua/user/keys.lua | 94 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 17 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 36f7fbd..2a4fa6c 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -193,13 +193,29 @@ map("n", "o", ":!xdg-open %") -- URL handling if vim.fn.has("mac") == 1 then - map("", "gx", 'call jobstart(["open", expand("")], {"detach": v:true})', {}) + map( + "", + "gx", + 'call jobstart(["open", expand("")], {"detach": v:true})', + {} + ) elseif vim.fn.has("unix") == 1 then - map("", "gx", 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', {}) + map( + "", + "gx", + 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', + {} + ) elseif vim.fn.has("wsl") == 1 then - map("", "gx", 'call jobstart(["wslview", expand("")], {"detach": v:true})', {}) + map( + "", + "gx", + 'call jobstart(["wslview", expand("")], {"detach": v:true})', + {} + ) else - map[""].gx = { 'lua print("Error: gx is not supported on this OS!")' } + map[""].gx = + { 'lua print("Error: gx is not supported on this OS!")' } end -- Substitute globally and locally in the selected region. @@ -246,7 +262,7 @@ map("n", "z", ":call utils#ZoomToggle()") map("n", "z", "|_") -- Toggle statusline -map("n", "", ":call ToggleHiddenAll()") +map("n", "", ":call utils#ToggleHiddenAll()") -- Open last closed buffer map("n", "", ":call OpenLastClosed()") @@ -314,19 +330,55 @@ map("n", "fg", "lua require('telescope.builtin').live_grep()") map("n", "fb", "lua require('telescope.builtin').buffers()") map("n", "fh", "lua require('telescope.builtin').help_tags()") map("n", "fc", "lua require('telescope.builtin').commands()") -map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") +map( + "n", + "ffc", + "lua require('telescope.builtin').current_buffer_fuzzy_find()" +) map("n", "cf", "Telescope changed_files") map("n", "fp", "Telescope pickers") -map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker -map("n", "fd", "lua require('telescope.builtin').diagnostics()") +map( + "n", + "fr", + "lua require('telescope.builtin').registers({})" +) -- registers picker +map( + "n", + "fd", + "lua require('telescope.builtin').diagnostics()" +) map("n", "fk", "lua require('telescope.builtin').keymaps()") -map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes -map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs -map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts -map("n", "fw", [[lua require'plugins.telescope'.find_projects()]]) -- find projects -map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files -map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find notifications +map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map( + "n", + "fgn", + [[lua require'plugins.telescope'.grep_notes()]] +) -- search notes +map( + "n", + "f.", + [[lua require'plugins.telescope'.find_configs()]] +) -- find configs +map( + "n", + "fs", + [[lua require'plugins.telescope'.find_scripts()]] +) -- find scripts +map( + "n", + "fw", + [[lua require'plugins.telescope'.find_projects()]] +) -- find projects +map( + "n", + "fm", + "lua require('telescope').extensions.media_files.media_files({})" +) -- find media files +map( + "n", + "fi", + "lua require('telescope').extensions.notify.notify({})" +) -- find notifications --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option map( "n", @@ -352,7 +404,11 @@ map("n", "mg", "Glow") map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle -map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") +map( + "n", + "zm", + "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')" +) -- Vim-rooter map( @@ -401,7 +457,11 @@ vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) map("n", "ds", function() dap.continue() ui.toggle({}) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) -- Spaces buffers evenly + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes("=", false, true, true), + "n", + false + ) -- Spaces buffers evenly end) -- Set breakpoints, get variable values, step into/out of functions, etc. -- cgit v1.2.3 From d6ad907ab712cad7313b0808c64300f7faaa99bc Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 10 Aug 2023 23:55:05 +0200 Subject: Fixed lsp from creating duplicate servers on the same buffer --- lua/plugins/lsp.lua | 884 +++++++++++++++++++++++++++------------------------- 1 file changed, 467 insertions(+), 417 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index b875182..2eba05f 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,4 +1,7 @@ ---local mason = require('mason') +local lspconfig = require("lspconfig") +local mason_lspconfig = require("mason-lspconfig") +local null_ls = require("null-ls") +--local lsp_lines = require('lsp_lines') require("mason").setup() require("mason-null-ls").setup({ handlers = {}, @@ -6,10 +9,6 @@ require("mason-null-ls").setup({ automatic_installation = true, automatic_setup = true, }) -local lspconfig = require("lspconfig") -local mason_lspconfig = require("mason-lspconfig") -local null_ls = require("null-ls") ---local lsp_lines = require('lsp_lines') local keymap = vim.keymap local cmd = vim.cmd @@ -25,116 +24,145 @@ local border = { { "│", "FloatBorder" }, } -local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } -for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -end +-- Set up LSP servers if not done before +if not vim.g.lsp_setup_done then + -- Clear existing LSP clients + for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do + local clients = vim.lsp.get_clients({ buffer = bufnr }) + for _, client in ipairs(clients) do + client.stop() + end + end ---lsp_lines.setup() - ---vim.keymap.set("n", "g?", function() --- local lines_enabled = not vim.diagnostic.config().virtual_lines --- vim.diagnostic.config( --- { --- virtual_lines = lines_enabled, --- virtual_text = not lines_enabled --- } --- ) ---end, { noremap = true, silent = true }) - -vim.diagnostic.config({ - underline = false, - signs = true, - virtual_text = true, - --virtual_lines = { only_current_line = true }, - virtual_lines = false, - float = { - show_header = true, - source = "if_many", - --border = 'rounded', - border = border, - focusable = true, - }, - update_in_insert = false, -- default to false - severity_sort = false, -- default to false -}) + local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - underline = false, - virtual_text = false, - signs = true, - update_in_insert = false, -}) + --lsp_lines.setup() -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) - --- Use an on_attach function to only map the following keys after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - local map = function(mode, l, r, opts) - opts = opts or {} - opts.silent = true - opts.noremap = true - opts.buffer = bufnr - keymap.set(mode, l, r, opts) - end - -- Mappings - map("n", "K", "lua vim.lsp.buf.hover()") - --map("n", "gd", "lua vim.lsp.buf.definition()") - map("n", "gd", "lua require('goto-preview').goto_preview_definition()") - --map("n", "gi", "lua vim.lsp.buf.implementation()") - map("n", "gi", "lua require('goto-preview').goto_preview_implementation()") - --map("n", "gr", "lua vim.lsp.buf.references()") - map("n", "gr", "lua require('goto-preview').goto_preview_references()") - map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. - map("n", "k", "lua vim.lsp.buf.signature_help()") - --map("n", "gt", "lua vim.lsp.buf.type_definition()") - 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", "go", "lua vim.diagnostic.open_float()") - map( - "n", - "go", - ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')" - ) - map("n", "[d", "lua vim.diagnostic.goto_prev()") - map("n", "]d", "lua vim.diagnostic.goto_next()") - map("n", "gs", "lua vim.lsp.buf.document_symbol()") - map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") - map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - map("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end) - - -- TODO: Use the nicer new API for autocommands - cmd("augroup lsp_aucmds") - if client.server_capabilities.documentHighlightProvider then - cmd("au CursorHold lua vim.lsp.buf.document_highlight()") - cmd("au CursorMoved lua vim.lsp.buf.clear_references()") + --vim.keymap.set("n", "g?", function() + -- local lines_enabled = not vim.diagnostic.config().virtual_lines + -- vim.diagnostic.config( + -- { + -- virtual_lines = lines_enabled, + -- virtual_text = not lines_enabled + -- } + -- ) + --end, { noremap = true, silent = true }) + + vim.diagnostic.config({ + underline = false, + signs = true, + virtual_text = true, + --virtual_lines = { only_current_line = true }, + virtual_lines = false, + float = { + show_header = true, + source = "if_many", + --border = 'rounded', + border = border, + focusable = true, + }, + update_in_insert = false, -- default to false + severity_sort = false, -- default to false + }) + + vim.lsp.handlers["textDocument/publishDiagnostics"] = + vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + underline = false, + virtual_text = false, + signs = true, + update_in_insert = false, + }) + + vim.lsp.handlers["textDocument/hover"] = + vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) + vim.lsp.handlers["textDocument/signatureHelp"] = + vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) + + -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer + local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + local map = function(mode, l, r, opts) + opts = opts or {} + opts.silent = true + opts.noremap = true + opts.buffer = bufnr + keymap.set(mode, l, r, opts) + end + -- Mappings + map("n", "K", "lua vim.lsp.buf.hover()") + --map("n", "gd", "lua vim.lsp.buf.definition()") + map( + "n", + "gd", + "lua require('goto-preview').goto_preview_definition()" + ) + --map("n", "gi", "lua vim.lsp.buf.implementation()") + map( + "n", + "gi", + "lua require('goto-preview').goto_preview_implementation()" + ) + --map("n", "gr", "lua vim.lsp.buf.references()") + map( + "n", + "gr", + "lua require('goto-preview').goto_preview_references()" + ) + map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map("n", "k", "lua vim.lsp.buf.signature_help()") + --map("n", "gt", "lua vim.lsp.buf.type_definition()") + 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", "go", "lua vim.diagnostic.open_float()") + map( + "n", + "go", + ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')" + ) + map("n", "[d", "lua vim.diagnostic.goto_prev()") + map("n", "]d", "lua vim.diagnostic.goto_next()") + map("n", "gs", "lua vim.lsp.buf.document_symbol()") + map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") + map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + map("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end) + + -- TODO: Use the nicer new API for autocommands + cmd("augroup lsp_aucmds") + if client.server_capabilities.documentHighlightProvider then + cmd("au CursorHold lua vim.lsp.buf.document_highlight()") + cmd("au CursorMoved lua vim.lsp.buf.clear_references()") + end + cmd("augroup END") end - cmd("augroup END") -end --- Toggle diagnostics visibility -vim.g.diagnostics_visible = true -function _G.toggle_diagnostics() - if vim.g.diagnostics_visible then - vim.g.diagnostics_visible = false - vim.diagnostic.disable() - else - vim.g.diagnostics_visible = true - vim.diagnostic.enable() + -- Toggle diagnostics visibility + vim.g.diagnostics_visible = true + function _G.toggle_diagnostics() + if vim.g.diagnostics_visible then + vim.g.diagnostics_visible = false + vim.diagnostic.disable() + else + vim.g.diagnostics_visible = true + vim.diagnostic.enable() + end end -end --- Open float for diagnostics automatically -vim.cmd([[ + -- Open float for diagnostics automatically + vim.cmd([[ augroup OpenFloat " autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) autocmd CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) @@ -142,337 +170,359 @@ augroup OpenFloat 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" } - -local function prefer_null_ls_fmt(client) - client.server_capabilities.documentHighlightProvider = true - client.server_capabilities.documentFormattingProvider = true - on_attach(client) -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" } -local servers = { - asm_lsp = {}, - bashls = {}, - clangd = {}, - cssls = { - filetypes = { "css", "scss", "less", "sass" }, - root_dir = lspconfig.util.root_pattern("package.json", ".git"), - }, - -- ghcide = {}, - html = {}, - jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, - intelephense = {}, - julials = { - on_new_config = function(new_config, _) - local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") - if lspconfig.util.path.is_file(julia) then - new_config.cmd[1] = julia - end - end, - settings = { julia = { format = { indent = 2 } } }, - }, - pyright = { - settings = { - python = { - formatting = { provider = "yapf" }, - linting = { pytypeEnabled = true }, - }, + local function prefer_null_ls_fmt(client) + client.server_capabilities.documentHighlightProvider = true + client.server_capabilities.documentFormattingProvider = true + on_attach(client) + end + + local servers = { + asm_lsp = {}, + bashls = {}, + clangd = {}, + cssls = { + filetypes = { "css", "scss", "less", "sass" }, + root_dir = lspconfig.util.root_pattern("package.json", ".git"), + }, + -- ghcide = {}, + html = {}, + jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, + intelephense = {}, + julials = { + on_new_config = function(new_config, _) + local julia = + vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") + if lspconfig.util.path.is_file(julia) then + new_config.cmd[1] = julia + end + end, + settings = { julia = { format = { indent = 2 } } }, }, - }, - rust_analyzer = { - settings = { - ["rust-analyzer"] = { - cargo = { allFeatures = true }, - checkOnSave = { - command = "clippy", - extraArgs = { "--no-deps" }, + pyright = { + settings = { + python = { + formatting = { provider = "yapf" }, + linting = { pytypeEnabled = true }, }, }, }, - }, - dartls = { - cmd = { "dart", "language-server", "--protocol=lsp" }, - filetypes = { "dart" }, - init_options = { - closingLabels = true, - flutterOutline = true, - onlyAnalyzeProjectsWithOpenFiles = true, - outline = true, - suggestFromUnimportedLibraries = true, - }, - -- root_dir = root_pattern("pubspec.yaml"), - settings = { - dart = { - completeFunctionCalls = true, - showTodos = true, + rust_analyzer = { + settings = { + ["rust-analyzer"] = { + cargo = { allFeatures = true }, + checkOnSave = { + command = "clippy", + extraArgs = { "--no-deps" }, + }, + }, }, }, - on_attach = function(client, bufnr) end, - }, - lua_ls = { - on_attach = on_attach, - capabilities = capabilities, - debounce_text_changes = 500, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - enable = true, - globals = { "vim" }, + dartls = { + cmd = { "dart", "language-server", "--protocol=lsp" }, + filetypes = { "dart" }, + init_options = { + closingLabels = true, + flutterOutline = true, + onlyAnalyzeProjectsWithOpenFiles = true, + outline = true, + suggestFromUnimportedLibraries = true, + }, + -- root_dir = root_pattern("pubspec.yaml"), + settings = { + dart = { + completeFunctionCalls = true, + showTodos = true, }, - workspace = { - maxPreload = 2000, - preloadFileSize = 50000, - checkThirdParty = false, + }, + on_attach = function(client, bufnr) end, + }, + lua_ls = { + on_attach = on_attach, + capabilities = capabilities, + debounce_text_changes = 500, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + enable = true, + globals = { "vim" }, + }, + workspace = { + maxPreload = 2000, + preloadFileSize = 50000, + checkThirdParty = false, + }, }, }, }, - }, - sqlls = {}, - tsserver = { - capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), - on_attach = function(client) - client.server_capabilities.document_formatting = false - client.server_capabilities.document_range_formatting = false - end, - filetypes = { - "javascript", - "javascriptreact", - "javascript.jsx", - "typescript", - "typescriptreact", - "typescript.tsx", + sqlls = {}, + tsserver = { + capabilities = require("cmp_nvim_lsp").default_capabilities( + vim.lsp.protocol.make_client_capabilities() + ), + on_attach = function(client) + client.server_capabilities.document_formatting = false + client.server_capabilities.document_range_formatting = false + end, + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, }, - }, - vimls = {}, - yamlls = {}, -} + vimls = {}, + yamlls = {}, + } -mason_lspconfig.setup({ - ensure_installed = servers, -- will be installed by mason - automatic_installation = true, -}) + mason_lspconfig.setup({ + ensure_installed = servers, -- will be installed by mason + automatic_installation = true, + }) --- Your other configurations ... ---require("lspconfig").dartls.setup({ capabilities = capabilities }) ---local installed_lsp = mason_lspconfig.ensure_installed ---local mason_lspconfig = require("mason-lspconfig").ensure_installed - ---require("lspconfig").setup({ --- function() --- for _, lsp in ipairs(installed_lsp) do --- if --- lsp ~= "sqls" --- --and lsp ~= "sumneko_lua" --- --and lsp ~= "stylelint_lsp" --- --and lsp ~= "rust_analyzer" --- --and lsp ~= "sourcekit" --- and lsp ~= "dartls" --- then --- lspconfig[lsp].setup({ --- on_attach = on_attach, --- capabilities = capabilities, --- }) --- end --- end --- end, ---}) - -for server, config in pairs(servers) do - if config.prefer_null_ls then - if config.on_attach then - local old_on_attach = config.on_attach - config.on_attach = function(client, bufnr) - old_on_attach(client, bufnr) - prefer_null_ls_fmt(client) + -- Your other configurations ... + --require("lspconfig").dartls.setup({ capabilities = capabilities }) + --local installed_lsp = mason_lspconfig.ensure_installed + --local mason_lspconfig = require("mason-lspconfig").ensure_installed + + --require("lspconfig").setup({ + -- function() + -- for _, lsp in ipairs(installed_lsp) do + -- if + -- lsp ~= "sqls" + -- --and lsp ~= "sumneko_lua" + -- --and lsp ~= "stylelint_lsp" + -- --and lsp ~= "rust_analyzer" + -- --and lsp ~= "sourcekit" + -- and lsp ~= "dartls" + -- then + -- lspconfig[lsp].setup({ + -- on_attach = on_attach, + -- capabilities = capabilities, + -- }) + -- end + -- end + -- end, + --}) + + for server, config in pairs(servers) do + if config.prefer_null_ls then + if config.on_attach then + local old_on_attach = config.on_attach + config.on_attach = function(client, bufnr) + old_on_attach(client, bufnr) + prefer_null_ls_fmt(client) + end + else + config.on_attach = prefer_null_ls_fmt end - else - config.on_attach = prefer_null_ls_fmt + elseif not config.on_attach then + config.on_attach = on_attach end - elseif not config.on_attach then - config.on_attach = on_attach + + lspconfig[server].setup(config) end - lspconfig[server].setup(config) -end + -- null_ls setup + local builtins = null_ls.builtins + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) --- null_ls setup -local builtins = null_ls.builtins -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - ---local eslint_opts = { --- -- condition = function(utils) --- -- return utils.root_has_file ".eslintrc.js" or utils.root_has_file ".eslintrc" or utils.root_has_file ".eslintrc.json" --- -- end, --- -- diagnostics_format = "#{m} [#{c}]", --- prefer_local = true, ---} - ---null_ls.setup({ -local sources = { - -- Diagnostics - builtins.diagnostics.chktex, - --null_ls.builtins.code_actions.eslint_d, - --null_ls.builtins.diagnostics.eslint_d, - --null_ls.builtins.formatting.eslint_d, - -- null_ls.builtins.diagnostics.cppcheck, - -- null_ls.builtins.diagnostics.proselint, - -- null_ls.builtins.diagnostics.pylint, - --builtins.diagnostics.selene, - builtins.diagnostics.dotenv_linter, - builtins.diagnostics.shellcheck.with({ - -- shell script diagnostics - diagnostic_config = { - -- see :help vim.diagnostic.config() - underline = true, - virtual_text = false, - signs = true, - update_in_insert = false, - severity_sort = true, - }, - diagnostics_format = "[#{c}] #{m} (#{s})", - -- this will run every time the source runs, - -- so you should prefer caching results if possible - }), - builtins.diagnostics.zsh.with({ - filetypes = "zsh", - "sh", - }), - builtins.diagnostics.todo_comments, - builtins.diagnostics.teal, - -- null_ls.builtins.diagnostics.vale, - builtins.diagnostics.vint, - builtins.diagnostics.tidy, - builtins.diagnostics.php, - builtins.diagnostics.phpcs, - builtins.diagnostics.flake8, - builtins.diagnostics.eslint_d.with({ - condition = function(utils) - return utils.root_has_file(".eslintrc.json") + --local eslint_opts = { + -- -- condition = function(utils) + -- -- return utils.root_has_file ".eslintrc.js" or utils.root_has_file ".eslintrc" or utils.root_has_file ".eslintrc.json" + -- -- end, + -- -- diagnostics_format = "#{m} [#{c}]", + -- prefer_local = true, + --} + + --null_ls.setup({ + local sources = { + -- Diagnostics + builtins.diagnostics.chktex, + --null_ls.builtins.code_actions.eslint_d, + --null_ls.builtins.diagnostics.eslint_d, + --null_ls.builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.cppcheck, + -- null_ls.builtins.diagnostics.proselint, + -- null_ls.builtins.diagnostics.pylint, + --builtins.diagnostics.selene, + builtins.diagnostics.dotenv_linter, + builtins.diagnostics.shellcheck.with({ + -- shell script diagnostics + diagnostic_config = { + -- see :help vim.diagnostic.config() + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, + severity_sort = true, + }, + diagnostics_format = "[#{c}] #{m} (#{s})", + -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), + builtins.diagnostics.zsh.with({ + filetypes = "zsh", + "sh", + }), + builtins.diagnostics.todo_comments, + builtins.diagnostics.teal, + -- null_ls.builtins.diagnostics.vale, + builtins.diagnostics.vint, + builtins.diagnostics.tidy, + builtins.diagnostics.php, + builtins.diagnostics.phpcs, + builtins.diagnostics.flake8, + builtins.diagnostics.eslint_d.with({ + condition = function(utils) + return utils.root_has_file(".eslintrc.json") + end, + }), + builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, + + -- Formatting + builtins.formatting.shfmt.with({ + filetypes = { "bash", "zsh", "sh" }, + extra_args = { "-i", "2", "-ci" }, + }), + 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.rustfmt, + builtins.formatting.sql_formatter, + -- null_ls.builtins.formatting.cmake_format, + builtins.formatting.isort, + builtins.formatting.htmlbeautifier, + -- null_ls.builtins.formatting.prettier, + builtins.formatting.prettierd, + builtins.formatting.prettier.with({ + filetypes = { + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "json", + "yaml", + "markdown", + "html", + "css", + "scss", + "less", + "graphql", + "vue", + "svelte", + }, + extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, + }), + builtins.formatting.rustfmt, + builtins.formatting.stylua, + --builtins.formatting.dart_format, + builtins.formatting.dart_format.with({ + filetypes = { "dart" }, + }), + builtins.formatting.trim_whitespace, + builtins.formatting.yapf, + -- null_ls.builtins.formatting.black + + -- Code Actions + builtins.code_actions.shellcheck, -- shell script code actions + --builtins.code_actions.eslint_d.with(eslint_opts), + -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, + + -- Hover + builtins.hover.dictionary, + builtins.hover.printenv, + } + --}) + -- Linters/Formatters ensure installed + --for _, pkg_name in ipairs({ + -- "dart-debug-Adaptor", + -- "stylua", + -- "prettier", + -- "prettierd", + --}) do + + -- Import the builtins table from the null-ls module and store it in the null_ls_sources variable + null_ls.setup({ + sources = sources, + update_in_insert = true, + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) + end end, - }), - builtins.formatting.eslint_d, - -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, - - -- Formatting - builtins.formatting.shfmt.with({ - filetypes = { "bash", "zsh", "sh" }, - extra_args = { "-i", "2", "-ci" }, - }), - 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.rustfmt, - builtins.formatting.sql_formatter, - -- null_ls.builtins.formatting.cmake_format, - builtins.formatting.isort, - builtins.formatting.htmlbeautifier, - -- null_ls.builtins.formatting.prettier, - builtins.formatting.prettierd, - builtins.formatting.prettier.with({ - filetypes = { - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "json", - "yaml", - "markdown", - "html", - "css", - "scss", - "less", - "graphql", - "vue", - "svelte", - }, - extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, - }), - builtins.formatting.rustfmt, - builtins.formatting.stylua, - --builtins.formatting.dart_format, - builtins.formatting.dart_format.with({ - filetypes = { "dart" }, - }), - builtins.formatting.trim_whitespace, - builtins.formatting.yapf, - -- null_ls.builtins.formatting.black - - -- Code Actions - builtins.code_actions.shellcheck, -- shell script code actions - --builtins.code_actions.eslint_d.with(eslint_opts), - -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, - builtins.code_actions.gitsigns, - builtins.code_actions.gitrebase, - - -- Hover - builtins.hover.dictionary, - builtins.hover.printenv, -} ---}) --- Linters/Formatters ensure installed ---for _, pkg_name in ipairs({ --- "dart-debug-Adaptor", --- "stylua", --- "prettier", --- "prettierd", ---}) do - --- Import the builtins table from the null-ls module and store it in the null_ls_sources variable -null_ls.setup({ - sources = sources, - update_in_insert = true, - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format() - end, - }) + }) + + -- Install all the null-ls sources using Mason + local registry = require("mason-registry") + for _, source_name in ipairs(sources) do + local ok, pkg = pcall(registry.get_package, source_name) + if ok then + if not pkg:is_installed() then + pkg:install() + end end - end, -}) + end + -- Loop through the null_ls_sources table and install the packages + -- Install all sources for null-ls + --local null_ls_sources = require("null-ls").builtins --- Install all the null-ls sources using Mason -local registry = require("mason-registry") -for _, source_name in ipairs(sources) do - local ok, pkg = pcall(registry.get_package, source_name) - if ok then - if not pkg:is_installed() then - pkg:install() + --for _, source_name in ipairs(null_ls_sources) do + -- local ok, pkg = pcall(mason.get_package, source_name) + -- if ok then + -- if not pkg:is_installed() then + -- pkg:install() + -- end + -- end + --end + vim.api.nvim_create_user_command("NullLsToggle", function() + -- you can also create commands to disable or enable sources + require("null-ls").toggle({}) + end, {}) + + local null_ls_stop = function() + local null_ls_client + for _, client in ipairs(vim.lsp.get_clients()) do + if client.name == "null-ls" then + null_ls_client = client + end end + if not null_ls_client then + return + end + + null_ls_client.stop() end + + vim.api.nvim_create_user_command("NullLsStop", null_ls_stop, {}) + + vim.g.lsp_setup_done = true end --- Loop through the null_ls_sources table and install the packages --- Install all sources for null-ls ---local null_ls_sources = require("null-ls").builtins - ---for _, source_name in ipairs(null_ls_sources) do --- local ok, pkg = pcall(mason.get_package, source_name) --- if ok then --- if not pkg:is_installed() then --- pkg:install() --- end --- end ---end -vim.api.nvim_create_user_command("NullLsToggle", function() - -- you can also create commands to disable or enable sources - require("null-ls").toggle({}) -end, {}) -- cgit v1.2.3 From ba76bc69ea1af1a62614396a8151274bdfc74485 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 10 Aug 2023 23:55:37 +0200 Subject: Installed "smartpde/telescope-recent-files" --- lua/user/pack.lua | 168 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 88 insertions(+), 80 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 177f8d8..10b47ec 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -53,13 +53,13 @@ packer.init({ -- Install plugins here return packer.startup(function(use) -- Defaults - use("wbthomason/packer.nvim") -- Have packer manage itself (package manager) - use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins + use("wbthomason/packer.nvim") -- Have packer manage itself (package manager) + use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins use("lewis6991/impatient.nvim") -- Faster loading/startup times -- Tree-sitter use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... - use("nvim-treesitter/nvim-treesitter-refactor") -- Refactor module for nvim-treesitter + use("nvim-treesitter/nvim-treesitter-refactor") -- Refactor module for nvim-treesitter -- lsp use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters @@ -75,7 +75,7 @@ return packer.startup(function(use) -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim - use("rcarriga/nvim-dap-ui") -- UI for nvim-dap + use("rcarriga/nvim-dap-ui") -- UI for nvim-dap --use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } use("theHamsta/nvim-dap-virtual-text") use("gabrielpoca/replacer.nvim") @@ -91,7 +91,7 @@ return packer.startup(function(use) --}) -- Linters/Formatters - use('mhartington/formatter.nvim') + use("mhartington/formatter.nvim") use("jay-babu/mason-null-ls.nvim") --use({"jayp0521/mason-null-ls.nvim", -- config = function() @@ -106,62 +106,63 @@ return packer.startup(function(use) }) -- Completion - use("hrsh7th/nvim-cmp") -- Completion engine plugin - use("hrsh7th/cmp-nvim-lsp") -- Completion source for nvim-lsp - use("hrsh7th/cmp-buffer") -- Completion source for content of current buffer - use("hrsh7th/cmp-path") -- Completion source for paths - use("hrsh7th/cmp-cmdline") -- Completion source for command-line - use("petertriho/cmp-git") -- Completion source for git - use("tamago324/cmp-zsh") -- Completion source for zsh - use("f3fora/cmp-spell") -- Completion source for spell-checking - use("hrsh7th/cmp-calc") -- Completion source for math calculation - use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip + use("hrsh7th/nvim-cmp") -- Completion engine plugin + use("hrsh7th/cmp-nvim-lsp") -- Completion source for nvim-lsp + use("hrsh7th/cmp-buffer") -- Completion source for content of current buffer + use("hrsh7th/cmp-path") -- Completion source for paths + use("hrsh7th/cmp-cmdline") -- Completion source for command-line + use("petertriho/cmp-git") -- Completion source for git + use("tamago324/cmp-zsh") -- Completion source for zsh + use("f3fora/cmp-spell") -- Completion source for spell-checking + use("hrsh7th/cmp-calc") -- Completion source for math calculation + use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip use("hrsh7th/cmp-nvim-lsp-signature-help") -- Completion source for displaying function signatures with the current parameter emphasized use("rcarriga/cmp-dap") -- Snippets - use("L3MON4D3/LuaSnip") -- Snippet engine + use("L3MON4D3/LuaSnip") -- Snippet engine use("rafamadriz/friendly-snippets") -- Collection of snippets to use -- Git - use("tpope/vim-fugitive") -- + use("tpope/vim-fugitive") -- --use("dinhhuy258/git.nvim") -- For git blame & browse - use("kdheepak/lazygit.nvim") -- Terminal UI for git commands + use("kdheepak/lazygit.nvim") -- Terminal UI for git commands use("lewis6991/gitsigns.nvim") -- Git decorations -- File explorer/fuzzy finder use("kyazdani42/nvim-tree.lua") -- File explorer - use('ibhagwan/fzf-lua') -- Fuzzy finder - use('ThePrimeagen/harpoon') + use("ibhagwan/fzf-lua") -- Fuzzy finder + use("ThePrimeagen/harpoon") --use("nvim-telescope/telescope.nvim") -- Fuzzy finder with lots of features/extendabilities use({ - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', + "nvim-telescope/telescope.nvim", + branch = "0.1.x", --config = function() -- require('plugins.telescope').setup() --end, requires = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope-live-grep-args.nvim', - 'nvim-telescope/telescope-file-browser.nvim', - { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, - } + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-live-grep-args.nvim", + "nvim-telescope/telescope-file-browser.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, + }, }) - use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm - use("nvim-telescope/telescope-ui-select.nvim") -- - use("nvim-telescope/telescope-project.nvim") -- - use("nvim-telescope/telescope-media-files.nvim") -- - use("nvim-telescope/telescope-file-browser.nvim") -- + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm + use("nvim-telescope/telescope-ui-select.nvim") -- + use("nvim-telescope/telescope-project.nvim") -- + use("nvim-telescope/telescope-media-files.nvim") -- + use("nvim-telescope/telescope-file-browser.nvim") -- use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }) -- Search emoji(s) and other symbols use("nvim-telescope/telescope-dap.nvim") - use("axkirillov/telescope-changed-files") -- + use("axkirillov/telescope-changed-files") -- + use("smartpde/telescope-recent-files") -- UX use("folke/neodev.nvim") use({ - 'numToStr/Navigator.nvim', -- Navigate between Tmux and Nvim + "numToStr/Navigator.nvim", -- Navigate between Tmux and Nvim config = function() - require('Navigator').setup() + require("Navigator").setup() end, }) use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }) -- Handy unix commands inside Vim (Rename, Move etc.) @@ -171,24 +172,25 @@ return packer.startup(function(use) --use("vimpostor/vim-tpipeline") -- --use("nathom/filetype.nvim") -- use("mbbill/undotree") - use({ "myusuf3/numbers.vim", -- - vim.cmd("let g:numbers_exclude = ['dashboard']") + use({ + "myusuf3/numbers.vim", -- + vim.cmd("let g:numbers_exclude = ['dashboard']"), }) - use("windwp/nvim-autopairs") -- - use("numToStr/Comment.nvim") -- - use("akinsho/toggleterm.nvim") -- + use("windwp/nvim-autopairs") -- + use("numToStr/Comment.nvim") -- + use("akinsho/toggleterm.nvim") -- use("tweekmonster/startuptime.vim") -- use({ - "ggandor/leap.nvim", -- + "ggandor/leap.nvim", -- config = function() - require('leap').add_default_mappings() + require("leap").add_default_mappings() --require("leap").set_default_keymaps() --vim.keymap.set('n', '-', '(leap-forward)', {}) --vim.keymap.set('n', '_', '(leap-backward)', {}) end, }) use({ - "ggandor/flit.nvim", -- + "ggandor/flit.nvim", -- config = function() require("flit").setup() end, @@ -201,7 +203,8 @@ 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'") }) @@ -228,15 +231,16 @@ return packer.startup(function(use) "nvim-neotest/neotest-plenary", "nvim-neotest/neotest-vim-test", }, - } + }, }) use({ - 'rmagatti/session-lens', - requires = { 'rmagatti/auto-session', 'nvim-telescope/telescope.nvim' }, + "rmagatti/session-lens", + requires = { "rmagatti/auto-session", "nvim-telescope/telescope.nvim" }, config = function() - require('session-lens').setup({ --[[your custom config--]] }) - vim.keymap.set('n', 's', require('session-lens').search_session) -- <-- this sets it to `Ctrl + s` - end + require("session-lens").setup({ --[[your custom config--]] + }) + vim.keymap.set("n", "s", require("session-lens").search_session) -- <-- this sets it to `Ctrl + s` + end, }) -- Colorschemes @@ -247,46 +251,46 @@ return packer.startup(function(use) use("nyngwang/nvimgelion") use("projekt0n/github-nvim-theme") use({ - 'folke/tokyonight.nvim', + "folke/tokyonight.nvim", config = function() - require('tokyonight').setup({ + require("tokyonight").setup({ transparent = true, dim_inactive = false, }) - end + end, }) -- UI - use("kyazdani42/nvim-web-devicons") -- - use("onsails/lspkind-nvim") -- - use({ 'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async' }) -- Fold code + use("kyazdani42/nvim-web-devicons") -- + use("onsails/lspkind-nvim") -- + use({ "kevinhwang91/nvim-ufo", requires = "kevinhwang91/promise-async" }) -- Fold code use({ "luukvbaal/statuscol.nvim", config = function() - local builtin = require "statuscol.builtin" - require("statuscol").setup { + local builtin = require("statuscol.builtin") + require("statuscol").setup({ relculright = true, segments = { { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, { text = { "%s" }, click = "v:lua.ScSa" }, { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, }, - } - end + }) + end, }) use({ - 'glepnir/dashboard-nvim', + "glepnir/dashboard-nvim", --event = 'VimEnter', - requires = { 'nvim-tree/nvim-web-devicons' } + requires = { "nvim-tree/nvim-web-devicons" }, }) - use("rcarriga/nvim-notify") -- Notification plugin - use("karb94/neoscroll.nvim") -- Faster/smooth scrolling + 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({ - 'norcalli/nvim-colorizer.lua', -- colorize hexa and rgb strings - cmd = { 'ColorizerToggle', 'ColorizerAttachToBuffer' }, + "norcalli/nvim-colorizer.lua", -- colorize hexa and rgb strings + cmd = { "ColorizerToggle", "ColorizerAttachToBuffer" }, config = function() - require('colorizer').setup({ + require("colorizer").setup({ --'*'; user_default_options = { RGB = true, @@ -295,31 +299,33 @@ return packer.startup(function(use) RRGGBBAA = false, css = false, css_fn = true, - mode = 'foreground', + mode = "foreground", }, }) - end + end, }) - use({"j-hui/fidget.nvim", - tag = 'legacy', - }) -- UI to show nvim-lsp progress - use({ "simrat39/symbols-outline.nvim", -- + use({ + "j-hui/fidget.nvim", + tag = "legacy", + }) -- UI to show nvim-lsp progress + use({ + "simrat39/symbols-outline.nvim", -- config = function() require("symbols-outline").setup({ auto_close = true, }) - end + end, }) use({ - "kosayoda/nvim-lightbulb", -- + "kosayoda/nvim-lightbulb", -- requires = "antoinemadec/FixCursorHold.nvim", }) use({ "SmiteshP/nvim-navic", -- Statusline/Winbar component that uses LSP to show current code context - requires = "neovim/nvim-lspconfig" + requires = "neovim/nvim-lspconfig", }) use({ - 'rebelot/heirline.nvim', -- Statusline that is highly configurable + "rebelot/heirline.nvim", -- Statusline that is highly configurable --requires = 'kyazdani42/nvim-web-devicons', --event = 'VimEnter', }) @@ -340,7 +346,7 @@ return packer.startup(function(use) "stevearc/dressing.nvim", -- optional for vim.ui.select }, config = function() - require('flutter-tools').setup({ + require("flutter-tools").setup({ debugger = { enabled = true, run_via_dap = true, @@ -350,7 +356,9 @@ return packer.startup(function(use) }) use({ "iamcco/markdown-preview.nvim", -- Markdown Preview - run = function() vim.fn["mkdp#util#install"]() end, + run = function() + vim.fn["mkdp#util#install"]() + end, }) use({ "ellisonleao/glow.nvim", -- Markdown Preview @@ -358,7 +366,7 @@ return packer.startup(function(use) require("glow").setup({ style = "dark", }) - end + end, }) -------------------------------------------------- -- cgit v1.2.3 From 916f367cceddaf39b22287d4331ae7e75328f78f Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 10 Aug 2023 23:57:36 +0200 Subject: New extension "recent_files" --- lua/plugins/telescope.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 72f8a01..6c411d5 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -33,6 +33,7 @@ require("telescope").setup({ --path_display = { "smart" }, file_ignore_patterns = { "packer_compiled.lua", + "~/.config/zsh/plugins", "zcompdump", "%.DS_Store", "%.git/", @@ -288,6 +289,7 @@ require("telescope").load_extension("notify") require("telescope").load_extension("dap") require("telescope").load_extension("session-lens") require("telescope").load_extension("flutter") +require("telescope").load_extension("recent_files") --M.curbuf = function(opts) -- opts = opts -- cgit v1.2.3 From fe58616053dcf9d80da4028dd2a5c4e44befb878 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 20:50:30 +0200 Subject: Moved to $HOME/ --- .editorconfig | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 86067d4..0000000 --- a/.editorconfig +++ /dev/null @@ -1,38 +0,0 @@ -root = true - -[**] -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 -charset = utf-8 - -# TypeScript/JavaScript config -[**.{ts,js}] -indent_size = 2 - -# Json config -[**.json] -indent_size = 2 - -# Lua config -[**.lua] -indent_size = 2 - -# Latex config -[**.tex] -trim_trailing_whitespace = false - -# Markdown config -[**.md] -trim_trailing_whitespace = false - -# Textfile config -[**.txt] -trim_trailing_whitespace = false -insert_final_newline = false - -# Snippets config -[**.snippets] -indent_style = tab -- cgit v1.2.3 From c87d48cc6d298d435ce04bcd9f52b2cfdf762fb5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:36:42 +0200 Subject: Fixed formatting --- lua/user/opts.lua | 83 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index bb7f36c..7af412b 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -1,35 +1,4 @@ --[[ opts.lua ]] --- " Load indent files, to automatically do language-dependent indenting. ---vim.cmd([[ --- "filetype plugin indent on ---]]) - --- Let clipboard register be + -vim.cmd([[ - let g:clipbrdDefaultReg = '+' -]]) - ---vim.cmd([[ --- "autocmd BufEnter * :syntax sync fromstart --- "syntax enable --- "set nocompatible --- "autocmd FileType lua set comments=s1:---,m:--,ex:-- ---]]) - --- Fast macros without lazyredraw -vim.cmd([[ - set re=0 - nnoremap @ execute "noautocmd norm! " . v:count1 . "@" . getcharstr() - xnoremap @ :execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr() -]]) - --- Stop annoying auto commenting on new lines -vim.cmd [[ - augroup annoying - au! - au BufEnter * set fo-=c fo-=r fo-=o - augroup end -]] -- Environment --vim.opt.shell = "zsh" -- @@ -127,19 +96,19 @@ vim.opt.report = 0 -- Always report changed lines. local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") --vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undodir = { prefix .. "/nvim/tmp/.undo//" } -vim.opt.backupdir = { prefix .. "/nvim/tmp/.backup//" } vim.opt.directory = { prefix .. "/nvim/tmp/.swp//" } -vim.opt.backup = false -- ---vim.opt.undofile = false -- +vim.opt.backupdir = { prefix .. "/nvim/tmp/.backup//" } vim.opt.undofile = true -- -vim.opt.swapfile = true -- +vim.opt.swapfile = true -- +vim.opt.backup = true -- +--vim.opt.backupcopy = -- Add timestamp as extension for backup files -vim.api.nvim_create_autocmd('BufWritePre', { - group = vim.api.nvim_create_augroup('timestamp_backupext', { clear = true }), - desc = 'Add timestamp to backup extension', - pattern = '*', +vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("timestamp_backupext", { clear = true }), + desc = "Add timestamp to backup extension", + pattern = "*", callback = function() - vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') + vim.opt.backupext = "-" .. vim.fn.strftime("%Y%m%d%H%M") end, }) @@ -219,7 +188,7 @@ vim.opt.pumheight = 10 -- pop up menu height -- Better Completion vim.opt.complete = { ".", "w", "b", "u", "t" } -- --vim.opt.completeopt = { "longest,menuone,preview" } -- -vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } +vim.opt.completeopt = { "menu", "menuone", "noselect" } --vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp --vim.opt.completeopt = { "menu", "menuone", "noselect" } -- @@ -253,6 +222,38 @@ vim.g.netrw_browse_split = 0 vim.g.netrw_banner = 0 vim.g.netrw_winsize = 25 +-- " Load indent files, to automatically do language-dependent indenting. +--vim.cmd([[ +-- "filetype plugin indent on +--]]) + +-- Let clipboard register be + +vim.cmd([[ + let g:clipbrdDefaultReg = '+' +]]) + +--vim.cmd([[ +-- "autocmd BufEnter * :syntax sync fromstart +-- "syntax enable +-- "set nocompatible +-- "autocmd FileType lua set comments=s1:---,m:--,ex:-- +--]]) + +-- Fast macros without lazyredraw +vim.cmd([[ + set re=0 + nnoremap @ execute "noautocmd norm! " . v:count1 . "@" . getcharstr() + xnoremap @ :execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr() +]]) + +-- Stop annoying auto commenting on new lines +vim.cmd([[ + augroup annoying + au! + au BufEnter * set fo-=c fo-=r fo-=o + augroup end +]]) + -- Cursorline vim.cmd([[ " Only show cursorline in the current window and in normal mode augroup cline -- cgit v1.2.3 From fd7727660bc836779bccd128bef632a40e26dba7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:36:51 +0200 Subject: Fixed formatting --- lua/user/keys.lua | 162 ++++++++++++------------------------------------------ 1 file changed, 34 insertions(+), 128 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 2a4fa6c..54dd59c 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -1,4 +1,5 @@ ---[[ key.lua ]] +--[[ keys.lua ]] + ------------- Shorten Function Names -------------- local keymap = vim.keymap local map = function(mode, l, r, opts) @@ -24,11 +25,7 @@ map("i", "kj", "") --map("n", "", ".") -- Reload nvim config -map( - "n", - "", - "luafile ~/.config/nvim/init.lua | :echom ('Nvim config loading...') | :sl! | echo ('')" -) +map("n", "", "luafile ~/.config/nvim/init.lua | :echom ('Nvim config loading...') | :sl! | echo ('')") --------------- Extended Operations --------------- -- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros @@ -63,8 +60,6 @@ map("n", "m", ":marks") -- Messages map("n", "M", ":messages") --- Clear messages - -- Clear messages or just refresh/redraw the screen map("n", "u", ":echo '' | redraw") @@ -76,18 +71,11 @@ map("n", "$", ":NumbersToggle") map("n", "%", ":NumbersOnOff") -- Easier split navigations, just ctrl-j instead of ctrl-w then j ---map("n", "", "") ---map("n", "", "") ---map("n", "", "") ---map("n", "", "") map("t", "", "") map("t", "", "") map("t", "", "") map("t", "", "") map("t", "", "") ---map("t", "", "") ---map("n", "", "") ---map("n", "", ":call MyFunc(v:count)") -- Split window map("n", "h", ":split") @@ -171,12 +159,8 @@ map("i", "", "") map("n", "", "!clear") -- Change file to an executable -map( - "n", - "x", - ":lua require('user.mods').Toggle_executable() | :echom ('Toggle executable') | :sl! | echo ('')" -) ---map("n", "x", ":!chmod +x %") +map("n", "x", ":lua require('user.mods').Toggle_executable() | :echom ('Toggle executable') | :sl! | echo ('')") +-- map("n", "x", ":!chmod +x %") -- Paste without replace clipboard map("v", "p", '"_dP') @@ -193,29 +177,13 @@ map("n", "o", ":!xdg-open %") -- URL handling if vim.fn.has("mac") == 1 then - map( - "", - "gx", - 'call jobstart(["open", expand("")], {"detach": v:true})', - {} - ) + map("", "gx", 'call jobstart(["open", expand("")], {"detach": v:true})', {}) elseif vim.fn.has("unix") == 1 then - map( - "", - "gx", - 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', - {} - ) + map("", "gx", 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', {}) elseif vim.fn.has("wsl") == 1 then - map( - "", - "gx", - 'call jobstart(["wslview", expand("")], {"detach": v:true})', - {} - ) + map("", "gx", 'call jobstart(["wslview", expand("")], {"detach": v:true})', {}) else - map[""].gx = - { 'lua print("Error: gx is not supported on this OS!")' } + map[""].gx = { 'lua print("Error: gx is not supported on this OS!")' } end -- Substitute globally and locally in the selected region. @@ -250,7 +218,7 @@ map("n", "", "za") -- Make a copy of current file --vim.cmd([[ --- map s :up \| saveas! %:p:r-=strftime("%y.%m.%d-%H:%M")-bak.=expand("%:e") \| 3sleep \| e # +-- map s :up \| saveas! %:p:r-=strftime("%y.%m.%d-%H:%M")-bak.=expand("%:e") \| 3sleep \| e # --]]) map("n", ".b", ":!cp % %.backup") @@ -285,16 +253,6 @@ map("n", "", "NavigatorDown") map({ "n", "t" }, "tt", "ToggleTerm") map({ "n", "t" }, "th", "lua Horizontal_term_toggle()") map({ "n", "t" }, "tv", "lua Vertical_term_toggle()") --- map[""] = { "ToggleTerm", desc = "Toggle terminal" } --- map["tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } --- map["tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } --- map["tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } --- map["tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } --- map["tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } --- map["tf"] = { "ToggleTerm direction=float", desc = "ToggleTerm float" } --- map["th"] = { "ToggleTerm size=10 direction=horizontal", desc = "ToggleTerm horizontal split" } --- map["tv"] = { "ToggleTerm size=80 direction=vertical", desc = "ToggleTerm vertical split" } ---end -- LazyGit map({ "n", "t" }, "gg", "lua Lazygit_toggle()") @@ -325,67 +283,28 @@ map("n", "gm", ":Gmove") map("n", "ff", function() require("telescope.builtin").find_files({ hidden = true, no_ignore = false }) end) -- find all files +map("n", "fF", ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = "Find files in cwd" }) --map("n", "fF", "lua require('telescope.builtin').find_files()") -- find files with hidden option map("n", "fg", "lua require('telescope.builtin').live_grep()") map("n", "fb", "lua require('telescope.builtin').buffers()") map("n", "fh", "lua require('telescope.builtin').help_tags()") map("n", "fc", "lua require('telescope.builtin').commands()") -map( - "n", - "ffc", - "lua require('telescope.builtin').current_buffer_fuzzy_find()" -) +map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") map("n", "cf", "Telescope changed_files") map("n", "fp", "Telescope pickers") -map( - "n", - "fr", - "lua require('telescope.builtin').registers({})" -) -- registers picker -map( - "n", - "fd", - "lua require('telescope.builtin').diagnostics()" -) +map("n", "fd", "lua require('telescope.builtin').diagnostics()") map("n", "fk", "lua require('telescope.builtin').keymaps()") -map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes -map( - "n", - "fgn", - [[lua require'plugins.telescope'.grep_notes()]] -) -- search notes -map( - "n", - "f.", - [[lua require'plugins.telescope'.find_configs()]] -) -- find configs -map( - "n", - "fs", - [[lua require'plugins.telescope'.find_scripts()]] -) -- find scripts -map( - "n", - "fw", - [[lua require'plugins.telescope'.find_projects()]] -) -- find projects -map( - "n", - "fm", - "lua require('telescope').extensions.media_files.media_files({})" -) -- find media files -map( - "n", - "fi", - "lua require('telescope').extensions.notify.notify({})" -) -- find notifications +map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker +map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs +map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts +map("n", "fw", [[lua require'plugins.telescope'.find_projects()]]) -- find projects +map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files +map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find notifications +map("n", "ffr", "lua require('telescope').extensions.recent_files.pick()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- 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 a shortcut to open the picker. -- FZF map("n", "fz", "lua require('fzf-lua').files()") @@ -404,19 +323,10 @@ map("n", "mg", "Glow") map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle -map( - "n", - "zm", - "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')" -) +map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") -- Vim-rooter -map( - "n", - "ro", - "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", - term_opts -) +map("n", "ro", "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", term_opts) -- Trouble (UI to show diagnostics) map("n", "t", "TroubleToggle") @@ -438,7 +348,7 @@ map("n", "q", function() require("plugins.quickfix").close() else require("plugins.quickfix").open() - --require("quickfix").open() + -- require("quickfix").open() end end, { desc = "Toggle quickfix window" }) @@ -457,17 +367,13 @@ vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) map("n", "ds", function() dap.continue() ui.toggle({}) - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes("=", false, true, true), - "n", - false - ) -- Spaces buffers evenly + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) -- Spaces buffers evenly end) -- Set breakpoints, get variable values, step into/out of functions, etc. map("n", "dC", dap.continue) ---map("n", "dC", dap.close) ---map("n", "dt", dap.terminate) +-- map("n", "dC", dap.close) +-- map("n", "dt", dap.terminate) map("n", "dt", ui.toggle) map("n", "dd", function() dap.disconnect({ terminateDebuggee = true }) @@ -503,11 +409,11 @@ end, { desc = "DAP-Telescope: Commands" }) -- Close debugger and clear breakpoints --map("n", "de", function() --- dap.clear_breakpoints() --- ui.toggle({}) --- dap.terminate() --- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) --- require("notify")("Debugger session ended", "warn") +-- dap.clear_breakpoints() +-- ui.toggle({}) +-- dap.terminate() +-- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) +-- require("notify")("Debugger session ended", "warn") --end) -- Dashboard -- cgit v1.2.3 From 7e3f32f105b0f32c252c8851e5604b1422c931ae Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:37:00 +0200 Subject: Fixed formatting --- lua/plugins/lsp.lua | 367 ++++++++++++++-------------------------------------- 1 file changed, 99 insertions(+), 268 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 2eba05f..d94052f 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,37 +1,22 @@ local lspconfig = require("lspconfig") local mason_lspconfig = require("mason-lspconfig") local null_ls = require("null-ls") ---local lsp_lines = require('lsp_lines') +-- local lsp_lines = require('lsp_lines') require("mason").setup() -require("mason-null-ls").setup({ - handlers = {}, - ensure_installed = nil, - automatic_installation = true, - automatic_setup = true, -}) +require("mason-null-ls").setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, automatic_setup = true }) local keymap = vim.keymap local cmd = vim.cmd -local border = { - { "┌", "FloatBorder" }, - { "─", "FloatBorder" }, - { "┐", "FloatBorder" }, - { "│", "FloatBorder" }, - { "┘", "FloatBorder" }, - { "─", "FloatBorder" }, - { "└", "FloatBorder" }, - { "│", "FloatBorder" }, -} +local border = { { "┌", "FloatBorder" }, { "─", "FloatBorder" }, { "┐", "FloatBorder" }, { "│", "FloatBorder" }, { "┘", "FloatBorder" }, { "─", "FloatBorder" }, + { "└", "FloatBorder" }, { "│", "FloatBorder" } } -- Set up LSP servers if not done before if not vim.g.lsp_setup_done then -- Clear existing LSP clients for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do local clients = vim.lsp.get_clients({ buffer = bufnr }) - for _, client in ipairs(clients) do - client.stop() - end + for _, client in ipairs(clients) do client.stop() end end local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } @@ -40,9 +25,9 @@ if not vim.g.lsp_setup_done then vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end - --lsp_lines.setup() + -- lsp_lines.setup() - --vim.keymap.set("n", "g?", function() + -- vim.keymap.set("n", "g?", function() -- local lines_enabled = not vim.diagnostic.config().virtual_lines -- vim.diagnostic.config( -- { @@ -50,37 +35,28 @@ if not vim.g.lsp_setup_done then -- virtual_text = not lines_enabled -- } -- ) - --end, { noremap = true, silent = true }) + -- end, { noremap = true, silent = true }) vim.diagnostic.config({ underline = false, signs = true, - virtual_text = true, - --virtual_lines = { only_current_line = true }, + virtual_text = true, -- virtual_lines = { only_current_line = true }, virtual_lines = false, float = { show_header = true, - source = "if_many", - --border = 'rounded', + source = "if_many", -- border = 'rounded', border = border, - focusable = true, + focusable = true }, - update_in_insert = false, -- default to false - severity_sort = false, -- default to false + update_in_insert = false, -- default to false + severity_sort = false -- default to false }) - vim.lsp.handlers["textDocument/publishDiagnostics"] = - vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - underline = false, - virtual_text = false, - signs = true, - update_in_insert = false, - }) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, + { underline = false, virtual_text = false, signs = true, update_in_insert = false }) - vim.lsp.handlers["textDocument/hover"] = - vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) - vim.lsp.handlers["textDocument/signatureHelp"] = - vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer local on_attach = function(client, bufnr) @@ -95,50 +71,28 @@ if not vim.g.lsp_setup_done then end -- Mappings map("n", "K", "lua vim.lsp.buf.hover()") - --map("n", "gd", "lua vim.lsp.buf.definition()") - map( - "n", - "gd", - "lua require('goto-preview').goto_preview_definition()" - ) - --map("n", "gi", "lua vim.lsp.buf.implementation()") - map( - "n", - "gi", - "lua require('goto-preview').goto_preview_implementation()" - ) - --map("n", "gr", "lua vim.lsp.buf.references()") - map( - "n", - "gr", - "lua require('goto-preview').goto_preview_references()" - ) + -- map("n", "gd", "lua vim.lsp.buf.definition()") + map("n", "gd", "lua require('goto-preview').goto_preview_definition()") + -- map("n", "gi", "lua vim.lsp.buf.implementation()") + map("n", "gi", "lua require('goto-preview').goto_preview_implementation()") + -- map("n", "gr", "lua vim.lsp.buf.references()") + map("n", "gr", "lua require('goto-preview').goto_preview_references()") map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. map("n", "k", "lua vim.lsp.buf.signature_help()") - --map("n", "gt", "lua vim.lsp.buf.type_definition()") - map( - "n", - "gt", - "lua require('goto-preview').goto_preview_type_definition()" - ) + -- map("n", "gt", "lua vim.lsp.buf.type_definition()") + 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", "go", "lua vim.diagnostic.open_float()") - map( - "n", - "go", - ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')" - ) + map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") map("n", "[d", "lua vim.diagnostic.goto_prev()") map("n", "]d", "lua vim.diagnostic.goto_next()") map("n", "gs", "lua vim.lsp.buf.document_symbol()") map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - map("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end) + map("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) -- TODO: Use the nicer new API for autocommands cmd("augroup lsp_aucmds") @@ -187,43 +141,19 @@ augroup END asm_lsp = {}, bashls = {}, clangd = {}, - cssls = { - filetypes = { "css", "scss", "less", "sass" }, - root_dir = lspconfig.util.root_pattern("package.json", ".git"), - }, - -- ghcide = {}, + cssls = { filetypes = { "css", "scss", "less", "sass" }, root_dir = lspconfig.util.root_pattern("package.json", ".git") }, -- ghcide = {}, html = {}, jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, intelephense = {}, julials = { on_new_config = function(new_config, _) - local julia = - vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") - if lspconfig.util.path.is_file(julia) then - new_config.cmd[1] = julia - end + local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") + if lspconfig.util.path.is_file(julia) then new_config.cmd[1] = julia end end, - settings = { julia = { format = { indent = 2 } } }, - }, - pyright = { - settings = { - python = { - formatting = { provider = "yapf" }, - linting = { pytypeEnabled = true }, - }, - }, - }, - rust_analyzer = { - settings = { - ["rust-analyzer"] = { - cargo = { allFeatures = true }, - checkOnSave = { - command = "clippy", - extraArgs = { "--no-deps" }, - }, - }, - }, + settings = { julia = { format = { indent = 2 } } } }, + pyright = { settings = { python = { formatting = { provider = "yapf" }, linting = { pytypeEnabled = true } } } }, + rust_analyzer = { settings = { ["rust-analyzer"] = { cargo = { allFeatures = true }, checkOnSave = { command = "clippy", extraArgs = { "--no-deps" } } } } }, dartls = { cmd = { "dart", "language-server", "--protocol=lsp" }, filetypes = { "dart" }, @@ -232,16 +162,10 @@ augroup END flutterOutline = true, onlyAnalyzeProjectsWithOpenFiles = true, outline = true, - suggestFromUnimportedLibraries = true, - }, - -- root_dir = root_pattern("pubspec.yaml"), - settings = { - dart = { - completeFunctionCalls = true, - showTodos = true, - }, - }, - on_attach = function(client, bufnr) end, + suggestFromUnimportedLibraries = true + }, -- root_dir = root_pattern("pubspec.yaml"), + settings = { dart = { completeFunctionCalls = true, showTodos = true } }, + on_attach = function(client, bufnr) end }, lua_ls = { on_attach = on_attach, @@ -249,55 +173,36 @@ augroup END debounce_text_changes = 500, settings = { Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - enable = true, - globals = { "vim" }, - }, - workspace = { - maxPreload = 2000, - preloadFileSize = 50000, - checkThirdParty = false, - }, - }, - }, + runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, + diagnostics = { enable = true, globals = { "vim" } }, + workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false } + } + } }, sqlls = {}, tsserver = { - capabilities = require("cmp_nvim_lsp").default_capabilities( - vim.lsp.protocol.make_client_capabilities() - ), + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), on_attach = function(client) client.server_capabilities.document_formatting = false client.server_capabilities.document_range_formatting = false end, - filetypes = { - "javascript", - "javascriptreact", - "javascript.jsx", - "typescript", - "typescriptreact", - "typescript.tsx", - }, + filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" } }, vimls = {}, - yamlls = {}, + yamlls = {} } mason_lspconfig.setup({ - ensure_installed = servers, -- will be installed by mason - automatic_installation = true, + ensure_installed = servers, -- will be installed by mason + automatic_installation = true }) -- Your other configurations ... - --require("lspconfig").dartls.setup({ capabilities = capabilities }) - --local installed_lsp = mason_lspconfig.ensure_installed - --local mason_lspconfig = require("mason-lspconfig").ensure_installed + -- require("lspconfig").dartls.setup({ capabilities = capabilities }) + -- local installed_lsp = mason_lspconfig.ensure_installed + -- local mason_lspconfig = require("mason-lspconfig").ensure_installed - --require("lspconfig").setup({ + -- require("lspconfig").setup({ -- function() -- for _, lsp in ipairs(installed_lsp) do -- if @@ -315,7 +220,7 @@ augroup END -- end -- end -- end, - --}) + -- }) for server, config in pairs(servers) do if config.prefer_null_ls then @@ -339,129 +244,71 @@ augroup END local builtins = null_ls.builtins local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - --local eslint_opts = { + -- local eslint_opts = { -- -- condition = function(utils) -- -- return utils.root_has_file ".eslintrc.js" or utils.root_has_file ".eslintrc" or utils.root_has_file ".eslintrc.json" -- -- end, -- -- diagnostics_format = "#{m} [#{c}]", -- prefer_local = true, - --} - - --null_ls.setup({ - local sources = { - -- Diagnostics - builtins.diagnostics.chktex, - --null_ls.builtins.code_actions.eslint_d, - --null_ls.builtins.diagnostics.eslint_d, - --null_ls.builtins.formatting.eslint_d, + -- } + + -- null_ls.setup({ + local sources = { -- Diagnostics + builtins.diagnostics.chktex, -- null_ls.builtins.code_actions.eslint_d, + -- null_ls.builtins.diagnostics.eslint_d, + -- null_ls.builtins.formatting.eslint_d, -- null_ls.builtins.diagnostics.cppcheck, -- null_ls.builtins.diagnostics.proselint, -- null_ls.builtins.diagnostics.pylint, - --builtins.diagnostics.selene, - builtins.diagnostics.dotenv_linter, - builtins.diagnostics.shellcheck.with({ - -- shell script diagnostics - diagnostic_config = { - -- see :help vim.diagnostic.config() - underline = true, - virtual_text = false, - signs = true, - update_in_insert = false, - severity_sort = true, - }, - diagnostics_format = "[#{c}] #{m} (#{s})", - -- this will run every time the source runs, - -- so you should prefer caching results if possible - }), - builtins.diagnostics.zsh.with({ - filetypes = "zsh", - "sh", - }), - builtins.diagnostics.todo_comments, - builtins.diagnostics.teal, + -- builtins.diagnostics.selene, + builtins.diagnostics.dotenv_linter, builtins.diagnostics.shellcheck.with({ -- shell script diagnostics + diagnostic_config = { -- see :help vim.diagnostic.config() + underline = true, virtual_text = false, signs = true, update_in_insert = false, severity_sort = true }, + diagnostics_format = "[#{c}] #{m} (#{s})" -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), builtins.diagnostics.zsh.with({ filetypes = "zsh", "sh" }), builtins.diagnostics.todo_comments, builtins.diagnostics.teal, -- null_ls.builtins.diagnostics.vale, - builtins.diagnostics.vint, - builtins.diagnostics.tidy, - builtins.diagnostics.php, - builtins.diagnostics.phpcs, - builtins.diagnostics.flake8, - builtins.diagnostics.eslint_d.with({ - condition = function(utils) - return utils.root_has_file(".eslintrc.json") - end, - }), - builtins.formatting.eslint_d, + builtins.diagnostics.vint, builtins.diagnostics.tidy, builtins.diagnostics.php, builtins.diagnostics.phpcs, builtins.diagnostics.flake8, + builtins.diagnostics.eslint_d.with({ condition = function(utils) return utils.root_has_file(".eslintrc.json") end }), builtins.formatting.eslint_d, -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, -- Formatting - builtins.formatting.shfmt.with({ - filetypes = { "bash", "zsh", "sh" }, - extra_args = { "-i", "2", "-ci" }, - }), - 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.rustfmt, - builtins.formatting.sql_formatter, + builtins.formatting.shfmt.with({ filetypes = { "bash", "zsh", "sh" }, extra_args = { "-i", "2", "-ci" } }), 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.rustfmt, builtins.formatting.sql_formatter, -- null_ls.builtins.formatting.cmake_format, - builtins.formatting.isort, - builtins.formatting.htmlbeautifier, - -- null_ls.builtins.formatting.prettier, + builtins.formatting.isort, builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, builtins.formatting.prettierd, builtins.formatting.prettier.with({ - filetypes = { - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "json", - "yaml", - "markdown", - "html", - "css", - "scss", - "less", - "graphql", - "vue", - "svelte", - }, - extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", "css", + "scss", "less", "graphql", "vue", "svelte" }, + extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" } + }), builtins.formatting.rustfmt, + -- builtins.formatting.stylua, + -- builtins.formatting.lua_format, + builtins.formatting.stylua.with({ + filetypes = { "lua" }, + command = "stylua", + args = { "--indent-width", "2", "--column-width", "160", "--indent-type", "Spaces", "-" } }), - builtins.formatting.rustfmt, - builtins.formatting.stylua, - --builtins.formatting.dart_format, - builtins.formatting.dart_format.with({ - filetypes = { "dart" }, - }), - builtins.formatting.trim_whitespace, - builtins.formatting.yapf, + -- builtins.formatting.dart_format, + builtins.formatting.dart_format.with({ filetypes = { "dart" } }), builtins.formatting.trim_whitespace, builtins.formatting.yapf, -- null_ls.builtins.formatting.black -- Code Actions builtins.code_actions.shellcheck, -- shell script code actions - --builtins.code_actions.eslint_d.with(eslint_opts), + -- builtins.code_actions.eslint_d.with(eslint_opts), -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, - builtins.code_actions.gitsigns, - builtins.code_actions.gitrebase, - - -- Hover - builtins.hover.dictionary, - builtins.hover.printenv, - } - --}) + builtins.code_actions.gitsigns, builtins.code_actions.gitrebase, -- Hover + builtins.hover.dictionary, builtins.hover.printenv } + -- }) -- Linters/Formatters ensure installed - --for _, pkg_name in ipairs({ + -- for _, pkg_name in ipairs({ -- "dart-debug-Adaptor", -- "stylua", -- "prettier", -- "prettierd", - --}) do + -- }) do -- Import the builtins table from the null-ls module and store it in the null_ls_sources variable null_ls.setup({ @@ -470,39 +317,29 @@ augroup END on_attach = function(client, bufnr) if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format() - end, - }) + vim.api.nvim_create_autocmd("BufWritePre", { group = augroup, buffer = bufnr, callback = function() vim.lsp.buf.format() end }) end - end, + end }) -- Install all the null-ls sources using Mason local registry = require("mason-registry") for _, source_name in ipairs(sources) do local ok, pkg = pcall(registry.get_package, source_name) - if ok then - if not pkg:is_installed() then - pkg:install() - end - end + if ok then if not pkg:is_installed() then pkg:install() end end end -- Loop through the null_ls_sources table and install the packages -- Install all sources for null-ls - --local null_ls_sources = require("null-ls").builtins + -- local null_ls_sources = require("null-ls").builtins - --for _, source_name in ipairs(null_ls_sources) do + -- for _, source_name in ipairs(null_ls_sources) do -- local ok, pkg = pcall(mason.get_package, source_name) -- if ok then -- if not pkg:is_installed() then -- pkg:install() -- end -- end - --end + -- end vim.api.nvim_create_user_command("NullLsToggle", function() -- you can also create commands to disable or enable sources require("null-ls").toggle({}) @@ -510,14 +347,8 @@ augroup END local null_ls_stop = function() local null_ls_client - for _, client in ipairs(vim.lsp.get_clients()) do - if client.name == "null-ls" then - null_ls_client = client - end - end - if not null_ls_client then - return - end + for _, client in ipairs(vim.lsp.get_clients()) do if client.name == "null-ls" then null_ls_client = client end end + if not null_ls_client then return end null_ls_client.stop() end -- cgit v1.2.3 From efb0b96a87920426387367e071b4a94e94cf3303 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:37:09 +0200 Subject: Fixed formatting --- init.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 08f5cf7..d3fb064 100644 --- a/init.lua +++ b/init.lua @@ -49,7 +49,6 @@ if impatient_ok then impatient.enable_profile() end - -- Schedule reading shadafile to improve the startup time vim.opt.shadafile = "NONE" vim.schedule(function() @@ -57,7 +56,6 @@ vim.schedule(function() vim.cmd("silent! rsh") end) - -- Load/reload modules local modules = { "user.pack", -- Packer plugin manager @@ -98,17 +96,15 @@ local modules = { --"plugins.modify-blend", } - -- Refresh module cache for k, v in pairs(modules) do package.loaded[v] = nil require(v) end - -- Check if we have the latest stable version of nvim local mods = require("user.mods") -local expected_ver = "0.9.0" +local expected_ver = "0.10.0" local nvim_ver = mods.get_nvim_version() if nvim_ver ~= expected_ver then @@ -117,7 +113,6 @@ if nvim_ver ~= expected_ver then return end - -- Snippets vim.g.snippets = "luasnip" -- cgit v1.2.3 From de81cd8f047c7d985d44032c029c61f33fc1526b Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:37:24 +0200 Subject: Moved .ssh to find_script() --- lua/plugins/telescope.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 6c411d5..3678d27 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -321,22 +321,25 @@ function M.find_configs() "~/.config/picom", "~/.config/polybar", "~/.bashrc", - "~/.ssh", "~/.vim", "~/.profile", "~/.zprofile", + "~/.gitconfig", + "~/.gitsubtrees", + "~/.gitignore", + "~/.editorconfig", + "~/.prettierrc.yml", "~/README.md", }, - -- cwd = "~/.config/nvim/", file_ignore_patterns = { - "~/.config/nvim/startup.log", - "~/.config/zsh/plugins", + "/nvim/startup.log", + "zsh/plugins", "packer_compiled.lua", "resurrect", "tmux/plugins", --"^~/.config/tmux/plugins", "%.txt", - ".git", + ".git/", "autoload/plugged", "plug.vim", "zcompdump", @@ -353,6 +356,7 @@ function M.find_scripts() prompt_title = " Find Scripts", path_display = { "smart" }, search_dirs = { + "~/.ssh", "~/.local/bin/scripts", }, layout_strategy = "horizontal", -- cgit v1.2.3 From 00793fa99d4ec41a0fe5e8c38d8042efb51ef151 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:37:38 +0200 Subject: Testing a bunch of rules --- after/ftplugin/markdown.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua index ec30702..5bf3f16 100644 --- a/after/ftplugin/markdown.lua +++ b/after/ftplugin/markdown.lua @@ -1,2 +1,11 @@ +vim.wo.spell = true +vim.bo.spelllang = "en" +vim.wo.wrap = true +vim.wo.linebreak = true +vim.wo.breakindent = true +vim.wo.colorcolumn = "0" +vim.wo.conceallevel = 3 vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. + +vim.b[0].undo_ftplugin = "setlocal nospell nowrap nolinebreak nobreakindent conceallevel=0" -- cgit v1.2.3 From 2384135982f3629e76573773e32a7a57a6cbca4c Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:37:56 +0200 Subject: Fixed weird formatting/wrapping --- autoload/utils.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/autoload/utils.vim b/autoload/utils.vim index 1ca005f..fc078f7 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -147,4 +147,20 @@ function! utils#GotoJump() endfunction +"------------------------------------------------- + +" Disable annoying auto line break +fu! utils#DisableBr() + set wrap + set linebreak + set nolist " list disables linebreak + set textwidth=0 + set wrapmargin=0 + set formatoptions-=t +endfu + +" Disable line breaks for all file types +autocmd! BufNewFile,BufRead *.* call utils#DisableBr() + + "------------------------------------------------- -- cgit v1.2.3 From a679b99e0938d185d390ffc47252d29cc2bbf4f7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:38:57 +0200 Subject: Fixed formatting --- lua/user/mods.lua | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 2f14acd..49d3065 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -24,10 +24,8 @@ M.has = function(feat) return false end - -------------------------------------------------- - -- Format on save local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) require("null-ls").setup({ @@ -48,18 +46,25 @@ require("null-ls").setup({ end, }) - -------------------------------------------------- ---Determine if a value of any type is empty ---@param item any ---@return boolean? function M.empty(item) - if not item then return true end + if not item then + return true + end local item_type = type(item) - if item_type == 'string' then return item == '' end - if item_type == 'number' then return item <= 0 end - if item_type == 'table' then return vim.tbl_isempty(item) end + if item_type == "string" then + return item == "" + end + if item_type == "number" then + return item <= 0 + end + if item_type == "table" then + return vim.tbl_isempty(item) + end return item ~= nil end @@ -105,7 +110,6 @@ M.toggle_completion = function() end end - -------------------------------------------------- --- Make sure using latest neovim version @@ -165,6 +169,7 @@ function M.findFilesInCwd() 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() @@ -175,17 +180,17 @@ end -- Toggle the executable permission function M.Toggle_executable() - local current_file = vim.fn.expand('%:p') + 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) + 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) + vim.fn.system("chmod +x " .. current_file) --print(current_file .. ' is now executable.') print("Now executable") end @@ -234,34 +239,34 @@ function M.Set_git_env_vars() end end -vim.cmd [[augroup my_git_env_vars]] -vim.cmd [[ autocmd!]] -vim.cmd [[ autocmd BufEnter * lua require('user.mods').Set_git_env_vars()]] -vim.cmd [[ autocmd VimEnter * lua require('user.mods').Set_git_env_vars()]] -vim.cmd [[augroup END]] +vim.cmd([[augroup my_git_env_vars]]) +vim.cmd([[ autocmd!]]) +vim.cmd([[ autocmd BufEnter * lua require('user.mods').Set_git_env_vars()]]) +vim.cmd([[ autocmd VimEnter * lua require('user.mods').Set_git_env_vars()]]) +vim.cmd([[augroup END]]) -------------------------------------------------- -vim.cmd [[autocmd BufWritePre lua vim.lsp.buf.format()]] +vim.cmd([[autocmd BufWritePre lua vim.lsp.buf.format()]]) --vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] -------------------------------------------------- --- Update Tmux Status Vi-mode function M.update_tmux_status() - local mode = vim.api.nvim_eval('mode()') + local mode = vim.api.nvim_eval("mode()") -- Determine the mode name based on the mode value local mode_name - if mode == 'n' then - mode_name = '-- NORMAL --' - elseif mode == 'i' or mode == 'ic' then - mode_name = '-- INSERT --' + if mode == "n" then + mode_name = "-- NORMAL --" + elseif mode == "i" or mode == "ic" then + mode_name = "-- INSERT --" else - mode_name = '-- NORMAL --' --'-- COMMAND --' + mode_name = "-- NORMAL --" --'-- COMMAND --' end -- Write the mode name to the file - local file = io.open(os.getenv('HOME') .. '/.vi-mode', 'w') + local file = io.open(os.getenv("HOME") .. "/.vi-mode", "w") file:write(mode_name) file:close() if nvim_running then @@ -311,8 +316,6 @@ vim.cmd([[ -- -- vim.api.nvim_create_user_command('OpenEmulators', OpenEmulatorList, {}) - - --local api = vim.api --local fn = vim.fn --local cmd = vim.cmd @@ -414,8 +417,7 @@ function M.Update_neovim() -- 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") + 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 @@ -441,8 +443,6 @@ function M.Update_neovim() end -- Bind a keymap to the update_neovim function (optional) -vim.api.nvim_set_keymap('n', 'U', ' lua require("user.mods").Update_neovim()', - { noremap = true, silent = true }) - +vim.api.nvim_set_keymap("n", "U", ' lua require("user.mods").Update_neovim()', { noremap = true, silent = true }) return M -- cgit v1.2.3 From da19dad2906121c01c973b7502872137a8ce75dc Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:55:20 +0200 Subject: Fix weird closing error message --- lua/user/mods.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 49d3065..191d5ab 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -46,6 +46,9 @@ require("null-ls").setup({ end, }) +vim.cmd([[autocmd BufWritePre lua vim.lsp.buf.format()]]) +--vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] + -------------------------------------------------- ---Determine if a value of any type is empty @@ -247,11 +250,6 @@ vim.cmd([[augroup END]]) -------------------------------------------------- -vim.cmd([[autocmd BufWritePre lua vim.lsp.buf.format()]]) ---vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] - --------------------------------------------------- - --- Update Tmux Status Vi-mode function M.update_tmux_status() local mode = vim.api.nvim_eval("mode()") @@ -300,6 +298,7 @@ vim.cmd([[ --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() @@ -445,4 +444,15 @@ end -- Bind a keymap to the update_neovim function (optional) vim.api.nvim_set_keymap("n", "U", ' lua require("user.mods").Update_neovim()', { noremap = true, silent = true }) +-------------------------------------------------- + +-- Fix closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) +vim.api.nvim_create_autocmd({ "VimLeave" }, { + callback = function() + vim.fn.jobstart('notify-send "hello"', { detach = true }) + end, +}) + +-------------------------------------------------- + return M -- cgit v1.2.3 From cc720cb1b9e0a547577e9a1585be900e7e3966ea Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 11 Aug 2023 22:56:08 +0200 Subject: Fixed formatting --- lua/plugins/lsp.lua | 146 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index d94052f..4ce5610 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -8,15 +8,16 @@ require("mason-null-ls").setup({ handlers = {}, ensure_installed = nil, automati local keymap = vim.keymap local cmd = vim.cmd -local border = { { "┌", "FloatBorder" }, { "─", "FloatBorder" }, { "┐", "FloatBorder" }, { "│", "FloatBorder" }, { "┘", "FloatBorder" }, { "─", "FloatBorder" }, - { "└", "FloatBorder" }, { "│", "FloatBorder" } } +local border = { { "┌", "FloatBorder" }, { "─", "FloatBorder" }, { "┐", "FloatBorder" }, { "│", "FloatBorder" }, { "┘", "FloatBorder" }, { "─", "FloatBorder" }, { "└", "FloatBorder" }, { "│", "FloatBorder" } } -- Set up LSP servers if not done before if not vim.g.lsp_setup_done then -- Clear existing LSP clients for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do local clients = vim.lsp.get_clients({ buffer = bufnr }) - for _, client in ipairs(clients) do client.stop() end + for _, client in ipairs(clients) do + client.stop() + end end local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } @@ -40,20 +41,19 @@ if not vim.g.lsp_setup_done then vim.diagnostic.config({ underline = false, signs = true, - virtual_text = true, -- virtual_lines = { only_current_line = true }, + virtual_text = true, -- virtual_lines = { only_current_line = true }, virtual_lines = false, float = { show_header = true, - source = "if_many", -- border = 'rounded', + source = "if_many", -- border = 'rounded', border = border, - focusable = true + focusable = true, }, - update_in_insert = false, -- default to false - severity_sort = false -- default to false + update_in_insert = false, -- default to false + severity_sort = false, -- default to false }) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, - { underline = false, virtual_text = false, signs = true, update_in_insert = false }) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) @@ -92,7 +92,9 @@ if not vim.g.lsp_setup_done then map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - map("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) + map("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end) -- TODO: Use the nicer new API for autocommands cmd("augroup lsp_aucmds") @@ -141,16 +143,18 @@ augroup END asm_lsp = {}, bashls = {}, clangd = {}, - cssls = { filetypes = { "css", "scss", "less", "sass" }, root_dir = lspconfig.util.root_pattern("package.json", ".git") }, -- ghcide = {}, + cssls = { filetypes = { "css", "scss", "less", "sass" }, root_dir = lspconfig.util.root_pattern("package.json", ".git") }, -- ghcide = {}, html = {}, jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, intelephense = {}, julials = { on_new_config = function(new_config, _) local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") - if lspconfig.util.path.is_file(julia) then new_config.cmd[1] = julia end + if lspconfig.util.path.is_file(julia) then + new_config.cmd[1] = julia + end end, - settings = { julia = { format = { indent = 2 } } } + settings = { julia = { format = { indent = 2 } } }, }, pyright = { settings = { python = { formatting = { provider = "yapf" }, linting = { pytypeEnabled = true } } } }, rust_analyzer = { settings = { ["rust-analyzer"] = { cargo = { allFeatures = true }, checkOnSave = { command = "clippy", extraArgs = { "--no-deps" } } } } }, @@ -162,10 +166,10 @@ augroup END flutterOutline = true, onlyAnalyzeProjectsWithOpenFiles = true, outline = true, - suggestFromUnimportedLibraries = true - }, -- root_dir = root_pattern("pubspec.yaml"), + suggestFromUnimportedLibraries = true, + }, -- root_dir = root_pattern("pubspec.yaml"), settings = { dart = { completeFunctionCalls = true, showTodos = true } }, - on_attach = function(client, bufnr) end + on_attach = function(client, bufnr) end, }, lua_ls = { on_attach = on_attach, @@ -175,9 +179,9 @@ augroup END Lua = { runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, diagnostics = { enable = true, globals = { "vim" } }, - workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false } - } - } + workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false }, + }, + }, }, sqlls = {}, tsserver = { @@ -186,15 +190,15 @@ augroup END client.server_capabilities.document_formatting = false client.server_capabilities.document_range_formatting = false end, - filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" } + filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, }, vimls = {}, - yamlls = {} + yamlls = {}, } mason_lspconfig.setup({ - ensure_installed = servers, -- will be installed by mason - automatic_installation = true + ensure_installed = servers, -- will be installed by mason + automatic_installation = true, }) -- Your other configurations ... @@ -253,7 +257,7 @@ augroup END -- } -- null_ls.setup({ - local sources = { -- Diagnostics + local sources = { -- Diagnostics builtins.diagnostics.chktex, -- null_ls.builtins.code_actions.eslint_d, -- null_ls.builtins.diagnostics.eslint_d, -- null_ls.builtins.formatting.eslint_d, @@ -261,46 +265,74 @@ augroup END -- null_ls.builtins.diagnostics.proselint, -- null_ls.builtins.diagnostics.pylint, -- builtins.diagnostics.selene, - builtins.diagnostics.dotenv_linter, builtins.diagnostics.shellcheck.with({ -- shell script diagnostics - diagnostic_config = { -- see :help vim.diagnostic.config() - underline = true, virtual_text = false, signs = true, update_in_insert = false, severity_sort = true }, - diagnostics_format = "[#{c}] #{m} (#{s})" -- this will run every time the source runs, - -- so you should prefer caching results if possible - }), builtins.diagnostics.zsh.with({ filetypes = "zsh", "sh" }), builtins.diagnostics.todo_comments, builtins.diagnostics.teal, + builtins.diagnostics.dotenv_linter, + builtins.diagnostics.shellcheck.with({ -- shell script diagnostics + diagnostic_config = { -- see :help vim.diagnostic.config() + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, + severity_sort = true, + }, + diagnostics_format = "[#{c}] #{m} (#{s})", -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), + builtins.diagnostics.zsh.with({ filetypes = "zsh", "sh" }), + builtins.diagnostics.todo_comments, + builtins.diagnostics.teal, -- null_ls.builtins.diagnostics.vale, - builtins.diagnostics.vint, builtins.diagnostics.tidy, builtins.diagnostics.php, builtins.diagnostics.phpcs, builtins.diagnostics.flake8, - builtins.diagnostics.eslint_d.with({ condition = function(utils) return utils.root_has_file(".eslintrc.json") end }), builtins.formatting.eslint_d, + builtins.diagnostics.vint, + builtins.diagnostics.tidy, + builtins.diagnostics.php, + builtins.diagnostics.phpcs, + builtins.diagnostics.flake8, + builtins.diagnostics.eslint_d.with({ + condition = function(utils) + return utils.root_has_file(".eslintrc.json") + end, + }), + builtins.formatting.eslint_d, -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, -- Formatting - builtins.formatting.shfmt.with({ filetypes = { "bash", "zsh", "sh" }, extra_args = { "-i", "2", "-ci" } }), builtins.formatting.shellharden, + builtins.formatting.shfmt.with({ filetypes = { "bash", "zsh", "sh" }, extra_args = { "-i", "2", "-ci" } }), + 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.rustfmt, builtins.formatting.sql_formatter, + builtins.formatting.beautysh.with({ filetypes = "zsh" }), + builtins.formatting.clang_format, + builtins.formatting.rustfmt, + builtins.formatting.sql_formatter, -- null_ls.builtins.formatting.cmake_format, - builtins.formatting.isort, builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, + builtins.formatting.isort, + builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, builtins.formatting.prettierd, builtins.formatting.prettier.with({ - filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", "css", - "scss", "less", "graphql", "vue", "svelte" }, - extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" } - }), builtins.formatting.rustfmt, + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", "css", "scss", "less", "graphql", "vue", "svelte" }, + extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, + }), + builtins.formatting.rustfmt, -- builtins.formatting.stylua, -- builtins.formatting.lua_format, builtins.formatting.stylua.with({ filetypes = { "lua" }, command = "stylua", - args = { "--indent-width", "2", "--column-width", "160", "--indent-type", "Spaces", "-" } + args = { "--indent-width", "2", "--column-width", "160", "--indent-type", "Spaces", "-" }, }), -- builtins.formatting.dart_format, - builtins.formatting.dart_format.with({ filetypes = { "dart" } }), builtins.formatting.trim_whitespace, builtins.formatting.yapf, + builtins.formatting.dart_format.with({ filetypes = { "dart" } }), + builtins.formatting.trim_whitespace, + builtins.formatting.yapf, -- null_ls.builtins.formatting.black -- Code Actions builtins.code_actions.shellcheck, -- shell script code actions -- builtins.code_actions.eslint_d.with(eslint_opts), -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, - builtins.code_actions.gitsigns, builtins.code_actions.gitrebase, -- Hover - builtins.hover.dictionary, builtins.hover.printenv } + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, -- Hover + builtins.hover.dictionary, + builtins.hover.printenv, + } -- }) -- Linters/Formatters ensure installed -- for _, pkg_name in ipairs({ @@ -317,16 +349,26 @@ augroup END on_attach = function(client, bufnr) if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { group = augroup, buffer = bufnr, callback = function() vim.lsp.buf.format() end }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) end - end + end, }) -- Install all the null-ls sources using Mason local registry = require("mason-registry") for _, source_name in ipairs(sources) do local ok, pkg = pcall(registry.get_package, source_name) - if ok then if not pkg:is_installed() then pkg:install() end end + if ok then + if not pkg:is_installed() then + pkg:install() + end + end end -- Loop through the null_ls_sources table and install the packages -- Install all sources for null-ls @@ -347,8 +389,14 @@ augroup END local null_ls_stop = function() local null_ls_client - for _, client in ipairs(vim.lsp.get_clients()) do if client.name == "null-ls" then null_ls_client = client end end - if not null_ls_client then return end + for _, client in ipairs(vim.lsp.get_clients()) do + if client.name == "null-ls" then + null_ls_client = client + end + end + if not null_ls_client then + return + end null_ls_client.stop() end -- cgit v1.2.3 From d97d57fd65ca8cfdcd6f0b88097a0b4bb4077a44 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 16 Aug 2023 23:53:12 +0200 Subject: Changed error diagnostic sign --- lua/plugins/lsp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 4ce5610..5cca919 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -20,7 +20,8 @@ if not vim.g.lsp_setup_done then end end - local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } + local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } + --  for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -- cgit v1.2.3 From b7d19ba636d82472c3d27c1627b59aefa7ccd071 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 16 Aug 2023 23:53:46 +0200 Subject: Changed custom mapping of substitute --- lua/user/keys.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 54dd59c..2e6546e 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -187,8 +187,8 @@ else end -- Substitute globally and locally in the selected region. -map("n", "ss", ":%s//g") -map("v", "ss", ":s//g") +map("n", "ss", ":%s//g") +map("v", "ss", ":s//g") -- Toggle completion map("n", "tc", ":lua require('user.mods').toggle_completion()") @@ -310,7 +310,8 @@ map("n", "ffr", "lua require('telescope').extensions.recent_files.p map("n", "fz", "lua require('fzf-lua').files()") -- Nvim-tree -map("n", "f", ":NvimTreeToggle", {}) +map("n", "f", "Rooter:NvimTreeToggle", {}) +map("n", "", ":NvimTreeFindFileToggle", { noremap = false, silent = true }) -- Undotree map("n", "u", vim.cmd.UndotreeToggle) -- cgit v1.2.3 From 30c3774031d393bcb4d21975412759bc93fb9684 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 16 Aug 2023 23:55:58 +0200 Subject: Various functions related to nvim-tree --- lua/user/mods.lua | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 191d5ab..60e6ed8 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -449,10 +449,97 @@ vim.api.nvim_set_keymap("n", "U", ' lua require("user.mods").Update -- Fix closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) vim.api.nvim_create_autocmd({ "VimLeave" }, { callback = function() - vim.fn.jobstart('notify-send "hello"', { detach = true }) + vim.cmd("silent! !notify-send 'hello' >/dev/null 2>&1 &") end, }) -------------------------------------------------- +vim.cmd([[autocmd BufEnter * lua vim.cmd('Rooter')]]) + +-- nvim-tree is also there in modified buffers so this function filter it out +local modifiedBufs = function(bufs) + local t = 0 + for k, v in pairs(bufs) do + if v.name:match("NvimTree_") == nil then + t = t + 1 + end + end + return t +end + +function M.DeleteCurrentBuffer() + local cbn = vim.api.nvim_get_current_buf() + local buffers = vim.fn.getbufinfo({ buflisted = true }) + local size = #buffers + local idx = 0 + + for n, e in ipairs(buffers) do + if e.bufnr == cbn then + idx = n + break -- Exit loop as soon as we find the buffer + end + end + + if idx == 0 then + return + end + + if idx == size then + vim.cmd("bprevious") + else + vim.cmd("bnext") + end + + vim.cmd("silent! bdelete " .. cbn) + + -- Open a new blank window + vim.cmd("silent! enew") -- Opens a new vertical split + -- OR + -- vim.cmd("new") -- Opens a new horizontal split + -- Delay before opening a new split + --vim.defer_fn(function() + -- vim.cmd("enew") -- Opens a new vertical split + --end, 100) -- Adjust the delay as needed (in milliseconds) + -- Delay before closing the nvim-tree window +end + +-- +vim.cmd([[autocmd FileType NvimTree lua require("user.mods").DeleteCurrentBuffer()]]) +-- On :bd nvim-tree should behave as if it wasn't opened +vim.api.nvim_create_autocmd("BufEnter", { + nested = true, + callback = function() + -- Only 1 window with nvim-tree left: we probably closed a file buffer + if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then + local api = require("nvim-tree.api") + -- Required to let the close event complete. An error is thrown without this. + vim.defer_fn(function() + -- close nvim-tree: will go to the last buffer used before closing + api.tree.toggle({ find_file = true, focus = true }) + -- re-open nivm-tree + api.tree.toggle({ find_file = true, focus = true }) + -- nvim-tree is still the active window. Go to the previous window. + vim.cmd("wincmd p") + end, 0) + end + end, +}) + +-- Autocmd to dismiss notifications when opening nvim-tree window +local function isNvimTreeOpen() + local win = vim.fn.win_findbuf(vim.fn.bufnr("NvimTree")) + return vim.fn.empty(win) == 0 +end + +function M.DisableNotify() + if isNvimTreeOpen() then + require("notify").dismiss() + end +end + +vim.cmd([[ + autocmd! WinEnter,WinLeave * lua require('user.mods').DisableNotify() +]]) + return M -- cgit v1.2.3 From 98bc6f9a151430d49fc4bfd7096cef78b6abdc7c Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 16 Aug 2023 23:58:03 +0200 Subject: Various changes to nvim-tree and improve layout of config --- lua/plugins/nvim-tree.lua | 325 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 243 insertions(+), 82 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index e2298b5..31c77a3 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -1,104 +1,268 @@ -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then - return -end +----------------------------------------------------------- +-- Neovim File Tree Configuration +----------------------------------------------------------- -local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not config_status_ok then - return -end +--- To see mappings `g?` on nvim-tree +--- To see default mappings `:nvim-tree-default-mappings` -local tree_cb = nvim_tree_config.nvim_tree_callback +local icons = { + git_placement = "after", + modified_placement = "after", + padding = " ", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + modified = true, + }, --- To see mappings `g?` on nvim-tree --- To see default mappings `:nvim-tree-default-mappings` + glyphs = { + default = "󰈔", + symlink = "", + folder = { + arrow_open = "", + arrow_closed = "", + default = " ", + open = " ", + empty = " ", + empty_open = " ", + symlink = "", + symlink_open = "", + }, + git = { + deleted = "", + unmerged = "", + untracked = "", + unstaged = "", + staged = "", + renamed = "➜", + ignored = "◌", + }, + }, +} -nvim_tree.setup({ - update_focused_file = { +local renderer = { + indent_width = 2, + indent_markers = { enable = true, - update_cwd = true, - }, - git = { - enable = true, - ignore = false, - timeout = 500, -}, - renderer = { - root_folder_modifier = ":t", - indent_markers = { - enable = true, - }, + inline_arrows = true, icons = { - glyphs = { - default = "", - symlink = "", - folder = { - arrow_open = "", - arrow_closed = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - untracked = "U", - deleted = "", - ignored = "◌", - }, - }, + corner = "└", + edge = "│", + item = "│", + bottom = "─", + none = " ", }, }, + icons = icons, +} + +local system_open = { cmd = "zathura" } + +local HEIGHT_RATIO = 0.8 +local WIDTH_RATIO = 0.15 + +local float = { + enable = false, + open_win_config = function() + local screen_w = vim.opt.columns:get() + local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() + local window_w = screen_w * WIDTH_RATIO + local window_h = screen_h * HEIGHT_RATIO + local window_w_int = math.floor(window_w) + local window_h_int = math.floor(window_h) + local center_x = (screen_w - window_w) / 2 + local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() + return { + border = "rounded", + relative = "editor", + row = center_y, + col = center_x, + width = window_w_int, + height = window_h_int, + } + end, +} + +local view = { + cursorline = false, + hide_root_folder = false, + float = float, + signcolumn = "no", + width = function() + return math.floor(vim.opt.columns:get() * WIDTH_RATIO) + end, + side = "left", +} + +local api = require("nvim-tree.api") +local function on_attach(bufnr) + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + local mappings = { + [""] = { api.tree.change_root_to_node, "CD" }, + [""] = { api.node.open.replace_tree_buffer, "Open: In Place" }, + [""] = { api.node.show_info_popup, "Info" }, + [""] = { api.fs.rename_sub, "Rename: Omit Filename" }, + [""] = { api.node.open.tab, "Open: New Tab" }, + [""] = { api.node.open.vertical, "Open: Vertical Split" }, + [""] = { api.node.open.horizontal, "Open: Horizontal Split" }, + [""] = { api.node.navigate.parent_close, "Close Directory" }, + -- [""] = { api.node.open.edit, "Open" }, + [""] = { api.node.open.preview, "Open Preview" }, + [">"] = { api.node.navigate.sibling.next, "Next Sibling" }, + ["<"] = { api.node.navigate.sibling.prev, "Previous Sibling" }, + ["."] = { api.node.run.cmd, "Run Command" }, + ["-"] = { api.tree.change_root_to_parent, "Up" }, + ["a"] = { api.fs.create, "Create" }, + ["bmv"] = { api.marks.bulk.move, "Move Bookmarked" }, + ["B"] = { api.tree.toggle_no_buffer_filter, "Toggle No Buffer" }, + ["c"] = { api.fs.copy.node, "Copy" }, + -- ["C"] = { api.tree.toggle_git_clean_filter, "Toggle Git Clean" }, + ["[c"] = { api.node.navigate.git.prev, "Prev Git" }, + ["]c"] = { api.node.navigate.git.next, "Next Git" }, + ["d"] = { api.fs.remove, "Delete" }, + ["D"] = { api.fs.trash, "Trash" }, + ["E"] = { api.tree.expand_all, "Expand All" }, + ["e"] = { api.fs.rename_basename, "Rename: Basename" }, + ["]e"] = { api.node.navigate.diagnostics.next, "Next Diagnostic" }, + ["[e"] = { api.node.navigate.diagnostics.prev, "Prev Diagnostic" }, + ["F"] = { api.live_filter.clear, "Clean Filter" }, + ["f"] = { api.live_filter.start, "Filter" }, + ["g?"] = { api.tree.toggle_help, "Help" }, + ["gy"] = { api.fs.copy.absolute_path, "Copy Absolute Path" }, + ["H"] = { api.tree.toggle_hidden_filter, "Toggle Dotfiles" }, + ["I"] = { api.tree.toggle_gitignore_filter, "Toggle Git Ignore" }, + ["J"] = { api.node.navigate.sibling.last, "Last Sibling" }, + ["K"] = { api.node.navigate.sibling.first, "First Sibling" }, + ["m"] = { api.marks.toggle, "Toggle Bookmark" }, + -- ["o"] = { api.node.open.edit, "Open" }, + ["O"] = { api.node.open.no_window_picker, "Open: No Window Picker" }, + ["p"] = { api.fs.paste, "Paste" }, + ["P"] = { api.node.navigate.parent, "Parent Directory" }, + ["q"] = { api.tree.close, "Close" }, + ["r"] = { api.fs.rename, "Rename" }, + ["R"] = { api.tree.reload, "Refresh" }, + ["s"] = { api.node.run.system, "Run System" }, + ["S"] = { api.tree.search_node, "Search" }, + ["U"] = { api.tree.toggle_custom_filter, "Toggle Hidden" }, + ["W"] = { api.tree.collapse_all, "Collapse" }, + ["x"] = { api.fs.cut, "Cut" }, + ["y"] = { api.fs.copy.filename, "Copy Name" }, + ["Y"] = { api.fs.copy.relative_path, "Copy Relative Path" }, + ["<2-LeftMouse>"] = { api.node.open.edit, "Open" }, + ["<2-RightMouse>"] = { api.tree.change_root_to_node, "CD" }, + + -- Mappings migrated from view.mappings.list + ["l"] = { api.node.open.edit, "Open" }, + [""] = { api.node.open.edit, "Open" }, + ["o"] = { api.node.open.edit, "Open" }, + ["h"] = { api.node.navigate.parent_close, "Close Directory" }, + ["v"] = { api.node.open.vertical, "Open: Vertical Split" }, + ["C"] = { api.tree.change_root_to_node, "CD" }, + } + for keys, mapping in pairs(mappings) do + vim.keymap.set("n", keys, mapping[1], opts(mapping[2])) + end +end +api.events.subscribe(api.events.Event.FileCreated, function(file) + vim.cmd("edit" .. file.fname) +end) + +require("nvim-tree").setup({ + disable_netrw = true, + hijack_netrw = true, + auto_reload_on_write = true, + update_focused_file = { + enable = true, + update_cwd = false, + update_root = false, + ignore_list = {}, + }, + root_dirs = {}, + prefer_startup_root = true, + hijack_cursor = true, + --hijack_directories = { + -- enable = false, + --}, + --respect_buf_cwd = false, + sync_root_with_cwd = true, + --reload_on_bufenter = false, + view = view, + system_open = system_open, + renderer = renderer, + on_attach = on_attach, + notify = { + threshold = vim.log.levels.ERROR, + }, + git = { ignore = false }, diagnostics = { enable = true, show_on_dirs = true, icons = { - hint = "", - info = "", - warning = "", + hint = "⚑", + info = "􀅳", + warning = "▲", error = "", }, }, - view = { - width = 30, - --height = 30, - side = "left", - --mappings = { - -- list = { - -- { key = { "l", "", "o" }, cb = tree_cb("edit") }, - -- { key = "h", cb = tree_cb("close_node") }, - -- { key = "v", cb = tree_cb("vsplit") }, - -- { key = "u", action = "dir_up" }, - -- }, - --}, - }, trash = { cmd = "gio trash", require_confirm = true, }, + modified = { + enable = false, + show_on_dirs = true, + show_on_open_dirs = true, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, + }, + remove_file = { + close_window = true, + }, + open_file = { + quit_on_open = true, + resize_window = false, + window_picker = { + enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, + }, + }, }) -vim.api.nvim_create_autocmd("QuitPre", { - callback = function() - local invalid_win = {} - local wins = vim.api.nvim_list_wins() - for _, w in ipairs(wins) do - local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) - if bufname:match("NvimTree_") ~= nil then - table.insert(invalid_win, w) - end - end - if #invalid_win == #wins - 1 then - -- Should quit, so we close all invalid windows. - for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end - end +local api = require("nvim-tree.api") +local event = api.events.Event +api.events.subscribe(event.TreeOpen, function(_) + vim.cmd([[setlocal statuscolumn=\ ]]) + vim.cmd([[setlocal cursorlineopt=number]]) + vim.cmd([[setlocal fillchars+=vert:🮇]]) + vim.cmd([[setlocal fillchars+=horizup:🮇]]) + vim.cmd([[setlocal fillchars+=vertright:🮇]]) +end) + +local function open_nvim_tree(data) + vim.cmd.cd(data.file:match("(.+)/[^/]*$")) + local directory = vim.fn.isdirectory(data.file) == 1 + if not directory then + return end -}) + require("nvim-tree.api").tree.open() +end +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + -- Highlight Groups vim.api.nvim_command("highlight NvimTreeNormal guibg=none") --vim.api.nvim_command("highlight NvimTreeSymlink ") @@ -137,7 +301,6 @@ vim.api.nvim_command("highlight NvimTreeNormal guibg=none") --vim.api.nvim_command("highlight NvimTreeWinSeparator ") --(WinSeparator) --vim.api.nvim_command("highlight NvimTreeCursorColumn ") --(CursorColumn) - --vim.api.nvim_command("highlight NvimTreeFileDirty ") --(NvimTreeGitDirty) --vim.api.nvim_command("highlight NvimTreeFileStaged ") --(NvimTreeGitStaged) --vim.api.nvim_command("highlight NvimTreeFileMerge ") --(NvimTreeGitMerge) @@ -146,9 +309,7 @@ vim.api.nvim_command("highlight NvimTreeNormal guibg=none") --vim.api.nvim_command("highlight NvimTreeFileDeleted ") --(NvimTreeGitDeleted) --vim.api.nvim_command("highlight NvimTreeFileIgnored ") --(NvimTreeGitIgnored) - --vim.api.nvim_command("highlight NvimTreeLiveFilterPrefix ") --vim.api.nvim_command("highlight NvimTreeLiveFilterValue ") - --vim.api.nvim_command("highlight NvimTreeBookmark ") -- cgit v1.2.3 From 2a422765edf2b73f55a23109462d3b52d2ea3583 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 17 Aug 2023 22:09:39 +0200 Subject: Toggle dashboard mapping --- lua/user/keys.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 2e6546e..5d45a99 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -417,8 +417,8 @@ end, { desc = "DAP-Telescope: Commands" }) -- require("notify")("Debugger session ended", "warn") --end) --- Dashboard -map("n", "", "Dashboard") +-- Toggle Dashboard +map("n", "", "lua require('user.mods').toggle_dashboard()") -- Lsp Lines toggle map("", "l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) -- cgit v1.2.3 From c63e45a190bb041e5295f563171641b487496653 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 17 Aug 2023 22:09:52 +0200 Subject: Toggle dashboard function --- lua/user/mods.lua | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 60e6ed8..1370ce9 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -446,19 +446,22 @@ vim.api.nvim_set_keymap("n", "U", ' lua require("user.mods").Update -------------------------------------------------- --- Fix closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) +-- Fix or suppress closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) vim.api.nvim_create_autocmd({ "VimLeave" }, { callback = function() - vim.cmd("silent! !notify-send 'hello' >/dev/null 2>&1 &") + vim.fn.jobstart("!notify-send 2>/dev/null &", { detach = true }) end, }) -------------------------------------------------- +-- Rooter vim.cmd([[autocmd BufEnter * lua vim.cmd('Rooter')]]) --- nvim-tree is also there in modified buffers so this function filter it out -local modifiedBufs = function(bufs) +-------------------------------------------------- + +-- Nvim-tree +local modifiedBufs = function(bufs) -- nvim-tree is also there in modified buffers so this function filter it out local t = 0 for k, v in pairs(bufs) do if v.name:match("NvimTree_") == nil then @@ -468,6 +471,7 @@ local modifiedBufs = function(bufs) return t end +-- Deleting current file opened behaviour function M.DeleteCurrentBuffer() local cbn = vim.api.nvim_get_current_buf() local buffers = vim.fn.getbufinfo({ buflisted = true }) @@ -504,8 +508,8 @@ function M.DeleteCurrentBuffer() -- Delay before closing the nvim-tree window end --- vim.cmd([[autocmd FileType NvimTree lua require("user.mods").DeleteCurrentBuffer()]]) + -- On :bd nvim-tree should behave as if it wasn't opened vim.api.nvim_create_autocmd("BufEnter", { nested = true, @@ -526,7 +530,7 @@ vim.api.nvim_create_autocmd("BufEnter", { end, }) --- Autocmd to dismiss notifications when opening nvim-tree window +-- Dismiss notifications when opening nvim-tree window local function isNvimTreeOpen() local win = vim.fn.win_findbuf(vim.fn.bufnr("NvimTree")) return vim.fn.empty(win) == 0 @@ -542,4 +546,26 @@ vim.cmd([[ autocmd! WinEnter,WinLeave * lua require('user.mods').DisableNotify() ]]) +-------------------------------------------------- + +-- Toggle Dashboard +local is_dashboard_open = false +local previous_bufnr = nil + +function M.toggle_dashboard() + if is_dashboard_open then + vim.cmd("Dashboard") + is_dashboard_open = false + if previous_bufnr then + vim.cmd("buffer " .. previous_bufnr) + end + else + previous_bufnr = vim.fn.bufnr("%") + vim.cmd("Dashboard") + is_dashboard_open = true + end +end + +-------------------------------------------------- + return M -- cgit v1.2.3 From 96e2f165f58edbbeaca38db005fd92e4734137a5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 17 Aug 2023 22:11:39 +0200 Subject: Add commented out highlight group options --- lua/plugins/dashboard.lua | 116 ++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index b288f46..46c15ec 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -1,4 +1,5 @@ local db = require("dashboard") + --vim.api.nvim_create_autocmd("VimEnter", { -- callback = function() -- -- disable line numbers @@ -7,69 +8,72 @@ local db = require("dashboard") -- -- always start in insert mode -- end, --}) + db.setup({ - theme = "hyper", - config = { - header = { - [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], - [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], - [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], - [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], - [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], - [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], - }, + theme = "hyper", + config = { + header = { + [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], + [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], + [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], + [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], + [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], + [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], + }, disable_move = false, - shortcut = { - { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, - --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, - { - desc = " Files", + shortcut = { + { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, + { + desc = " Files", group = "Number", - --group = "Label", - action = "Telescope find_files", - key = "f", - }, - { - desc = " Text", + --group = "Label", + action = "Telescope find_files", + key = "f", + }, + { + desc = " Text", group = "Number", - --group = "Label", - action = 'enew', - key = "t", - }, - { - desc = " Grep", + --group = "Label", + action = "enew", + key = "t", + }, + { + desc = " Grep", group = "Number", - --group = "Label", - action = "Telescope live_grep", - key = "g", - }, - { - desc = " Scheme", + --group = "Label", + action = "Telescope live_grep", + key = "g", + }, + { + desc = " Scheme", group = "Number", - --group = "Label", - action = "Telescope colorscheme", - key = "s", - }, - { - desc = ' Config', + --group = "Label", + action = "Telescope colorscheme", + key = "s", + }, + { + desc = " Config", group = "Number", - --group = "Label", - action = ':edit ~/.config.nvim/init.lua', + --group = "Label", + action = ":edit ~/.config.nvim/init.lua", key = "c", - }, - }, - }, - hide = { - statusline = false, - tabline = false, - winbar = false, - }, - -- preview = { --- command, -- preview command --- file_path, -- preview file path --- file_height, -- preview file height --- file_width, -- preview file width --- }, --- footer = {} --your footer + }, + }, + footer = { "", "Hello World!" }, + }, + hide = { + statusline = false, + tabline = false, + winbar = false, + }, }) +--highlights +---- General +--DashboardHeader DashboardFooter +---- Hyper theme +--DashboardProjectTitle DashboardProjectTitleIcon DashboardProjectIcon +--DashboardMruTitle DashboardMruIcon DashboardFiles DashboardShotCutIcon +---- Doome theme +--DashboardDesc DashboardKey DashboardIcon DashboardShotCut -- cgit v1.2.3 From 4d54e319bba3687a011c02466a9a278684565180 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 18 Aug 2023 21:35:01 +0200 Subject: Helper function to suppress errors --- lua/user/mods.lua | 201 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 114 insertions(+), 87 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 1370ce9..457ec74 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -27,13 +27,13 @@ end -------------------------------------------------- -- Format on save -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -require("null-ls").setup({ +local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) +require('null-ls').setup({ -- you can reuse a shared lspconfig on_attach callback here on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then + if client.supports_method('textDocument/formatting') then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { + vim.api.nvim_create_autocmd('BufWritePre', { group = augroup, buffer = bufnr, callback = function() @@ -59,13 +59,13 @@ function M.empty(item) return true end local item_type = type(item) - if item_type == "string" then - return item == "" + if item_type == 'string' then + return item == '' end - if item_type == "number" then + if item_type == 'number' then return item <= 0 end - if item_type == "table" then + if item_type == 'table' then return vim.tbl_isempty(item) end return item ~= nil @@ -78,7 +78,7 @@ function M.may_create_dir(dir) local res = fn.isdirectory(dir) if res == 0 then - fn.mkdir(dir, "p") + fn.mkdir(dir, 'p') end end @@ -87,16 +87,16 @@ end --- Toggle cmp completion vim.g.cmp_toggle_flag = false -- initialize local normal_buftype = function() - return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" + return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' end M.toggle_completion = function() - local ok, cmp = pcall(require, "cmp") + local ok, cmp = pcall(require, 'cmp') if ok then local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag if next_cmp_toggle_flag then - print("completion on") + print('completion on') else - print("completion off") + print('completion off') end cmp.setup({ enabled = function() @@ -109,7 +109,7 @@ M.toggle_completion = function() end, }) else - print("completion not available") + print('completion not available') end end @@ -119,31 +119,56 @@ end function M.get_nvim_version() local actual_ver = vim.version() - local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) + local nvim_ver_str = string.format('%d.%d.%d', actual_ver.major, actual_ver.minor, actual_ver.patch) return nvim_ver_str end function M.add_pack(name) - local status, error = pcall(vim.cmd, "packadd " .. name) + local status, error = pcall(vim.cmd, 'packadd ' .. name) return status end -------------------------------------------------- +-- Define a global function to retrieve LSP clients based on Neovim version +function M.get_lsp_clients(bufnr) + local mods = require('user.mods') + local expected_ver = '0.10.0' + local nvim_ver = mods.get_nvim_version() + + --if nvim_ver ~= expected_ver then + -- local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) + -- vim.api.nvim_err_writeln(msg) + -- return + --end + + local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') + version_major = tonumber(version_major) + version_minor = tonumber(version_minor) + + if version_major > 0 or (version_major == 0 and version_minor >= 10) then + return vim.lsp.get_clients({ buffer = bufnr }) + else + return vim.lsp.buf_get_clients() + end +end + +-------------------------------------------------- + --- Toggle autopairs on/off (requires "windwp/nvim-autopairs") function M.Toggle_autopairs() - local ok, autopairs = pcall(require, "nvim-autopairs") + local ok, autopairs = pcall(require, 'nvim-autopairs') if ok then if autopairs.state.disabled then autopairs.enable() - print("autopairs on") + print('autopairs on') else autopairs.disable() - print("autopairs off") + print('autopairs off') end else - print("autopairs not available") + print('autopairs not available') end end @@ -166,10 +191,10 @@ 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 = 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 + vim.cmd('let g:rooter_manual_only = 0') -- Change back to automatic rooter end, 100) end @@ -183,19 +208,19 @@ end -- Toggle the executable permission function M.Toggle_executable() - local current_file = vim.fn.expand("%:p") + 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) + vim.fn.system('chmod -x ' .. current_file) --print(current_file .. ' is no longer executable.') - print("No longer executable") + print('No longer executable') else -- File is not executable, set the executable permission - vim.fn.system("chmod +x " .. current_file) + vim.fn.system('chmod +x ' .. current_file) --print(current_file .. ' is now executable.') - print("Now executable") + print('Now executable') end end @@ -220,21 +245,21 @@ end ------ -local prev_cwd = "" +local prev_cwd = '' function M.Set_git_env_vars() local cwd = vim.fn.getcwd() - if prev_cwd == "" then + if prev_cwd == '' then -- First buffer being opened, set prev_cwd to cwd prev_cwd = cwd elseif cwd ~= prev_cwd then -- Working directory has changed since last buffer was opened prev_cwd = cwd - local git_dir_job = vim.fn.jobstart({ "git", "rev-parse", "--git-dir" }) + local git_dir_job = vim.fn.jobstart({ 'git', 'rev-parse', '--git-dir' }) local command_status = vim.fn.jobwait({ git_dir_job })[1] if command_status > 0 then - vim.env.GIT_DIR = vim.fn.expand("$HOME/.cfg") - vim.env.GIT_WORK_TREE = vim.fn.expand("~") + vim.env.GIT_DIR = vim.fn.expand('$HOME/.cfg') + vim.env.GIT_WORK_TREE = vim.fn.expand('~') else vim.env.GIT_DIR = nil vim.env.GIT_WORK_TREE = nil @@ -252,28 +277,28 @@ vim.cmd([[augroup END]]) --- Update Tmux Status Vi-mode function M.update_tmux_status() - local mode = vim.api.nvim_eval("mode()") + local mode = vim.api.nvim_eval('mode()') -- Determine the mode name based on the mode value local mode_name - if mode == "n" then - mode_name = "-- NORMAL --" - elseif mode == "i" or mode == "ic" then - mode_name = "-- INSERT --" + if mode == 'n' then + mode_name = '-- NORMAL --' + elseif mode == 'i' or mode == 'ic' then + mode_name = '-- INSERT --' else - mode_name = "-- NORMAL --" --'-- COMMAND --' + mode_name = '-- NORMAL --' --'-- COMMAND --' end -- Write the mode name to the file - local file = io.open(os.getenv("HOME") .. "/.vi-mode", "w") + local file = io.open(os.getenv('HOME') .. '/.vi-mode', 'w') file:write(mode_name) 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 - vim.cmd("silent !tmux refresh-client -S") + VI_MODE = '' -- Clear VI_MODE to show Neovim mode + vim.cmd('silent !tmux refresh-client -S') end ---- Force tmux to update the status - vim.cmd("silent !tmux refresh-client -S") + vim.cmd('silent !tmux refresh-client -S') end vim.cmd([[ @@ -398,42 +423,42 @@ 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", + relative = 'editor', width = 80, height = 20, row = 2, col = 2, - style = "minimal", - border = "single", + 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_option(bufnr, 'modifiable', true) vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { line }) - vim.api.nvim_buf_set_option(bufnr, "modifiable", false) + 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.") + 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.") + 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.") + 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.") + 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() @@ -442,14 +467,14 @@ function M.Update_neovim() end -- Bind a keymap to the update_neovim function (optional) -vim.api.nvim_set_keymap("n", "U", ' lua require("user.mods").Update_neovim()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'U', ' lua require("user.mods").Update_neovim()', { noremap = true, silent = true }) -------------------------------------------------- -- Fix or suppress closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) -vim.api.nvim_create_autocmd({ "VimLeave" }, { +vim.api.nvim_create_autocmd({ 'VimLeave' }, { callback = function() - vim.fn.jobstart("!notify-send 2>/dev/null &", { detach = true }) + vim.fn.jobstart('!notify-send 2>/dev/null &', { detach = true }) end, }) @@ -464,7 +489,7 @@ vim.cmd([[autocmd BufEnter * lua vim.cmd('Rooter')]]) local modifiedBufs = function(bufs) -- nvim-tree is also there in modified buffers so this function filter it out local t = 0 for k, v in pairs(bufs) do - if v.name:match("NvimTree_") == nil then + if v.name:match('NvimTree_') == nil then t = t + 1 end end @@ -490,15 +515,15 @@ function M.DeleteCurrentBuffer() end if idx == size then - vim.cmd("bprevious") + vim.cmd('bprevious') else - vim.cmd("bnext") + vim.cmd('bnext') end - vim.cmd("silent! bdelete " .. cbn) + vim.cmd('silent! bdelete ' .. cbn) -- Open a new blank window - vim.cmd("silent! enew") -- Opens a new vertical split + vim.cmd('silent! enew') -- Opens a new vertical split -- OR -- vim.cmd("new") -- Opens a new horizontal split -- Delay before opening a new split @@ -511,12 +536,12 @@ end vim.cmd([[autocmd FileType NvimTree lua require("user.mods").DeleteCurrentBuffer()]]) -- On :bd nvim-tree should behave as if it wasn't opened -vim.api.nvim_create_autocmd("BufEnter", { +vim.api.nvim_create_autocmd('BufEnter', { nested = true, callback = function() -- Only 1 window with nvim-tree left: we probably closed a file buffer - if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then - local api = require("nvim-tree.api") + if #vim.api.nvim_list_wins() == 1 and require('nvim-tree.utils').is_nvim_tree_buf() then + local api = require('nvim-tree.api') -- Required to let the close event complete. An error is thrown without this. vim.defer_fn(function() -- close nvim-tree: will go to the last buffer used before closing @@ -524,7 +549,7 @@ vim.api.nvim_create_autocmd("BufEnter", { -- re-open nivm-tree api.tree.toggle({ find_file = true, focus = true }) -- nvim-tree is still the active window. Go to the previous window. - vim.cmd("wincmd p") + vim.cmd('wincmd p') end, 0) end end, @@ -532,13 +557,13 @@ vim.api.nvim_create_autocmd("BufEnter", { -- Dismiss notifications when opening nvim-tree window local function isNvimTreeOpen() - local win = vim.fn.win_findbuf(vim.fn.bufnr("NvimTree")) + local win = vim.fn.win_findbuf(vim.fn.bufnr('NvimTree')) return vim.fn.empty(win) == 0 end function M.DisableNotify() if isNvimTreeOpen() then - require("notify").dismiss() + require('notify').dismiss() end end @@ -549,23 +574,25 @@ vim.cmd([[ -------------------------------------------------- -- Toggle Dashboard -local is_dashboard_open = false -local previous_bufnr = nil - function M.toggle_dashboard() - if is_dashboard_open then - vim.cmd("Dashboard") - is_dashboard_open = false - if previous_bufnr then - vim.cmd("buffer " .. previous_bufnr) - end + if vim.bo.filetype == 'dashboard' then + vim.cmd('bdelete') else - previous_bufnr = vim.fn.bufnr("%") - vim.cmd("Dashboard") - is_dashboard_open = true + vim.cmd('Dashboard') end end -------------------------------------------------- +-- Helper function to suppress errors +local function silent_execute(cmd) + vim.fn['serverlist']() -- Required to prevent 'Press ENTER' prompt + local result = vim.fn.system(cmd .. ' 2>/dev/null') + vim.fn['serverlist']() + return result +end + +-------------------------------------------------- + +-- ... return M -- cgit v1.2.3 From 4b0cbee1ef2963b6e216ffc1ae48c9160b4443ed Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 18 Aug 2023 21:35:21 +0200 Subject: Removed checking for nvim version --- init.lua | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/init.lua b/init.lua index d3fb064..23068e5 100644 --- a/init.lua +++ b/init.lua @@ -102,17 +102,6 @@ for k, v in pairs(modules) do require(v) end --- Check if we have the latest stable version of nvim -local mods = require("user.mods") -local expected_ver = "0.10.0" -local nvim_ver = mods.get_nvim_version() - -if nvim_ver ~= expected_ver then - local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) - vim.api.nvim_err_writeln(msg) - return -end - -- Snippets vim.g.snippets = "luasnip" -- cgit v1.2.3 From 87b013983a232431bbf107887da8ffa2c527dff7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 18 Aug 2023 21:35:49 +0200 Subject: Add specific mru/project line limit --- lua/plugins/dashboard.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index 46c15ec..834ae82 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -12,6 +12,8 @@ local db = require("dashboard") db.setup({ theme = "hyper", config = { + mru = { limit = 10 }, + project = { limit = 10 }, header = { [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], -- cgit v1.2.3 From 2a8d6de4cb22225320bf4740a73e6d6a1b66255d Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 22:40:14 +0200 Subject: Telescope find hidden files --- lua/user/keys.lua | 396 +++++++++++++++++++++++++++--------------------------- 1 file changed, 197 insertions(+), 199 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 5d45a99..62c17e1 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -1,6 +1,3 @@ ---[[ keys.lua ]] - -------------- Shorten Function Names -------------- local keymap = vim.keymap local map = function(mode, l, r, opts) opts = opts or {} @@ -10,13 +7,12 @@ local map = function(mode, l, r, opts) end local term_opts = { noremap = true, silent = false } ---------------- Standard Operations --------------- -- Semi-colon as leader key -vim.g.mapleader = ";" +vim.g.mapleader = ';' -- "jk" and "kj" to exit insert-mode -map("i", "jk", "") -map("i", "kj", "") +map('i', 'jk', '') +map('i', 'kj', '') -- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" --map("n", ".", ";") @@ -25,103 +21,103 @@ map("i", "kj", "") --map("n", "", ".") -- Reload nvim config -map("n", "", "luafile ~/.config/nvim/init.lua | :echom ('Nvim config loading...') | :sl! | echo ('')") +map('n', '', "luafile ~/.config/nvim/init.lua | :echom ('Nvim config loading...') | :sl! | echo ('')") --------------- Extended Operations --------------- -- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros -- TODO: Have a list of if available on system/packages, example "Zen Mode" to not work on it (quit Zen Mode) -map("n", "q", function() +map('n', 'q', function() local config = vim.api.nvim_win_get_config(0) - if config.relative ~= "" then -- is_floating_window? - return ":silent! close!" - elseif vim.o.buftype == "quickfix" then - return ":quit" - elseif vim.o.buftype == "help" then - return ":close" + if config.relative ~= '' then -- is_floating_window? + return ':silent! close!' + elseif vim.o.buftype == 'quickfix' then + return ':quit' + elseif vim.o.buftype == 'help' then + return ':close' else - return "q" + return 'q' end end, { expr = true, replace_keycodes = true }) -- Combine buffers list with buffer name -map("n", "b", ":buffers:buffer") +map('n', 'b', ':buffers:buffer') -- Buffer confirmation -map("n", "y", ":BufferPick") +map('n', 'y', ':BufferPick') -- Map buffer next, prev and delete to +(n/p/d) respectively -map("n", "n", ":bn") -map("n", "p", ":bp") -map("n", "d", ":bd") +map('n', 'n', ':bn') +map('n', 'p', ':bp') +map('n', 'd', ':bd') -- List marks -map("n", "m", ":marks") +map('n', 'm', ':marks') -- Messages -map("n", "M", ":messages") +map('n', 'M', ':messages') -- Clear messages or just refresh/redraw the screen -map("n", "u", ":echo '' | redraw") +map('n', 'u', ":echo '' | redraw") -- Unsets the 'last search pattern' register by hitting return --map("n", "", "!silent :noh") -- Toggle set number -map("n", "$", ":NumbersToggle") -map("n", "%", ":NumbersOnOff") +map('n', '$', ':NumbersToggle') +map('n', '%', ':NumbersOnOff') -- Easier split navigations, just ctrl-j instead of ctrl-w then j -map("t", "", "") -map("t", "", "") -map("t", "", "") -map("t", "", "") -map("t", "", "") +map('t', '', '') +map('t', '', '') +map('t', '', '') +map('t', '', '') +map('t', '', '') -- Split window -map("n", "h", ":split") -map("n", "v", ":vsplit") -map("n", "c", "c") +map('n', 'h', ':split') +map('n', 'v', ':vsplit') +map('n', 'c', 'c') -- Resize Panes -map("n", "+", ":resize +5") -map("n", "-", ":resize -5") -map("n", "<", ":vertical resize +5") -map("n", ">", ":vertical resize -5") -map("n", "=", "=") +map('n', '+', ':resize +5') +map('n', '-', ':resize -5') +map('n', '<', ':vertical resize +5') +map('n', '>', ':vertical resize -5') +map('n', '=', '=') -- Map Alt+(h/j/k/l) in insert mode to move directional -map("i", "", "") -map("i", "", "") -map("i", "", "") -map("i", "", "") +map('i', '', '') +map('i', '', '') +map('i', '', '') +map('i', '', '') -- Map Alt+(h/j/k/l) in command mode to move directional -vim.api.nvim_set_keymap("c", "", "", { noremap = true }) -vim.api.nvim_set_keymap("c", "", "", { noremap = true }) -vim.api.nvim_set_keymap("c", "", "", { noremap = true }) -vim.api.nvim_set_keymap("c", "", "", { noremap = true }) +vim.api.nvim_set_keymap('c', '', '', { noremap = true }) +vim.api.nvim_set_keymap('c', '', '', { noremap = true }) +vim.api.nvim_set_keymap('c', '', '', { noremap = true }) +vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -- Create tab, edit and move between them -map("n", "n", ":tabnew") -map("n", "e", ":tabedit") -map("n", "[", ":tabprev") -map("n", "]", ":tabnext") +map('n', 'n', ':tabnew') +map('n', 'e', ':tabedit') +map('n', '[', ':tabprev') +map('n', ']', ':tabnext') -- "Zoom" a split window into a tab and/or close it --map("n", ",", ":tabnew %") --map("n", ".", ":tabclose") -- Vim TABs -map("n", "1", "1gt") -map("n", "2", "2gt") -map("n", "3", "3gt") -map("n", "4", "4gt") -map("n", "5", "5gt") -map("n", "6", "6gt") -map("n", "7", "7gt") -map("n", "8", "8gt") -map("n", "9", "9gt") -map("n", "0", "10gt") +map('n', '1', '1gt') +map('n', '2', '2gt') +map('n', '3', '3gt') +map('n', '4', '4gt') +map('n', '5', '5gt') +map('n', '6', '6gt') +map('n', '7', '7gt') +map('n', '8', '8gt') +map('n', '9', '9gt') +map('n', '0', '10gt') -- Move to the next and previous item in the quickfixlist --map("n", "]c", "cnext") @@ -131,82 +127,82 @@ map("n", "0", "10gt") --map("t", "", [[]]) -- Move block (indentation) easily -map("n", "<", "<<", term_opts) -map("n", ">", ">>", term_opts) -map("x", "<", "", ">gv", term_opts) +map('n', '<', '<<', term_opts) +map('n', '>', '>>', term_opts) +map('x', '<', '', '>gv', term_opts) -- Set alt+(j/k) to switch lines of texts or simply move them -map("n", "", ':let save_a=@a"add"ap:let @a=save_a') -map("n", "", ':let save_a=@a"add"ap:let @a=save_a') +map('n', '', ':let save_a=@a"add"ap:let @a=save_a') +map('n', '', ':let save_a=@a"add"ap:let @a=save_a') -- Search and replace -map("v", "sr", 'y:%s/"//gc') +map('v', 'sr', 'y:%s/"//gc') -- Toggle Diff -map("n", "td", "call utils#ToggleDiff()") +map('n', 'td', 'call utils#ToggleDiff()') -- Toggle Verbose -map("n", "vt", "call utils#VerboseToggle()") +map('n', 'vt', 'call utils#VerboseToggle()') -- Jump List -map("n", "j", "call utils#GotoJump()") +map('n', 'j', 'call utils#GotoJump()') -- Map delete to Ctrl+l -map("i", "", "") +map('i', '', '') -- Clear screen -map("n", "", "!clear") +map('n', '', '!clear') -- Change file to an executable -map("n", "x", ":lua require('user.mods').Toggle_executable() | :echom ('Toggle executable') | :sl! | echo ('')") +map('n', 'x', ":lua require('user.mods').Toggle_executable() | :echom ('Toggle executable') | :sl! | echo ('')") -- map("n", "x", ":!chmod +x %") -- Paste without replace clipboard -map("v", "p", '"_dP') +map('v', 'p', '"_dP') -- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in -- visual mode to select text to swap with --map("v", "", "`.``gvP``P") -- Change Working Directory to current project -map("n", "cd", ":cd %:p:h:pwd") +map('n', 'cd', ':cd %:p:h:pwd') -- Open the current file in the default program (on Mac this should just be just `open`) -map("n", "o", ":!xdg-open %") +map('n', 'o', ':!xdg-open %') -- URL handling -if vim.fn.has("mac") == 1 then - map("", "gx", 'call jobstart(["open", expand("")], {"detach": v:true})', {}) -elseif vim.fn.has("unix") == 1 then - map("", "gx", 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', {}) -elseif vim.fn.has("wsl") == 1 then - map("", "gx", 'call jobstart(["wslview", expand("")], {"detach": v:true})', {}) +if vim.fn.has('mac') == 1 then + map('', 'gx', 'call jobstart(["open", expand("")], {"detach": v:true})', {}) +elseif vim.fn.has('unix') == 1 then + map('', 'gx', 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', {}) +elseif vim.fn.has('wsl') == 1 then + map('', 'gx', 'call jobstart(["wslview", expand("")], {"detach": v:true})', {}) else - map[""].gx = { 'lua print("Error: gx is not supported on this OS!")' } + map[''].gx = { 'lua print("Error: gx is not supported on this OS!")' } end -- Substitute globally and locally in the selected region. -map("n", "ss", ":%s//g") -map("v", "ss", ":s//g") +map('n', 'ss', ':%s//g') +map('v', 'ss', ':s//g') -- Toggle completion -map("n", "tc", ":lua require('user.mods').toggle_completion()") +map('n', 'tc', ":lua require('user.mods').toggle_completion()") -- Disable default completion. -map("i", "", "") -map("i", "", "") +map('i', '', '') +map('i', '', '') -- Set line wrap -map("n", "", function() - local wrap_status = vim.api.nvim_exec("set wrap ?", true) +map('n', '', function() + local wrap_status = vim.api.nvim_exec('set wrap ?', true) - if wrap_status == "nowrap" then - vim.api.nvim_command("set wrap linebreak") - print("Wrap enabled") + if wrap_status == 'nowrap' then + vim.api.nvim_command('set wrap linebreak') + print('Wrap enabled') else - vim.api.nvim_command("set wrap nowrap") - print("Wrap disabled") + vim.api.nvim_command('set wrap nowrap') + print('Wrap disabled') end end, { silent = true }) @@ -214,195 +210,197 @@ end, { silent = true }) --utils.map("n", "", "&foldlevel ? 'zM' : 'zR'", { expr = true }) -- Use space to toggle fold -map("n", "", "za") +map('n', '', 'za') -- Make a copy of current file --vim.cmd([[ -- map s :up \| saveas! %:p:r-=strftime("%y.%m.%d-%H:%M")-bak.=expand("%:e") \| 3sleep \| e # --]]) -map("n", ".b", ":!cp % %.backup") +map('n', '.b', ':!cp % %.backup') -- Toggle transparency -map("n", "tb", ":call utils#Toggle_transparent_background()") +map('n', 'tb', ':call utils#Toggle_transparent_background()') -- Toggle zoom -map("n", "z", ":call utils#ZoomToggle()") -map("n", "z", "|_") +map('n', 'z', ':call utils#ZoomToggle()') +map('n', 'z', '|_') -- Toggle statusline -map("n", "", ":call utils#ToggleHiddenAll()") +map('n', '', ':call utils#ToggleHiddenAll()') -- Open last closed buffer -map("n", "", ":call OpenLastClosed()") +map('n', '', ':call OpenLastClosed()') ---------------- Plugin Operations ---------------- -- Packer -map("n", "Pc", "PackerCompile") -map("n", "Pi", "PackerInstall") -map("n", "Ps", "PackerSync") -map("n", "PS", "PackerStatus") -map("n", "Pu", "PackerUpdate") +map('n', 'Pc', 'PackerCompile') +map('n', 'Pi', 'PackerInstall') +map('n', 'Ps', 'PackerSync') +map('n', 'PS', 'PackerStatus') +map('n', 'Pu', 'PackerUpdate') -- Tmux navigation (aserowy/tmux.nvim) -map("n", "", "NavigatorLeft") -map("n", "", "NavigatorRight") -map("n", "", "NavigatorUp") -map("n", "", "NavigatorDown") +map('n', '', 'NavigatorLeft') +map('n', '', 'NavigatorRight') +map('n', '', 'NavigatorUp') +map('n', '', 'NavigatorDown') -- ToggleTerm -map({ "n", "t" }, "tt", "ToggleTerm") -map({ "n", "t" }, "th", "lua Horizontal_term_toggle()") -map({ "n", "t" }, "tv", "lua Vertical_term_toggle()") +map({ 'n', 't' }, 'tt', 'ToggleTerm') +map({ 'n', 't' }, 'th', 'lua Horizontal_term_toggle()') +map({ 'n', 't' }, 'tv', 'lua Vertical_term_toggle()') -- LazyGit -map({ "n", "t" }, "gg", "lua Lazygit_toggle()") +map({ 'n', 't' }, 'gg', 'lua Lazygit_toggle()') -map("n", "tg", "lua Gh_dash()") +map('n', 'tg', 'lua Gh_dash()') -- Fugitive git bindings -map("n", "gs", vim.cmd.Git) -map("n", "ga", ":Git add %:p") +map('n', 'gs', vim.cmd.Git) +map('n', 'ga', ':Git add %:p') --map("n", "gs", ":Gstatus") -map("n", "gc", ":Gcommit -v -q") -map("n", "gt", ":Gcommit -v -q %:p") +map('n', 'gc', ':Gcommit -v -q') +map('n', 'gt', ':Gcommit -v -q %:p') --map("n", "gd", ":Gdiff") -map("n", "ge", ":Gedit") +map('n', 'ge', ':Gedit') --map("n", "gr", ":Gread") -map("n", "gw", ":Gwrite") -map("n", "gl", ":silent! Glog:bot copen") +map('n', 'gw', ':Gwrite') +map('n', 'gl', ':silent! Glog:bot copen') --map("n", "gp", ":Ggrep") --map("n", "gp", ":Git push") --map("n", "gb", ":Gblame") -map("n", "gm", ":Gmove") +map('n', 'gm', ':Gmove') --map("n", "gb", ":Git branch") --map("n", "go", ":Git checkout") --map("n", "gps", ":Dispatch! git push") --map("n", "gpl", ":Dispatch! git pull") -- Telescope -map("n", "ff", function() - require("telescope.builtin").find_files({ hidden = true, no_ignore = false }) +map('n', 'ff', function() + require('telescope.builtin').find_files({ hidden = true, no_ignore = false }) +end) -- find files +map('n', 'fF', ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = 'Find files in cwd' }) +map('n', 'ff.', function() + require('telescope.builtin').find_files({ hidden = false, no_ignore = true }) end) -- find all files -map("n", "fF", ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = "Find files in cwd" }) ---map("n", "fF", "lua require('telescope.builtin').find_files()") -- find files with hidden option -map("n", "fg", "lua require('telescope.builtin').live_grep()") -map("n", "fb", "lua require('telescope.builtin').buffers()") -map("n", "fh", "lua require('telescope.builtin').help_tags()") -map("n", "fc", "lua require('telescope.builtin').commands()") -map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") -map("n", "cf", "Telescope changed_files") -map("n", "fp", "Telescope pickers") -map("n", "fd", "lua require('telescope.builtin').diagnostics()") -map("n", "fk", "lua require('telescope.builtin').keymaps()") -map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker -map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes -map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs -map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts -map("n", "fw", [[lua require'plugins.telescope'.find_projects()]]) -- find projects -map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files -map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find notifications -map("n", "ffr", "lua require('telescope').extensions.recent_files.pick()") +map('n', 'fg', "lua require('telescope.builtin').live_grep()") +map('n', 'fb', "lua require('telescope.builtin').buffers()") +map('n', 'fh', "lua require('telescope.builtin').help_tags()") +map('n', 'fc', "lua require('telescope.builtin').commands()") +map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") +map('n', 'cf', 'Telescope changed_files') +map('n', 'fp', 'Telescope pickers') +map('n', 'fd', "lua require('telescope.builtin').diagnostics()") +map('n', 'fk', "lua require('telescope.builtin').keymaps()") +map('n', 'fr', "lua require('telescope.builtin').registers({})") -- registers picker +map('n', 'fn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map('n', 'f.', [[lua require'plugins.telescope'.find_configs()]]) -- find configs +map('n', 'fs', [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts +map('n', 'fw', [[lua require'plugins.telescope'.find_projects()]]) -- find projects +map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files +map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications +map('n', 'ffr', "lua require('telescope').extensions.recent_files.pick()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- Map a shortcut to open the picker. -- FZF -map("n", "fz", "lua require('fzf-lua').files()") +map('n', 'fz', "lua require('fzf-lua').files()") -- Nvim-tree -map("n", "f", "Rooter:NvimTreeToggle", {}) -map("n", "", ":NvimTreeFindFileToggle", { noremap = false, silent = true }) +map('n', 'f', 'Rooter:NvimTreeToggle', {}) +map('n', '', ':NvimTreeFindFileToggle', { noremap = false, silent = true }) -- Undotree -map("n", "u", vim.cmd.UndotreeToggle) +map('n', 'u', vim.cmd.UndotreeToggle) -- Markdown-preview -map("n", "md", "MarkdownPreviewToggle") -map("n", "mg", "Glow") +map('n', 'md', 'MarkdownPreviewToggle') +map('n', 'mg', 'Glow') -- Autopairs -map("n", "ww", "lua require('user.mods').Toggle_autopairs()") +map('n', 'ww', "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle -map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") +map('n', 'zm', "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") -- Vim-rooter -map("n", "ro", "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", term_opts) +map('n', 'ro', "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", term_opts) -- Trouble (UI to show diagnostics) -map("n", "t", "TroubleToggle") -map("n", "tw", "TroubleToggle workspace_diagnostics") -map("n", "td", "TroubleToggle document_diagnostics") -map("n", "tq", "TroubleToggle quickfix") -map("n", "tl", "TroubleToggle loclist") -map("n", "gR", "TroubleToggle lsp_references") +map('n', 't', 'TroubleToggle') +map('n', 'tw', 'TroubleToggle workspace_diagnostics') +map('n', 'td', 'TroubleToggle document_diagnostics') +map('n', 'tq', 'TroubleToggle quickfix') +map('n', 'tl', 'TroubleToggle loclist') +map('n', 'gR', 'TroubleToggle lsp_references') -- Null-ls -map("n", "ls", "NullLsToggle") +map('n', 'ls', 'NullLsToggle') -- Replacer -map("n", "qr", ':lua require("replacer").run()') +map('n', 'qr', ':lua require("replacer").run()') -- Quickfix -map("n", "q", function() +map('n', 'q', function() if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then - require("plugins.quickfix").close() + require('plugins.quickfix').close() else - require("plugins.quickfix").open() + require('plugins.quickfix').open() -- require("quickfix").open() end -end, { desc = "Toggle quickfix window" }) +end, { desc = 'Toggle quickfix window' }) -- Dap (debugging) -local dap_ok, dap = pcall(require, "dap") -local dap_ui_ok, ui = pcall(require, "dapui") +local dap_ok, dap = pcall(require, 'dap') +local dap_ui_ok, ui = pcall(require, 'dapui') if not (dap_ok and dap_ui_ok) then - require("notify")("nvim-dap or dap-ui not installed!", "warning") + require('notify')('nvim-dap or dap-ui not installed!', 'warning') return end -vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) +vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) -- Start debugging session -map("n", "ds", function() +map('n', 'ds', function() dap.continue() ui.toggle({}) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) -- Spaces buffers evenly + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('=', false, true, true), 'n', false) -- Spaces buffers evenly end) -- Set breakpoints, get variable values, step into/out of functions, etc. -map("n", "dC", dap.continue) +map('n', 'dC', dap.continue) -- map("n", "dC", dap.close) -- map("n", "dt", dap.terminate) -map("n", "dt", ui.toggle) -map("n", "dd", function() +map('n', 'dt', ui.toggle) +map('n', 'dd', function() dap.disconnect({ terminateDebuggee = true }) end) -map("n", "dn", dap.step_over) -map("n", "di", dap.step_into) -map("n", "do", dap.step_out) -map("n", "db", dap.toggle_breakpoint) -map("n", "dB", function() +map('n', 'dn', dap.step_over) +map('n', 'di', dap.step_into) +map('n', 'do', dap.step_out) +map('n', 'db', dap.toggle_breakpoint) +map('n', 'dB', function() dap.clear_breakpoints() - require("notify")("Breakpoints cleared", "warn") + require('notify')('Breakpoints cleared', 'warn') end) -map("n", "dl", require("dap.ui.widgets").hover) -map("n", "de", function() - require("dapui").float_element() -end, { desc = "Open Element" }) -map("n", "dq", function() - require("dapui").close() - require("dap").repl.close() - local session = require("dap").session() +map('n', 'dl', require('dap.ui.widgets').hover) +map('n', 'de', function() + require('dapui').float_element() +end, { desc = 'Open Element' }) +map('n', 'dq', function() + require('dapui').close() + require('dap').repl.close() + local session = require('dap').session() if session then - require("dap").terminate() + require('dap').terminate() end - require("nvim-dap-virtual-text").refresh() -end, { desc = "Terminate Debug" }) -map("n", "dc", function() - require("telescope").extensions.dap.commands() -end, { desc = "DAP-Telescope: Commands" }) + require('nvim-dap-virtual-text').refresh() +end, { desc = 'Terminate Debug' }) +map('n', 'dc', function() + require('telescope').extensions.dap.commands() +end, { desc = 'DAP-Telescope: Commands' }) --vim.keymap.set("n", "B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))") --vim.keymap.set("v", "B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))") --vim.keymap.set("n", "lp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") @@ -418,7 +416,7 @@ end, { desc = "DAP-Telescope: Commands" }) --end) -- Toggle Dashboard -map("n", "", "lua require('user.mods').toggle_dashboard()") +map('n', '', "lua require('user.mods').toggle_dashboard()") -- Lsp Lines toggle -map("", "l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) +map('', 'l', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) -- cgit v1.2.3 From b7eb28215653fbeac69fb9bf8fe52fb9355e8a1b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 22:48:33 +0200 Subject: Re-formatted file --- lua/plugins/telescope.lua | 387 +++++++++++++++++++++++----------------------- 1 file changed, 194 insertions(+), 193 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 3678d27..9ed43ca 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,91 +1,91 @@ local M = {} -- Shorten function names -local actions = require("telescope.actions") -local fb_actions = require("telescope").extensions.file_browser.actions +local actions = require('telescope.actions') +local fb_actions = require('telescope').extensions.file_browser.actions --local builtin = require("telescope.builtin") --local themes = require("telescope.themes") --local utils = require("telescope.utils") --local action_state = require("telescope.actions.state") --local layout_actions = require("telescope.actions.layout") --local pickers = require("telescope.pickers") -local themes = require("telescope.themes") +local themes = require('telescope.themes') -require("telescope").setup({ +require('telescope').setup({ defaults = { vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--hidden", - "--fixed-strings", - "--trim", + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--hidden', + '--fixed-strings', + '--trim', }, - prompt_prefix = " ", - selection_caret = " ", - entry_prefix = " ", - path_display = { "tail" }, + prompt_prefix = ' ', + selection_caret = ' ', + entry_prefix = ' ', + path_display = { 'tail' }, --path_display = { "truncate" }, --path_display = { "smart" }, file_ignore_patterns = { - "packer_compiled.lua", - "~/.config/zsh/plugins", - "zcompdump", - "%.DS_Store", - "%.git/", - "%.spl", + 'packer_compiled.lua', + '~/.config/zsh/plugins', + 'zcompdump', + '%.DS_Store', + '%.git/', + '%.spl', --"%.log", - "%[No Name%]", -- new files / sometimes folders (netrw) - "/$", -- ignore folders (netrw) - "node_modules", - "%.png", - "%.zip", - "%.pxd", - "^.vim/", - "^.local/", - "^.cache/", - "^downloads/", - "^music/", + '%[No Name%]', -- new files / sometimes folders (netrw) + '/$', -- ignore folders (netrw) + 'node_modules', + '%.png', + '%.zip', + '%.pxd', + --"^.vim/", + '^.local/', + '^.cache/', + '^downloads/', + '^music/', --"^node_modules/", --"^undodir/", }, mappings = { i = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, + [''] = actions.cycle_history_next, + [''] = actions.cycle_history_prev, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, --[""] = actions.close, - [""] = actions.close, -- close w/ one esc + [''] = actions.close, -- close w/ one esc --[""] = "close", -- close w/ one esc - [""] = actions.which_key, -- keys from pressing + [''] = actions.which_key, -- keys from pressing - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, - [""] = actions.select_default, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, + [''] = actions.select_default, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_tab, - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, + [''] = actions.results_scrolling_up, + [''] = actions.results_scrolling_down, - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - [""] = actions.complete_tag, - [""] = actions.which_key, -- keys from pressing + [''] = actions.toggle_selection + actions.move_selection_worse, + [''] = actions.toggle_selection + actions.move_selection_better, + [''] = actions.send_to_qflist + actions.open_qflist, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + [''] = actions.complete_tag, + [''] = actions.which_key, -- keys from pressing --[""] = function(prompt_bufnr) -- local selection = require("telescope.actions.state").get_selected_entry() -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") @@ -102,36 +102,36 @@ require("telescope").setup({ -- -- Depending on what you want put `cd`, `lcd`, `tcd` -- vim.cmd(string.format("silent lcd %s", dir)) --end, - [""] = actions.close, - [""] = actions.close, - [""] = actions.select_default, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, - - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - - ["j"] = actions.move_selection_next, - ["k"] = actions.move_selection_previous, - ["H"] = actions.move_to_top, - ["M"] = actions.move_to_middle, - ["L"] = actions.move_to_bottom, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - ["gg"] = actions.move_to_top, - ["G"] = actions.move_to_bottom, - - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, - - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, - - ["?"] = actions.which_key, + [''] = actions.close, + [''] = actions.close, + [''] = actions.select_default, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_tab, + + [''] = actions.toggle_selection + actions.move_selection_worse, + [''] = actions.toggle_selection + actions.move_selection_better, + [''] = actions.send_to_qflist + actions.open_qflist, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + + ['j'] = actions.move_selection_next, + ['k'] = actions.move_selection_previous, + ['H'] = actions.move_to_top, + ['M'] = actions.move_to_middle, + ['L'] = actions.move_to_bottom, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + ['gg'] = actions.move_to_top, + ['G'] = actions.move_to_bottom, + + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, + + [''] = actions.results_scrolling_up, + [''] = actions.results_scrolling_down, + + ['?'] = actions.which_key, --[""] = function(prompt_bufnr) -- local selection = require("telescope.actions.state").get_selected_entry() -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") @@ -146,11 +146,11 @@ require("telescope").setup({ filesize_limit = 3, timeout = 250, }, - selection_strategy = "reset", - sorting_strategy = "ascending", - scroll_strategy = "limit", + selection_strategy = 'reset', + sorting_strategy = 'ascending', + scroll_strategy = 'limit', color_devicons = true, - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { horizontal = { height = 0.95, @@ -161,9 +161,17 @@ require("telescope").setup({ bottom_pane = { height = 12, preview_cutoff = 70, - prompt_position = "bottom", + prompt_position = 'bottom', }, }, + find_files = { + --cwd = '%:p:h', + cwd = vim.fn.getcwd(), + prompt_prefix = ' ', + --hidden = true, + --no_ignore = false, + follow = true, + }, --pickers = { -- live_grep = { -- disable_coordinates = true, @@ -208,13 +216,6 @@ require("telescope").setup({ -- prompt_prefix=' ', -- show_line = false, --}, - find_files = { - cwd = "%:p:h", - --cwd = vim.fn.getcwd(), - prompt_prefix = " ", - hidden = true, - follow = true, - }, --keymaps = { prompt_prefix='? ' }, --oldfiles = { prompt_prefix=' ' }, --highlights = { prompt_prefix=' ' }, @@ -251,20 +252,20 @@ require("telescope").setup({ extensions = { file_browser = { - theme = "dropdown", + theme = 'dropdown', -- disables netrw and use telescope-file-browser in its place hijack_netrw = true, mappings = { -- your custom insert mode mappings - ["i"] = { - [""] = function() - vim.cmd("normal vbd") + ['i'] = { + [''] = function() + vim.cmd('normal vbd') end, --[""] = fb_actions.goto_parent_dir, }, - ["n"] = { + ['n'] = { -- your custom normal mode mappings - ["N"] = fb_actions.create, + ['N'] = fb_actions.create, --[""] = fb_actions.goto_parent_dir, --["/"] = function() -- vim.cmd("startinsert") @@ -279,17 +280,17 @@ require("telescope").setup({ -- Load extensions: -- have to be loaded after telescope setup/config -require("telescope").load_extension("fzf") -require("telescope").load_extension("ui-select") -require("telescope").load_extension("file_browser") -require("telescope").load_extension("changed_files") -require("telescope").load_extension("media_files") +require('telescope').load_extension('fzf') +require('telescope').load_extension('ui-select') +require('telescope').load_extension('file_browser') +require('telescope').load_extension('changed_files') +require('telescope').load_extension('media_files') --require('telescope').extensions.notify.notify() -require("telescope").load_extension("notify") -require("telescope").load_extension("dap") -require("telescope").load_extension("session-lens") -require("telescope").load_extension("flutter") -require("telescope").load_extension("recent_files") +require('telescope').load_extension('notify') +require('telescope').load_extension('dap') +require('telescope').load_extension('session-lens') +require('telescope').load_extension('flutter') +require('telescope').load_extension('recent_files') --M.curbuf = function(opts) -- opts = opts @@ -302,78 +303,78 @@ require("telescope").load_extension("recent_files") --end function M.find_configs() - require("telescope.builtin").find_files({ + require('telescope.builtin').find_files({ hidden = true, no_ignore = false, - prompt_title = " Find Configs", - results_title = "Config Files", - path_display = { "smart" }, + prompt_title = ' Find Configs', + results_title = 'Config Files', + path_display = { 'smart' }, search_dirs = { - "~/.config/nvim", - "~/.config/zsh", - "~/.config/tmux", - "~/.config/X11", - "~/.config/alacritty", - "~/.config/kitty", - "~/.config/wezterm", - "~/.config/bspwm", - "~/.config/sxhkd", - "~/.config/picom", - "~/.config/polybar", - "~/.bashrc", - "~/.vim", - "~/.profile", - "~/.zprofile", - "~/.gitconfig", - "~/.gitsubtrees", - "~/.gitignore", - "~/.editorconfig", - "~/.prettierrc.yml", - "~/README.md", + '~/.config/nvim', + '~/.config/zsh', + '~/.config/tmux', + '~/.config/X11', + '~/.config/alacritty', + '~/.config/kitty', + '~/.config/wezterm', + '~/.config/bspwm', + '~/.config/sxhkd', + '~/.config/picom', + '~/.config/polybar', + '~/.bashrc', + '~/.vim', + '~/.profile', + '~/.zprofile', + '~/.gitconfig', + '~/.gitsubtrees', + '~/.gitignore', + '~/.editorconfig', + '~/.prettierrc.yml', + '~/README.md', }, file_ignore_patterns = { - "/nvim/startup.log", - "zsh/plugins", - "packer_compiled.lua", - "resurrect", - "tmux/plugins", + '/nvim/startup.log', + 'zsh/plugins', + 'packer_compiled.lua', + 'resurrect', + 'tmux/plugins', --"^~/.config/tmux/plugins", - "%.txt", - ".git/", - "autoload/plugged", - "plug.vim", - "zcompdump", + '%.txt', + '.git/', + 'autoload/plugged', + 'plug.vim', + 'zcompdump', }, - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, }) end function M.find_scripts() - require("telescope.builtin").find_files({ + require('telescope.builtin').find_files({ hidden = true, no_ignore = true, - prompt_title = " Find Scripts", - path_display = { "smart" }, + prompt_title = ' Find Scripts', + path_display = { 'smart' }, search_dirs = { - "~/.ssh", - "~/.local/bin/scripts", + '~/.ssh', + '~/.local/bin/scripts', }, - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, }) end function M.find_projects() - require("telescope.builtin").find_files({ + require('telescope.builtin').find_files({ hidden = true, no_ignore = true, - prompt_title = " Find Projects", - path_display = { "smart" }, + prompt_title = ' Find Projects', + path_display = { 'smart' }, search_dirs = { - "~/projects", + '~/projects', }, - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, }) end @@ -382,58 +383,58 @@ function M.grep_notes() local opts = {} opts.hidden = false opts.search_dirs = { - "~/documents/notes/", + '~/documents/notes/', } - opts.prompt_prefix = "  " - opts.prompt_title = " Grep Notes" - opts.path_display = { "smart" } - require("telescope.builtin").live_grep(opts) + opts.prompt_prefix = '  ' + opts.prompt_title = ' Grep Notes' + opts.path_display = { 'smart' } + require('telescope.builtin').live_grep(opts) end function M.find_notes() - require("telescope.builtin").find_files({ + require('telescope.builtin').find_files({ hidden = false, - prompt_title = " Find Notes", - path_display = { "smart" }, + prompt_title = ' Find Notes', + path_display = { 'smart' }, search_dirs = { - "~/documents/notes/private/", - "~/documents/notes", + '~/documents/notes/private/', + '~/documents/notes', }, --cwd = "~documents/notes", - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, }) end function M.file_explorer() - require("telescope.builtin").file_browser({ - prompt_title = "File Browser", - cwd = "~", - layout_strategy = "horizontal", + require('telescope.builtin').file_browser({ + prompt_title = 'File Browser', + cwd = '~', + layout_strategy = 'horizontal', }) end function M.grep_current_dir() - local buffer_dir = require("telescope.utils").buffer_dir() + local buffer_dir = require('telescope.utils').buffer_dir() local opts = { - prompt_title = "Live Grep in " .. buffer_dir, + prompt_title = 'Live Grep in ' .. buffer_dir, cwd = buffer_dir, } - require("telescope.builtin").live_grep(opts) + require('telescope.builtin').live_grep(opts) end -------------------------------------------------------------------------------- -local dropdown = require("telescope.themes").get_dropdown({ +local dropdown = require('telescope.themes').get_dropdown({ hidden = true, no_ignore = true, previewer = false, - prompt_title = "", - preview_title = "", - results_title = "", + prompt_title = '', + preview_title = '', + results_title = '', layout_config = { --anchor = "S", - prompt_position = "top", + prompt_position = 'top', }, }) @@ -446,16 +447,16 @@ local dropdown = require("telescope.themes").get_dropdown({ local with_title = function(opts, extra) extra = extra or {} local path = opts.cwd or opts.path or extra.cwd or extra.path or nil - local title = "" - local buf_path = vim.fn.expand("%:p:h") + local title = '' + local buf_path = vim.fn.expand('%:p:h') local cwd = vim.fn.getcwd() if path ~= nil and buf_path ~= cwd then - title = require("plenary.path"):new(buf_path):make_relative(cwd) + title = require('plenary.path'):new(buf_path):make_relative(cwd) else - title = vim.fn.fnamemodify(cwd, ":t") + title = vim.fn.fnamemodify(cwd, ':t') end - return vim.tbl_extend("force", opts, { + return vim.tbl_extend('force', opts, { prompt_title = title, }, extra or {}) end @@ -469,10 +470,10 @@ end --local findhere = function() function M.findhere() -- Open file browser if argument is a folder - local arg = vim.api.nvim_eval("argv(0)") - if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == "") then + local arg = vim.api.nvim_eval('argv(0)') + if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == '') then vim.defer_fn(function() - require("telescope.builtin").find_files(with_title(dropdown)) + require('telescope.builtin').find_files(with_title(dropdown)) -- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ -- hidden = true, -- results_title = '', -- cgit v1.2.3 From a1264f4352057e8929c07495c8f218ac8a8458da Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 22:48:40 +0200 Subject: Re-formatted file --- lua/plugins/lsp.lua | 151 +++++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 72 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 5cca919..8802994 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,29 +1,30 @@ -local lspconfig = require("lspconfig") -local mason_lspconfig = require("mason-lspconfig") -local null_ls = require("null-ls") +local lspconfig = require('lspconfig') +local mason_lspconfig = require('mason-lspconfig') +local null_ls = require('null-ls') -- local lsp_lines = require('lsp_lines') -require("mason").setup() -require("mason-null-ls").setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, automatic_setup = true }) +require('mason').setup() +require('mason-null-ls').setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, automatic_setup = true }) local keymap = vim.keymap local cmd = vim.cmd -local border = { { "┌", "FloatBorder" }, { "─", "FloatBorder" }, { "┐", "FloatBorder" }, { "│", "FloatBorder" }, { "┘", "FloatBorder" }, { "─", "FloatBorder" }, { "└", "FloatBorder" }, { "│", "FloatBorder" } } +local border = { { '┌', 'FloatBorder' }, { '─', 'FloatBorder' }, { '┐', 'FloatBorder' }, { '│', 'FloatBorder' }, { '┘', 'FloatBorder' }, { '─', 'FloatBorder' }, { '└', 'FloatBorder' }, { '│', 'FloatBorder' } } -- Set up LSP servers if not done before if not vim.g.lsp_setup_done then -- Clear existing LSP clients for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do - local clients = vim.lsp.get_clients({ buffer = bufnr }) + local clients = require('user.mods').get_lsp_clients(bufnr) + for _, client in ipairs(clients) do client.stop() end end - local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } + local signs = { Error = ' ', Warn = '▲', Info = '􀅳', Hint = '⚑' } --  for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type + local hl = 'DiagnosticSign' .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end @@ -46,7 +47,7 @@ if not vim.g.lsp_setup_done then virtual_lines = false, float = { show_header = true, - source = "if_many", -- border = 'rounded', + source = 'if_many', -- border = 'rounded', border = border, focusable = true, }, @@ -54,15 +55,15 @@ if not vim.g.lsp_setup_done then severity_sort = false, -- default to false }) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) + vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' }) + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' }) -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer local on_attach = function(client, bufnr) -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') local map = function(mode, l, r, opts) opts = opts or {} opts.silent = true @@ -71,39 +72,39 @@ if not vim.g.lsp_setup_done then keymap.set(mode, l, r, opts) end -- Mappings - map("n", "K", "lua vim.lsp.buf.hover()") + map('n', 'K', 'lua vim.lsp.buf.hover()') -- map("n", "gd", "lua vim.lsp.buf.definition()") - map("n", "gd", "lua require('goto-preview').goto_preview_definition()") + map('n', 'gd', "lua require('goto-preview').goto_preview_definition()") -- map("n", "gi", "lua vim.lsp.buf.implementation()") - map("n", "gi", "lua require('goto-preview').goto_preview_implementation()") + map('n', 'gi', "lua require('goto-preview').goto_preview_implementation()") -- map("n", "gr", "lua vim.lsp.buf.references()") - map("n", "gr", "lua require('goto-preview').goto_preview_references()") - map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. - map("n", "k", "lua vim.lsp.buf.signature_help()") + map('n', 'gr', "lua require('goto-preview').goto_preview_references()") + map('n', 'gD', 'lua vim.lsp.buf.declaration()') -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map('n', 'k', 'lua vim.lsp.buf.signature_help()') -- map("n", "gt", "lua vim.lsp.buf.type_definition()") - 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", "go", "lua vim.diagnostic.open_float()") - map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") - map("n", "[d", "lua vim.diagnostic.goto_prev()") - map("n", "]d", "lua vim.diagnostic.goto_next()") - map("n", "gs", "lua vim.lsp.buf.document_symbol()") - map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") - map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - map("n", "wl", function() + 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', 'go', 'lua vim.diagnostic.open_float()') + map('n', 'go', ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") + map('n', '[d', 'lua vim.diagnostic.goto_prev()') + map('n', ']d', 'lua vim.diagnostic.goto_next()') + map('n', 'gs', 'lua vim.lsp.buf.document_symbol()') + map('n', 'gw', 'lua vim.lsp.buf.workspace_symbol()') + map('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') + map('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') + map('n', 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) -- TODO: Use the nicer new API for autocommands - cmd("augroup lsp_aucmds") + cmd('augroup lsp_aucmds') if client.server_capabilities.documentHighlightProvider then - cmd("au CursorHold lua vim.lsp.buf.document_highlight()") - cmd("au CursorMoved lua vim.lsp.buf.clear_references()") + cmd('au CursorHold lua vim.lsp.buf.document_highlight()') + cmd('au CursorMoved lua vim.lsp.buf.clear_references()') end - cmd("augroup END") + cmd('augroup END') end -- Toggle diagnostics visibility @@ -128,11 +129,11 @@ augroup END ]]) -- Suppress error messages from lang servers - vim.lsp.set_log_level("debug") + vim.lsp.set_log_level('debug') local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require("cmp_nvim_lsp").default_capabilities() + capabilities = require('cmp_nvim_lsp').default_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.offsetEncoding = { "utf-16" } + capabilities.offsetEncoding = { 'utf-16' } local function prefer_null_ls_fmt(client) client.server_capabilities.documentHighlightProvider = true @@ -144,24 +145,28 @@ augroup END asm_lsp = {}, bashls = {}, clangd = {}, - cssls = { filetypes = { "css", "scss", "less", "sass" }, root_dir = lspconfig.util.root_pattern("package.json", ".git") }, -- ghcide = {}, + cssls = { filetypes = { 'css', 'scss', 'less', 'sass' }, root_dir = lspconfig.util.root_pattern('package.json', '.git') }, -- ghcide = {}, html = {}, - jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, + jsonls = { prefer_null_ls = true, cmd = { '--stdio' } }, intelephense = {}, julials = { on_new_config = function(new_config, _) - local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") + local julia = vim.fn.expand('~/.julia/environments/nvim-lspconfig/bin/julia') if lspconfig.util.path.is_file(julia) then new_config.cmd[1] = julia end end, settings = { julia = { format = { indent = 2 } } }, }, - pyright = { settings = { python = { formatting = { provider = "yapf" }, linting = { pytypeEnabled = true } } } }, - rust_analyzer = { settings = { ["rust-analyzer"] = { cargo = { allFeatures = true }, checkOnSave = { command = "clippy", extraArgs = { "--no-deps" } } } } }, + pyright = { settings = { python = { formatting = { provider = 'yapf' }, linting = { pytypeEnabled = true } } } }, + rust_analyzer = { + settings = { + ['rust-analyzer'] = { cargo = { allFeatures = true }, checkOnSave = { command = 'clippy', extraArgs = { '--no-deps' } } }, + }, + }, dartls = { - cmd = { "dart", "language-server", "--protocol=lsp" }, - filetypes = { "dart" }, + cmd = { 'dart', 'language-server', '--protocol=lsp' }, + filetypes = { 'dart' }, init_options = { closingLabels = true, flutterOutline = true, @@ -178,20 +183,20 @@ augroup END debounce_text_changes = 500, settings = { Lua = { - runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, - diagnostics = { enable = true, globals = { "vim" } }, + runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') }, + diagnostics = { enable = true, globals = { 'vim' } }, workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false }, }, }, }, sqlls = {}, tsserver = { - capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), on_attach = function(client) client.server_capabilities.document_formatting = false client.server_capabilities.document_range_formatting = false end, - filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, + filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx' }, }, vimls = {}, yamlls = {}, @@ -247,7 +252,7 @@ augroup END -- null_ls setup local builtins = null_ls.builtins - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) -- local eslint_opts = { -- -- condition = function(utils) @@ -275,10 +280,10 @@ augroup END update_in_insert = false, severity_sort = true, }, - diagnostics_format = "[#{c}] #{m} (#{s})", -- this will run every time the source runs, + diagnostics_format = '[#{c}] #{m} (#{s})', -- this will run every time the source runs, -- so you should prefer caching results if possible }), - builtins.diagnostics.zsh.with({ filetypes = "zsh", "sh" }), + builtins.diagnostics.zsh.with({ filetypes = 'zsh', 'sh' }), builtins.diagnostics.todo_comments, builtins.diagnostics.teal, -- null_ls.builtins.diagnostics.vale, @@ -289,17 +294,17 @@ augroup END builtins.diagnostics.flake8, builtins.diagnostics.eslint_d.with({ condition = function(utils) - return utils.root_has_file(".eslintrc.json") + return utils.root_has_file('.eslintrc.json') end, }), builtins.formatting.eslint_d, -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, -- Formatting - builtins.formatting.shfmt.with({ filetypes = { "bash", "zsh", "sh" }, extra_args = { "-i", "2", "-ci" } }), + builtins.formatting.shfmt.with({ filetypes = { 'bash', 'zsh', 'sh' }, extra_args = { '-i', '2', '-ci' } }), builtins.formatting.shellharden, - builtins.formatting.trim_whitespace.with({ filetypes = { "tmux", "teal", "zsh" } }), -- builtins.formatting.beautysh, - builtins.formatting.beautysh.with({ filetypes = "zsh" }), + builtins.formatting.trim_whitespace.with({ filetypes = { 'tmux', 'teal', 'zsh' } }), -- builtins.formatting.beautysh, + builtins.formatting.beautysh.with({ filetypes = 'zsh' }), builtins.formatting.clang_format, builtins.formatting.rustfmt, builtins.formatting.sql_formatter, @@ -308,19 +313,19 @@ augroup END builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, builtins.formatting.prettierd, builtins.formatting.prettier.with({ - filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", "css", "scss", "less", "graphql", "vue", "svelte" }, - extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, + filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'json', 'yaml', 'markdown', 'html', 'css', 'scss', 'less', 'graphql', 'vue', 'svelte' }, + extra_args = { '--single-quote', '--tab-width 4', '--print-width 200' }, }), builtins.formatting.rustfmt, -- builtins.formatting.stylua, -- builtins.formatting.lua_format, builtins.formatting.stylua.with({ - filetypes = { "lua" }, - command = "stylua", - args = { "--indent-width", "2", "--column-width", "160", "--indent-type", "Spaces", "-" }, + filetypes = { 'lua' }, + command = 'stylua', + args = { '--quote_style', 'AutoPreferSingle', '--indent-width', '2', '--column-width', '160', '--indent-type', 'Spaces', '-' }, }), -- builtins.formatting.dart_format, - builtins.formatting.dart_format.with({ filetypes = { "dart" } }), + builtins.formatting.dart_format.with({ filetypes = { 'dart' } }), builtins.formatting.trim_whitespace, builtins.formatting.yapf, -- null_ls.builtins.formatting.black @@ -348,9 +353,9 @@ augroup END sources = sources, update_in_insert = true, on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then + if client.supports_method('textDocument/formatting') then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { + vim.api.nvim_create_autocmd('BufWritePre', { group = augroup, buffer = bufnr, callback = function() @@ -362,7 +367,7 @@ augroup END }) -- Install all the null-ls sources using Mason - local registry = require("mason-registry") + local registry = require('mason-registry') for _, source_name in ipairs(sources) do local ok, pkg = pcall(registry.get_package, source_name) if ok then @@ -383,15 +388,17 @@ augroup END -- end -- end -- end - vim.api.nvim_create_user_command("NullLsToggle", function() + vim.api.nvim_create_user_command('NullLsToggle', function() -- you can also create commands to disable or enable sources - require("null-ls").toggle({}) + require('null-ls').toggle({}) end, {}) local null_ls_stop = function() local null_ls_client - for _, client in ipairs(vim.lsp.get_clients()) do - if client.name == "null-ls" then + local clients = require('user.mods').get_lsp_clients(bufnr) + + for _, client in ipairs(clients) do + if client.name == 'null-ls' then null_ls_client = client end end @@ -402,7 +409,7 @@ augroup END null_ls_client.stop() end - vim.api.nvim_create_user_command("NullLsStop", null_ls_stop, {}) + vim.api.nvim_create_user_command('NullLsStop', null_ls_stop, {}) vim.g.lsp_setup_done = true end -- cgit v1.2.3 From 4916ab5ee9550f9c6ae7ebabece3a2486d9ef4ae Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 22:48:48 +0200 Subject: Re-formatted file --- lua/plugins/dashboard.lua | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index 834ae82..a78332b 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -1,4 +1,4 @@ -local db = require("dashboard") +local db = require('dashboard') --vim.api.nvim_create_autocmd("VimEnter", { -- callback = function() @@ -10,9 +10,9 @@ local db = require("dashboard") --}) db.setup({ - theme = "hyper", + theme = 'hyper', config = { - mru = { limit = 10 }, + mru = { limit = 10, label = '' }, project = { limit = 10 }, header = { [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], @@ -24,45 +24,45 @@ db.setup({ }, disable_move = false, shortcut = { - { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + { desc = ' Plugins', group = 'Number', action = 'PackerStatus', key = 'p' }, --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, { - desc = " Files", - group = "Number", + desc = ' Files', + group = 'Number', --group = "Label", - action = "Telescope find_files", - key = "f", + action = 'Telescope find_files', + key = 'f', }, { - desc = " Text", - group = "Number", + desc = ' Text', + group = 'Number', --group = "Label", - action = "enew", - key = "t", + action = 'enew', + key = 't', }, { - desc = " Grep", - group = "Number", + desc = ' Grep', + group = 'Number', --group = "Label", - action = "Telescope live_grep", - key = "g", + action = 'Telescope live_grep', + key = 'g', }, { - desc = " Scheme", - group = "Number", + desc = ' Scheme', + group = 'Number', --group = "Label", - action = "Telescope colorscheme", - key = "s", + action = 'Telescope colorscheme', + key = 's', }, { - desc = " Config", - group = "Number", + desc = ' Config', + group = 'Number', --group = "Label", - action = ":edit ~/.config.nvim/init.lua", - key = "c", + action = ':edit ~/.config.nvim/init.lua', + key = 'c', }, }, - footer = { "", "Hello World!" }, + footer = { '', 'Hello World!' }, }, hide = { statusline = false, -- cgit v1.2.3 From 5890467e25af50a142260c7937453c4f8cf49773 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 22:48:58 +0200 Subject: Re-formatted file --- lua/user/pack.lua | 285 +++++++++++++++++++++++++++--------------------------- 1 file changed, 143 insertions(+), 142 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 10b47ec..cc57085 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -3,17 +3,17 @@ local fn = vim.fn -------------------------------------------------- -- Automatically install packer -local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then PACKER_BOOTSTRAP = fn.system({ - "git", - "clone", - "--depth", - "1", - "https://github.com/wbthomason/packer.nvim", + 'git', + 'clone', + '--depth', + '1', + 'https://github.com/wbthomason/packer.nvim', install_path, }) - print("Installing packer, please close and reopen Neovim...") + print('Installing packer, please close and reopen Neovim...') vim.cmd([[packadd packer.nvim]]) end @@ -30,7 +30,7 @@ vim.cmd([[ -------------------------------------------------- -- Use a protected call so don't error out on first use -local status_ok, packer = pcall(require, "packer") +local status_ok, packer = pcall(require, 'packer') if not status_ok then return end @@ -43,7 +43,7 @@ packer.init({ --max_jobs = 90, display = { open_fn = function() - return require("packer.util").float({ border = "rounded" }) + return require('packer.util').float({ border = 'rounded' }) end, }, }) @@ -53,33 +53,33 @@ packer.init({ -- Install plugins here return packer.startup(function(use) -- Defaults - use("wbthomason/packer.nvim") -- Have packer manage itself (package manager) - use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins - use("lewis6991/impatient.nvim") -- Faster loading/startup times + use('wbthomason/packer.nvim') -- Have packer manage itself (package manager) + use('nvim-lua/plenary.nvim') -- Useful lua functions used by lots of plugins + use('lewis6991/impatient.nvim') -- Faster loading/startup times -- Tree-sitter - use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... - use("nvim-treesitter/nvim-treesitter-refactor") -- Refactor module for nvim-treesitter + use({ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... + use('nvim-treesitter/nvim-treesitter-refactor') -- Refactor module for nvim-treesitter -- lsp - use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters - 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('williamboman/mason.nvim') -- Package manager to install and manage LSP servers, DAP servers, linters and formatters + 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", + 'https://git.sr.ht/~whynothugo/lsp_lines.nvim', config = function() - require("lsp_lines").setup() + require('lsp_lines').setup() end, }) - use("rmagatti/goto-preview") + use('rmagatti/goto-preview') -- Debugger - use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim - use("rcarriga/nvim-dap-ui") -- UI for nvim-dap + use('mfussenegger/nvim-dap') -- Debug Adapter Protocol client implementation for Neovim + use('rcarriga/nvim-dap-ui') -- UI for nvim-dap --use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } - use("theHamsta/nvim-dap-virtual-text") - use("gabrielpoca/replacer.nvim") - use("jayp0521/mason-nvim-dap.nvim") + use('theHamsta/nvim-dap-virtual-text') + use('gabrielpoca/replacer.nvim') + use('jayp0521/mason-nvim-dap.nvim') --use({ -- "jayp0521/mason-nvim-dap.nvim", -- config = function() @@ -91,8 +91,8 @@ return packer.startup(function(use) --}) -- Linters/Formatters - use("mhartington/formatter.nvim") - use("jay-babu/mason-null-ls.nvim") + use('mhartington/formatter.nvim') + use('jay-babu/mason-null-ls.nvim') --use({"jayp0521/mason-null-ls.nvim", -- config = function() -- require('mason-null-ls.nvim').setup({ @@ -101,110 +101,111 @@ return packer.startup(function(use) -- end --}) use({ - "jose-elias-alvarez/null-ls.nvim", -- Provides LSP: linters, formatters, diagnostics, code actions and etc... - requires = { "jay-babu/mason-null-ls.nvim" }, + 'jose-elias-alvarez/null-ls.nvim', -- Provides LSP: linters, formatters, diagnostics, code actions and etc... + requires = { 'jay-babu/mason-null-ls.nvim' }, }) -- Completion - use("hrsh7th/nvim-cmp") -- Completion engine plugin - use("hrsh7th/cmp-nvim-lsp") -- Completion source for nvim-lsp - use("hrsh7th/cmp-buffer") -- Completion source for content of current buffer - use("hrsh7th/cmp-path") -- Completion source for paths - use("hrsh7th/cmp-cmdline") -- Completion source for command-line - use("petertriho/cmp-git") -- Completion source for git - use("tamago324/cmp-zsh") -- Completion source for zsh - use("f3fora/cmp-spell") -- Completion source for spell-checking - use("hrsh7th/cmp-calc") -- Completion source for math calculation - use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip - use("hrsh7th/cmp-nvim-lsp-signature-help") -- Completion source for displaying function signatures with the current parameter emphasized - use("rcarriga/cmp-dap") + use('hrsh7th/nvim-cmp') -- Completion engine plugin + use('hrsh7th/cmp-nvim-lsp') -- Completion source for nvim-lsp + use('hrsh7th/cmp-buffer') -- Completion source for content of current buffer + use('hrsh7th/cmp-path') -- Completion source for paths + use('hrsh7th/cmp-cmdline') -- Completion source for command-line + use('petertriho/cmp-git') -- Completion source for git + use('tamago324/cmp-zsh') -- Completion source for zsh + use('f3fora/cmp-spell') -- Completion source for spell-checking + use('hrsh7th/cmp-calc') -- Completion source for math calculation + use('saadparwaiz1/cmp_luasnip') -- Completion source for snippets, specifically for luasnip + use('hrsh7th/cmp-nvim-lsp-signature-help') -- Completion source for displaying function signatures with the current parameter emphasized + use('rcarriga/cmp-dap') -- Snippets - use("L3MON4D3/LuaSnip") -- Snippet engine - use("rafamadriz/friendly-snippets") -- Collection of snippets to use + use('L3MON4D3/LuaSnip') -- Snippet engine + use('rafamadriz/friendly-snippets') -- Collection of snippets to use -- Git - use("tpope/vim-fugitive") -- + use('tpope/vim-fugitive') -- --use("dinhhuy258/git.nvim") -- For git blame & browse - use("kdheepak/lazygit.nvim") -- Terminal UI for git commands - use("lewis6991/gitsigns.nvim") -- Git decorations + use('kdheepak/lazygit.nvim') -- Terminal UI for git commands + use('lewis6991/gitsigns.nvim') -- Git decorations -- File explorer/fuzzy finder - use("kyazdani42/nvim-tree.lua") -- File explorer - use("ibhagwan/fzf-lua") -- Fuzzy finder - use("ThePrimeagen/harpoon") + use('kyazdani42/nvim-tree.lua') -- File explorer + use('ibhagwan/fzf-lua') -- Fuzzy finder + use('ThePrimeagen/harpoon') --use("nvim-telescope/telescope.nvim") -- Fuzzy finder with lots of features/extendabilities use({ - "nvim-telescope/telescope.nvim", - branch = "0.1.x", + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', --config = function() -- require('plugins.telescope').setup() --end, requires = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-live-grep-args.nvim", - "nvim-telescope/telescope-file-browser.nvim", - { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-live-grep-args.nvim', + 'nvim-telescope/telescope-file-browser.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, }, }) - use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm - use("nvim-telescope/telescope-ui-select.nvim") -- - use("nvim-telescope/telescope-project.nvim") -- - use("nvim-telescope/telescope-media-files.nvim") -- - use("nvim-telescope/telescope-file-browser.nvim") -- - use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }) -- Search emoji(s) and other symbols - use("nvim-telescope/telescope-dap.nvim") - use("axkirillov/telescope-changed-files") -- - use("smartpde/telescope-recent-files") + use({ 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }) -- Support fzf syntax/algorithm + use('nvim-telescope/telescope-ui-select.nvim') -- + use('nvim-telescope/telescope-project.nvim') -- + use('nvim-telescope/telescope-media-files.nvim') -- + use('nvim-telescope/telescope-file-browser.nvim') -- + use({ 'nvim-telescope/telescope-symbols.nvim', after = 'telescope.nvim' }) -- Search emoji(s) and other symbols + use('nvim-telescope/telescope-dap.nvim') + use('axkirillov/telescope-changed-files') -- + use('smartpde/telescope-recent-files') -- UX - use("folke/neodev.nvim") + use('folke/neodev.nvim') use({ - "numToStr/Navigator.nvim", -- Navigate between Tmux and Nvim + 'numToStr/Navigator.nvim', -- Navigate between Tmux and Nvim config = function() - require("Navigator").setup() + require('Navigator').setup() end, }) - use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }) -- Handy unix commands inside Vim (Rename, Move etc.) + 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("mbbill/undotree") + use('mbbill/undotree') use({ - "myusuf3/numbers.vim", -- + 'myusuf3/numbers.vim', -- vim.cmd("let g:numbers_exclude = ['dashboard']"), }) - use("windwp/nvim-autopairs") -- - use("numToStr/Comment.nvim") -- - use("akinsho/toggleterm.nvim") -- - use("tweekmonster/startuptime.vim") -- + use('windwp/nvim-autopairs') -- + use('numToStr/Comment.nvim') -- + use('akinsho/toggleterm.nvim') -- + use('tweekmonster/startuptime.vim') -- + use('qpkorr/vim-bufkill') use({ - "ggandor/leap.nvim", -- + 'ggandor/leap.nvim', -- config = function() - require("leap").add_default_mappings() + require('leap').add_default_mappings() --require("leap").set_default_keymaps() --vim.keymap.set('n', '-', '(leap-forward)', {}) --vim.keymap.set('n', '_', '(leap-backward)', {}) end, }) use({ - "ggandor/flit.nvim", -- + 'ggandor/flit.nvim', -- config = function() - require("flit").setup() + require('flit').setup() end, }) - use("folke/which-key.nvim") -- - use("folke/zen-mode.nvim") -- - use("romainl/vim-cool") -- - use("antoinemadec/FixCursorHold.nvim") -- + use('folke/which-key.nvim') -- + use('folke/zen-mode.nvim') -- + use('romainl/vim-cool') -- + use('antoinemadec/FixCursorHold.nvim') -- use({ - "folke/trouble.nvim", - requires = "nvim-tree/nvim-web-devicons", + 'folke/trouble.nvim', + requires = 'nvim-tree/nvim-web-devicons', }) use({ - "airblade/vim-rooter", -- + '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'") }) @@ -224,36 +225,36 @@ return packer.startup(function(use) --end, --}) use({ - "nvim-neotest/neotest", + 'nvim-neotest/neotest', requires = { { - "nvim-neotest/neotest-python", - "nvim-neotest/neotest-plenary", - "nvim-neotest/neotest-vim-test", + 'nvim-neotest/neotest-python', + 'nvim-neotest/neotest-plenary', + 'nvim-neotest/neotest-vim-test', }, }, }) use({ - "rmagatti/session-lens", - requires = { "rmagatti/auto-session", "nvim-telescope/telescope.nvim" }, + 'rmagatti/session-lens', + requires = { 'rmagatti/auto-session', 'nvim-telescope/telescope.nvim' }, config = function() - require("session-lens").setup({ --[[your custom config--]] + require('session-lens').setup({ --[[your custom config--]] }) - vim.keymap.set("n", "s", require("session-lens").search_session) -- <-- this sets it to `Ctrl + s` + vim.keymap.set('n', 's', require('session-lens').search_session) -- <-- this sets it to `Ctrl + s` end, }) -- Colorschemes - use("bluz71/vim-nightfly-guicolors") - use("ayu-theme/ayu-vim") - use("joshdick/onedark.vim") - use("NTBBloodbath/doom-one.nvim") - use("nyngwang/nvimgelion") - use("projekt0n/github-nvim-theme") + use('bluz71/vim-nightfly-guicolors') + use('ayu-theme/ayu-vim') + use('joshdick/onedark.vim') + use('NTBBloodbath/doom-one.nvim') + use('nyngwang/nvimgelion') + use('projekt0n/github-nvim-theme') use({ - "folke/tokyonight.nvim", + 'folke/tokyonight.nvim', config = function() - require("tokyonight").setup({ + require('tokyonight').setup({ transparent = true, dim_inactive = false, }) @@ -261,36 +262,36 @@ return packer.startup(function(use) }) -- UI - use("kyazdani42/nvim-web-devicons") -- - use("onsails/lspkind-nvim") -- - use({ "kevinhwang91/nvim-ufo", requires = "kevinhwang91/promise-async" }) -- Fold code + use('kyazdani42/nvim-web-devicons') -- + use('onsails/lspkind-nvim') -- + use({ 'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async' }) -- Fold code use({ - "luukvbaal/statuscol.nvim", + 'luukvbaal/statuscol.nvim', config = function() - local builtin = require("statuscol.builtin") - require("statuscol").setup({ + local builtin = require('statuscol.builtin') + require('statuscol').setup({ relculright = true, segments = { - { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, - { text = { "%s" }, click = "v:lua.ScSa" }, - { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + { text = { builtin.foldfunc }, click = 'v:lua.ScFa' }, + { text = { '%s' }, click = 'v:lua.ScSa' }, + { text = { builtin.lnumfunc, ' ' }, click = 'v:lua.ScLa' }, }, }) end, }) use({ - "glepnir/dashboard-nvim", + 'glepnir/dashboard-nvim', --event = 'VimEnter', - requires = { "nvim-tree/nvim-web-devicons" }, + requires = { 'nvim-tree/nvim-web-devicons' }, }) - use("rcarriga/nvim-notify") -- Notification plugin - use("karb94/neoscroll.nvim") -- Faster/smooth scrolling + 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({ - "norcalli/nvim-colorizer.lua", -- colorize hexa and rgb strings - cmd = { "ColorizerToggle", "ColorizerAttachToBuffer" }, + 'norcalli/nvim-colorizer.lua', -- colorize hexa and rgb strings + cmd = { 'ColorizerToggle', 'ColorizerAttachToBuffer' }, config = function() - require("colorizer").setup({ + require('colorizer').setup({ --'*'; user_default_options = { RGB = true, @@ -299,54 +300,54 @@ return packer.startup(function(use) RRGGBBAA = false, css = false, css_fn = true, - mode = "foreground", + mode = 'foreground', }, }) end, }) use({ - "j-hui/fidget.nvim", - tag = "legacy", + 'j-hui/fidget.nvim', + tag = 'legacy', }) -- UI to show nvim-lsp progress use({ - "simrat39/symbols-outline.nvim", -- + 'simrat39/symbols-outline.nvim', -- config = function() - require("symbols-outline").setup({ + require('symbols-outline').setup({ auto_close = true, }) end, }) use({ - "kosayoda/nvim-lightbulb", -- - requires = "antoinemadec/FixCursorHold.nvim", + 'kosayoda/nvim-lightbulb', -- + requires = 'antoinemadec/FixCursorHold.nvim', }) use({ - "SmiteshP/nvim-navic", -- Statusline/Winbar component that uses LSP to show current code context - requires = "neovim/nvim-lspconfig", + 'SmiteshP/nvim-navic', -- Statusline/Winbar component that uses LSP to show current code context + requires = 'neovim/nvim-lspconfig', }) use({ - "rebelot/heirline.nvim", -- Statusline that is highly configurable + 'rebelot/heirline.nvim', -- Statusline that is highly configurable --requires = 'kyazdani42/nvim-web-devicons', --event = 'VimEnter', }) -- Language specific tools - use("simrat39/rust-tools.nvim") -- Rust tooling ecosystem + use('simrat39/rust-tools.nvim') -- Rust tooling ecosystem use({ - "saecki/crates.nvim", -- - requires = { "nvim-lua/plenary.nvim" }, + 'saecki/crates.nvim', -- + requires = { 'nvim-lua/plenary.nvim' }, config = function() - require("crates").setup() + require('crates').setup() end, }) use({ - "akinsho/flutter-tools.nvim", + 'akinsho/flutter-tools.nvim', requires = { - "nvim-lua/plenary.nvim", - "stevearc/dressing.nvim", -- optional for vim.ui.select + 'nvim-lua/plenary.nvim', + 'stevearc/dressing.nvim', -- optional for vim.ui.select }, config = function() - require("flutter-tools").setup({ + require('flutter-tools').setup({ debugger = { enabled = true, run_via_dap = true, @@ -355,16 +356,16 @@ return packer.startup(function(use) end, }) use({ - "iamcco/markdown-preview.nvim", -- Markdown Preview + 'iamcco/markdown-preview.nvim', -- Markdown Preview run = function() - vim.fn["mkdp#util#install"]() + vim.fn['mkdp#util#install']() end, }) use({ - "ellisonleao/glow.nvim", -- Markdown Preview + 'ellisonleao/glow.nvim', -- Markdown Preview config = function() - require("glow").setup({ - style = "dark", + require('glow').setup({ + style = 'dark', }) end, }) @@ -374,6 +375,6 @@ return packer.startup(function(use) -- Automatically set up your configuration after cloning packer.nvim -- Put this at the end after all plugins if PACKER_BOOTSTRAP then - require("packer").sync() + require('packer').sync() end end) -- cgit v1.2.3 From ace51640ef59bb1a33fa104778349c4a159637b7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 22:57:45 +0200 Subject: Changed binding for nvim-tree.FindFile --- 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 62c17e1..4b70553 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -309,7 +309,7 @@ map('n', 'fz', "lua require('fzf-lua').files()") -- Nvim-tree map('n', 'f', 'Rooter:NvimTreeToggle', {}) -map('n', '', ':NvimTreeFindFileToggle', { noremap = false, silent = true }) +map('n', 'F', ':NvimTreeFindFileToggle', { noremap = false, silent = true }) -- Undotree map('n', 'u', vim.cmd.UndotreeToggle) -- cgit v1.2.3 From 7d028420d0cd8592c36f9b50950f4b72fe613aa7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 23:01:24 +0200 Subject: Add custom devicons --- lua/plugins/web-devicons.lua | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lua/plugins/web-devicons.lua b/lua/plugins/web-devicons.lua index 2f68275..06f2d1c 100644 --- a/lua/plugins/web-devicons.lua +++ b/lua/plugins/web-devicons.lua @@ -1,17 +1,22 @@ ---local status, icons = pcall(require, "nvim-web-devicons") ---if (not status) then return end ---icons.setup { -require'nvim-web-devicons'.setup { +local devicons = require('nvim-web-devicons') + +-- Set devicons overrides early. +devicons.setup({ override = { + js = { icon = '󰌞', color = '#f5c06f', name = 'Js' }, + jsx = { icon = '', color = '#689fb6', name = 'Jsx' }, + ts = { icon = '󰛦', color = '#4377c1', name = 'Ts' }, + tsx = { icon = '', color = '#4377c1', name = 'Tsx' }, + png = { icon = '󰋩', color = '#d4843e', name = 'Png' }, + webp = { icon = '󰋩', color = '#3498db', name = 'Webp' }, + jpg = { icon = '󰋩', color = '#16a085', name = 'Jpg' }, + svg = { icon = '󰋩', color = '#3affdb', name = 'Svg' }, zsh = { - icon = "", - color = "#428850", - cterm_color = "65", - name = "Zsh" - }; - color_icons = true; + icon = '', + color = '#428850', + cterm_color = '65', + name = 'Zsh', + }, }, - -- globally enable default icons (default to false) - -- will get overriden by `get_icons` option - --default = true -} + color_icons = true, +}) -- cgit v1.2.3 From 9a60230047b4e0c508d4a7e07d5ebfdb8f68743e Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 19 Aug 2023 23:05:54 +0200 Subject: More short message options --- lua/user/opts.lua | 156 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 69 deletions(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 7af412b..f8cb064 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -3,11 +3,11 @@ -- Environment --vim.opt.shell = "zsh" -- vim.o.updatetime = 250 -vim.o.shell = "/bin/zsh" -vim.scriptencoding = "utf-8" -- -vim.opt.encoding = "utf-8" -- -vim.opt.fileencoding = "utf-8" -- -vim.g.python3_host_prog = "/usr/bin/python3" -- +vim.o.shell = '/bin/zsh' +vim.scriptencoding = 'utf-8' -- +vim.opt.encoding = 'utf-8' -- +vim.opt.fileencoding = 'utf-8' -- +vim.g.python3_host_prog = '/usr/bin/python3' -- vim.g.loaded_python3_provider = 1 -- vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file vim.o.autochdir = true @@ -17,27 +17,27 @@ vim.o.autochdir = true vim.opt.termguicolors = true -- Clipboard -vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup +vim.opt.clipboard:append({ 'unnamedplus' }) -- Install xclip or this will slowdown startup -- Behaviour -vim.opt.backspace = { "start", "eol", "indent" } -- Make backspace work as you would expect. +vim.opt.backspace = { 'start', 'eol', 'indent' } -- Make backspace work as you would expect. vim.opt.hidden = true -- Switch between buffers without having to save first. vim.opt.splitbelow = true -- make split put the new buffer below the current buffer vim.opt.splitright = true -- make vsplit put the new buffer on the right of the current buffer vim.opt.scrolloff = 8 -- vim.opt.sidescrolloff = 8 -- how many lines to scroll when using the scrollbar vim.opt.autoread = true -- reload files if changed externally -vim.opt.display = "lastline" -- Show as much as possible of the last line. -vim.opt.inccommand = "split" -- +vim.opt.display = 'lastline' -- Show as much as possible of the last line. +vim.opt.inccommand = 'split' -- vim.opt.ttyfast = true -- Faster redrawing. vim.opt.lazyredraw = false -- Only redraw when necessary -vim.opt.keywordprg = ":help" -- :help options +vim.opt.keywordprg = ':help' -- :help options vim.opt.ruler = true -- vim.opt.errorbells = false -- vim.opt.list = true -- Show non-printable characters. vim.opt.showmatch = true -- vim.opt.matchtime = 3 -- -vim.opt.showbreak = "↪ " -- +vim.opt.showbreak = '↪ ' -- vim.opt.linebreak = true -- vim.opt.exrc = true -- --vim.opt.autochdir = true -- or use this to use <:e> to create a file in current directory @@ -65,7 +65,7 @@ vim.opt.smartindent = true -- smart indent vim.opt.number = true -- vim.opt.title = true -- --vim.opt.colorcolumn = "+1" -- -vim.opt.signcolumn = "yes:1" -- always show the sign column +vim.opt.signcolumn = 'yes:1' -- always show the sign column --vim.opt.signcolumn = "yes:" .. vim.o.numberwidth --vim.opt.signcolumn = "number" --vim.opt.signcolumn = "no" -- @@ -93,76 +93,94 @@ vim.opt.report = 0 -- Always report changed lines. --vim.opt.stl = " " -- Backup/undo/swap -local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") +local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand('~/.config') --vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" -vim.opt.undodir = { prefix .. "/nvim/tmp/.undo//" } -vim.opt.directory = { prefix .. "/nvim/tmp/.swp//" } -vim.opt.backupdir = { prefix .. "/nvim/tmp/.backup//" } +vim.opt.undodir = { prefix .. '/nvim/tmp/.undo//' } +vim.opt.directory = { prefix .. '/nvim/tmp/.swp//' } +vim.opt.backupdir = { prefix .. '/nvim/tmp/.backup//' } vim.opt.undofile = true -- vim.opt.swapfile = true -- vim.opt.backup = true -- --vim.opt.backupcopy = -- Add timestamp as extension for backup files -vim.api.nvim_create_autocmd("BufWritePre", { - group = vim.api.nvim_create_augroup("timestamp_backupext", { clear = true }), - desc = "Add timestamp to backup extension", - pattern = "*", +vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('timestamp_backupext', { clear = true }), + desc = 'Add timestamp to backup extension', + pattern = '*', callback = function() - vim.opt.backupext = "-" .. vim.fn.strftime("%Y%m%d%H%M") + vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') end, }) -- Format --vim.opt.textwidth = 80 -- -vim.opt.isfname:append("@-@") +vim.opt.isfname:append('@-@') vim.cmd([[let &t_Cs = "\e[4:3m"]]) -- Undercurl vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- -vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolder -vim.cmd("set whichwrap+=<,>,[,],h,l") -- +vim.opt.path:append({ '**' }) -- Finding files - Search down into subfolder +vim.cmd('set whichwrap+=<,>,[,],h,l') -- vim.cmd([[set iskeyword+=-]]) -- --vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work vim.opt.formatoptions = vim.opt.formatoptions - - "t" -- wrap with text width - + "c" -- wrap comments - + "r" -- insert comment after enter - - "o" -- insert comment after o/O - - "q" -- allow formatting of comments with gq - - "a" -- format paragraphs - + "n" -- recognized numbered lists - - "2" -- use indent of second line for paragraph - + "l" -- long lines are not broken - + "j" -- remove comment when joining lines + - 't' -- wrap with text width + + 'c' -- wrap comments + + 'r' -- insert comment after enter + - 'o' -- insert comment after o/O + - 'q' -- allow formatting of comments with gq + - 'a' -- format paragraphs + + 'n' -- recognized numbered lists + - '2' -- use indent of second line for paragraph + + 'l' -- long lines are not broken + + 'j' -- remove comment when joining lines vim.opt.wrapscan = true -- " Searches wrap around end-of-file. --vim.wo.number = true -- --vim.opt.wrap = false -- No Wrap lines --vim.opt.foldmethod = 'manual' -- --vim.opt.foldmethod = "expr" -- -vim.opt.foldmethod = "manual" +vim.opt.foldmethod = 'manual' vim.opt.foldlevel = 3 vim.opt.confirm = false -vim.opt.shortmess:append("sI") +--vim.opt.shortmess:append("sI") --vim.opt.shortmess = "a" --vim.opt.shortmess = "sI" --vim.o.shortmess = vim.o.shortmess:gsub('s', '') +vim.opt.shortmess = table.concat({ -- Use abbreviations and short messages in command menu line. + 'f', -- Use "(3 of 5)" instead of "(file 3 of 5)". + 'i', -- Use "[noeol]" instead of "[Incomplete last line]". + 'l', -- Use "999L, 888C" instead of "999 lines, 888 characters". + 'm', -- Use "[+]" instead of "[Modified]". + 'n', -- Use "[New]" instead of "[New File]". + 'r', -- Use "[RO]" instead of "[readonly]". + 'w', -- Use "[w]", "[a]" instead of "written", "appended". + 'x', -- Use "[dos]", "[unix]", "[mac]" instead of "[dos format]", "[unix format]", "[mac format]". + 'o', -- Overwrite message for writing a file with subsequent message. + 'O', -- Message for reading a file overwrites any previous message. + 's', -- Disable "search hit BOTTOM, continuing at TOP" such messages. + 't', -- Truncate file message at the start if it is too long. + 'T', -- Truncate other messages in the middle if they are too long. + 'I', -- Don't give the :intro message when starting. + 'c', -- Don't give ins-completion-menu messages. + 'F', -- Don't give the file info when editing a file. +}) vim.opt.fillchars = { - horiz = "─", - horizup = "┴", - horizdown = "┬", - vert = "│", - vertleft = "┤", - vertright = "├", - verthoriz = "┼", - foldopen = "", - foldsep = "│", - foldclose = "", - fold = "─", - eob = " ", + horiz = '─', + horizup = '┴', + horizdown = '┬', + vert = '│', + vertleft = '┤', + vertright = '├', + verthoriz = '┼', + foldopen = '', + foldsep = '│', + foldclose = '', + fold = '─', + eob = ' ', --diff = "┃", - diff = "░", - msgsep = "━", + diff = '░', + msgsep = '━', --msgsep = "‾", } -vim.opt.listchars = { tab = "▸ ", trail = "·" } -- +vim.opt.listchars = { tab = '▸ ', trail = '·' } -- --vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer vim.opt.modeline = true -- vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis) @@ -179,40 +197,40 @@ vim.opt.smartcase = true -- smart case vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns. vim.opt.winblend = 30 --vim.opt.winblend = 5 -vim.opt.wildoptions = "pum" -- +vim.opt.wildoptions = 'pum' -- --vim.opt.pumblend = 5 -- vim.opt.pumblend = 12 -- --vim.opt.pumblend=15 vim.opt.pumheight = 10 -- pop up menu height -- Better Completion -vim.opt.complete = { ".", "w", "b", "u", "t" } -- +vim.opt.complete = { '.', 'w', 'b', 'u', 't' } -- --vim.opt.completeopt = { "longest,menuone,preview" } -- -vim.opt.completeopt = { "menu", "menuone", "noselect" } +vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } --vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp --vim.opt.completeopt = { "menu", "menuone", "noselect" } -- -- Wildmenu completion -- vim.opt.wildmenu = true -- -vim.opt.wildmode = { "list:longest" } -- -vim.opt.wildignore:append({ ".hg", ".git", ".svn" }) -- Version control -vim.opt.wildignore:append({ "*.aux", "*.out", "*.toc" }) -- LaTeX intermediate files -vim.opt.wildignore:append({ "*.jpg", "*.bmp", "*.gif", "*.png", "*.jpeg" }) -- binary images -vim.opt.wildignore:append({ "*.o", "*.obj", "*.exe", "*.dll", "*.manifest" }) -- compiled object files -vim.opt.wildignore:append({ "*.spl" }) -- compiled spelling word lists -vim.opt.wildignore:append({ "*.sw?" }) -- Vim swap files -vim.opt.wildignore:append({ "*.DS_Store" }) -- OSX bullshit -vim.opt.wildignore:append({ "*.luac" }) -- Lua byte code -vim.opt.wildignore:append({ "migrations" }) -- Django migrations -vim.opt.wildignore:append({ "*.pyc" }) -- Python byte code -vim.opt.wildignore:append({ "*.orig" }) -- Merge resolution files -vim.opt.wildignore:append({ "*/node_modules/*" }) -- +vim.opt.wildmode = { 'list:longest' } -- +vim.opt.wildignore:append({ '.hg', '.git', '.svn' }) -- Version control +vim.opt.wildignore:append({ '*.aux', '*.out', '*.toc' }) -- LaTeX intermediate files +vim.opt.wildignore:append({ '*.jpg', '*.bmp', '*.gif', '*.png', '*.jpeg' }) -- binary images +vim.opt.wildignore:append({ '*.o', '*.obj', '*.exe', '*.dll', '*.manifest' }) -- compiled object files +vim.opt.wildignore:append({ '*.spl' }) -- compiled spelling word lists +vim.opt.wildignore:append({ '*.sw?' }) -- Vim swap files +vim.opt.wildignore:append({ '*.DS_Store' }) -- OSX bullshit +vim.opt.wildignore:append({ '*.luac' }) -- Lua byte code +vim.opt.wildignore:append({ 'migrations' }) -- Django migrations +vim.opt.wildignore:append({ '*.pyc' }) -- Python byte code +vim.opt.wildignore:append({ '*.orig' }) -- Merge resolution files +vim.opt.wildignore:append({ '*/node_modules/*' }) -- -- Shada vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" -- Sessions -vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +vim.opt.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal' --vim.opt.sessionoptions = "curdir,folds,help,options,tabpages,winsize,winpos,terminal,globals" -- --vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" --vim.opt.sessionoptions:remove({ "blank", "buffers", "globals" }) @@ -263,7 +281,7 @@ vim.cmd([[ " Only show cursorline in the augroup END ]]) vim.opt.cursorline = true -- -vim.opt.guicursor = "i:ver100,r:hor100" -- +vim.opt.guicursor = 'i:ver100,r:hor100' -- -- Trailing whitespace vim.cmd([[ " Only show in insert mode -- cgit v1.2.3 From ee86f0bd6c858c9d1fc3edd67352172a0f9faa58 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 21 Aug 2023 18:29:06 +0200 Subject: Update on cwd --- lua/plugins/nvim-tree.lua | 208 +++++++++++++++++++++++----------------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 31c77a3..906db81 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -6,9 +6,9 @@ --- To see default mappings `:nvim-tree-default-mappings` local icons = { - git_placement = "after", - modified_placement = "after", - padding = " ", + git_placement = 'after', + modified_placement = 'after', + padding = ' ', show = { file = true, folder = true, @@ -18,26 +18,26 @@ local icons = { }, glyphs = { - default = "󰈔", - symlink = "", + default = '󰈔', + symlink = '', folder = { - arrow_open = "", - arrow_closed = "", - default = " ", - open = " ", - empty = " ", - empty_open = " ", - symlink = "", - symlink_open = "", + arrow_open = '', + arrow_closed = '', + default = ' ', + open = ' ', + empty = ' ', + empty_open = ' ', + symlink = '', + symlink_open = '', }, git = { - deleted = "", - unmerged = "", - untracked = "", - unstaged = "", - staged = "", - renamed = "➜", - ignored = "◌", + deleted = '', + unmerged = '', + untracked = '', + unstaged = '', + staged = '', + renamed = '➜', + ignored = '◌', }, }, } @@ -48,17 +48,17 @@ local renderer = { enable = true, inline_arrows = true, icons = { - corner = "└", - edge = "│", - item = "│", - bottom = "─", - none = " ", + corner = '└', + edge = '│', + item = '│', + bottom = '─', + none = ' ', }, }, icons = icons, } -local system_open = { cmd = "zathura" } +local system_open = { cmd = 'zathura' } local HEIGHT_RATIO = 0.8 local WIDTH_RATIO = 0.15 @@ -75,8 +75,8 @@ local float = { local center_x = (screen_w - window_w) / 2 local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() return { - border = "rounded", - relative = "editor", + border = 'rounded', + relative = 'editor', row = center_y, col = center_x, width = window_w_int, @@ -89,97 +89,97 @@ local view = { cursorline = false, hide_root_folder = false, float = float, - signcolumn = "no", + signcolumn = 'no', width = function() return math.floor(vim.opt.columns:get() * WIDTH_RATIO) end, - side = "left", + side = 'left', } -local api = require("nvim-tree.api") +local api = require('nvim-tree.api') local function on_attach(bufnr) local function opts(desc) - return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } end local mappings = { - [""] = { api.tree.change_root_to_node, "CD" }, - [""] = { api.node.open.replace_tree_buffer, "Open: In Place" }, - [""] = { api.node.show_info_popup, "Info" }, - [""] = { api.fs.rename_sub, "Rename: Omit Filename" }, - [""] = { api.node.open.tab, "Open: New Tab" }, - [""] = { api.node.open.vertical, "Open: Vertical Split" }, - [""] = { api.node.open.horizontal, "Open: Horizontal Split" }, - [""] = { api.node.navigate.parent_close, "Close Directory" }, + [''] = { api.tree.change_root_to_node, 'CD' }, + [''] = { api.node.open.replace_tree_buffer, 'Open: In Place' }, + [''] = { api.node.show_info_popup, 'Info' }, + [''] = { api.fs.rename_sub, 'Rename: Omit Filename' }, + [''] = { api.node.open.tab, 'Open: New Tab' }, + [''] = { api.node.open.vertical, 'Open: Vertical Split' }, + [''] = { api.node.open.horizontal, 'Open: Horizontal Split' }, + [''] = { api.node.navigate.parent_close, 'Close Directory' }, -- [""] = { api.node.open.edit, "Open" }, - [""] = { api.node.open.preview, "Open Preview" }, - [">"] = { api.node.navigate.sibling.next, "Next Sibling" }, - ["<"] = { api.node.navigate.sibling.prev, "Previous Sibling" }, - ["."] = { api.node.run.cmd, "Run Command" }, - ["-"] = { api.tree.change_root_to_parent, "Up" }, - ["a"] = { api.fs.create, "Create" }, - ["bmv"] = { api.marks.bulk.move, "Move Bookmarked" }, - ["B"] = { api.tree.toggle_no_buffer_filter, "Toggle No Buffer" }, - ["c"] = { api.fs.copy.node, "Copy" }, + [''] = { api.node.open.preview, 'Open Preview' }, + ['>'] = { api.node.navigate.sibling.next, 'Next Sibling' }, + ['<'] = { api.node.navigate.sibling.prev, 'Previous Sibling' }, + ['.'] = { api.node.run.cmd, 'Run Command' }, + ['-'] = { api.tree.change_root_to_parent, 'Up' }, + ['a'] = { api.fs.create, 'Create' }, + ['bmv'] = { api.marks.bulk.move, 'Move Bookmarked' }, + ['B'] = { api.tree.toggle_no_buffer_filter, 'Toggle No Buffer' }, + ['c'] = { api.fs.copy.node, 'Copy' }, -- ["C"] = { api.tree.toggle_git_clean_filter, "Toggle Git Clean" }, - ["[c"] = { api.node.navigate.git.prev, "Prev Git" }, - ["]c"] = { api.node.navigate.git.next, "Next Git" }, - ["d"] = { api.fs.remove, "Delete" }, - ["D"] = { api.fs.trash, "Trash" }, - ["E"] = { api.tree.expand_all, "Expand All" }, - ["e"] = { api.fs.rename_basename, "Rename: Basename" }, - ["]e"] = { api.node.navigate.diagnostics.next, "Next Diagnostic" }, - ["[e"] = { api.node.navigate.diagnostics.prev, "Prev Diagnostic" }, - ["F"] = { api.live_filter.clear, "Clean Filter" }, - ["f"] = { api.live_filter.start, "Filter" }, - ["g?"] = { api.tree.toggle_help, "Help" }, - ["gy"] = { api.fs.copy.absolute_path, "Copy Absolute Path" }, - ["H"] = { api.tree.toggle_hidden_filter, "Toggle Dotfiles" }, - ["I"] = { api.tree.toggle_gitignore_filter, "Toggle Git Ignore" }, - ["J"] = { api.node.navigate.sibling.last, "Last Sibling" }, - ["K"] = { api.node.navigate.sibling.first, "First Sibling" }, - ["m"] = { api.marks.toggle, "Toggle Bookmark" }, + ['[c'] = { api.node.navigate.git.prev, 'Prev Git' }, + [']c'] = { api.node.navigate.git.next, 'Next Git' }, + ['d'] = { api.fs.remove, 'Delete' }, + ['D'] = { api.fs.trash, 'Trash' }, + ['E'] = { api.tree.expand_all, 'Expand All' }, + ['e'] = { api.fs.rename_basename, 'Rename: Basename' }, + [']e'] = { api.node.navigate.diagnostics.next, 'Next Diagnostic' }, + ['[e'] = { api.node.navigate.diagnostics.prev, 'Prev Diagnostic' }, + ['F'] = { api.live_filter.clear, 'Clean Filter' }, + ['f'] = { api.live_filter.start, 'Filter' }, + ['g?'] = { api.tree.toggle_help, 'Help' }, + ['gy'] = { api.fs.copy.absolute_path, 'Copy Absolute Path' }, + ['H'] = { api.tree.toggle_hidden_filter, 'Toggle Dotfiles' }, + ['I'] = { api.tree.toggle_gitignore_filter, 'Toggle Git Ignore' }, + ['J'] = { api.node.navigate.sibling.last, 'Last Sibling' }, + ['K'] = { api.node.navigate.sibling.first, 'First Sibling' }, + ['m'] = { api.marks.toggle, 'Toggle Bookmark' }, -- ["o"] = { api.node.open.edit, "Open" }, - ["O"] = { api.node.open.no_window_picker, "Open: No Window Picker" }, - ["p"] = { api.fs.paste, "Paste" }, - ["P"] = { api.node.navigate.parent, "Parent Directory" }, - ["q"] = { api.tree.close, "Close" }, - ["r"] = { api.fs.rename, "Rename" }, - ["R"] = { api.tree.reload, "Refresh" }, - ["s"] = { api.node.run.system, "Run System" }, - ["S"] = { api.tree.search_node, "Search" }, - ["U"] = { api.tree.toggle_custom_filter, "Toggle Hidden" }, - ["W"] = { api.tree.collapse_all, "Collapse" }, - ["x"] = { api.fs.cut, "Cut" }, - ["y"] = { api.fs.copy.filename, "Copy Name" }, - ["Y"] = { api.fs.copy.relative_path, "Copy Relative Path" }, - ["<2-LeftMouse>"] = { api.node.open.edit, "Open" }, - ["<2-RightMouse>"] = { api.tree.change_root_to_node, "CD" }, + ['O'] = { api.node.open.no_window_picker, 'Open: No Window Picker' }, + ['p'] = { api.fs.paste, 'Paste' }, + ['P'] = { api.node.navigate.parent, 'Parent Directory' }, + ['q'] = { api.tree.close, 'Close' }, + ['r'] = { api.fs.rename, 'Rename' }, + ['R'] = { api.tree.reload, 'Refresh' }, + ['s'] = { api.node.run.system, 'Run System' }, + ['S'] = { api.tree.search_node, 'Search' }, + ['U'] = { api.tree.toggle_custom_filter, 'Toggle Hidden' }, + ['W'] = { api.tree.collapse_all, 'Collapse' }, + ['x'] = { api.fs.cut, 'Cut' }, + ['y'] = { api.fs.copy.filename, 'Copy Name' }, + ['Y'] = { api.fs.copy.relative_path, 'Copy Relative Path' }, + ['<2-LeftMouse>'] = { api.node.open.edit, 'Open' }, + ['<2-RightMouse>'] = { api.tree.change_root_to_node, 'CD' }, -- Mappings migrated from view.mappings.list - ["l"] = { api.node.open.edit, "Open" }, - [""] = { api.node.open.edit, "Open" }, - ["o"] = { api.node.open.edit, "Open" }, - ["h"] = { api.node.navigate.parent_close, "Close Directory" }, - ["v"] = { api.node.open.vertical, "Open: Vertical Split" }, - ["C"] = { api.tree.change_root_to_node, "CD" }, + ['l'] = { api.node.open.edit, 'Open' }, + [''] = { api.node.open.edit, 'Open' }, + ['o'] = { api.node.open.edit, 'Open' }, + ['h'] = { api.node.navigate.parent_close, 'Close Directory' }, + ['v'] = { api.node.open.vertical, 'Open: Vertical Split' }, + ['C'] = { api.tree.change_root_to_node, 'CD' }, } for keys, mapping in pairs(mappings) do - vim.keymap.set("n", keys, mapping[1], opts(mapping[2])) + vim.keymap.set('n', keys, mapping[1], opts(mapping[2])) end end api.events.subscribe(api.events.Event.FileCreated, function(file) - vim.cmd("edit" .. file.fname) + vim.cmd('edit' .. file.fname) end) -require("nvim-tree").setup({ +require('nvim-tree').setup({ disable_netrw = true, hijack_netrw = true, auto_reload_on_write = true, update_focused_file = { enable = true, update_cwd = false, - update_root = false, + update_root = true, ignore_list = {}, }, root_dirs = {}, @@ -203,14 +203,14 @@ require("nvim-tree").setup({ enable = true, show_on_dirs = true, icons = { - hint = "⚑", - info = "􀅳", - warning = "▲", - error = "", + hint = '⚑', + info = '􀅳', + warning = '▲', + error = '', }, }, trash = { - cmd = "gio trash", + cmd = 'gio trash', require_confirm = true, }, modified = { @@ -233,17 +233,17 @@ require("nvim-tree").setup({ resize_window = false, window_picker = { enable = true, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "nofile", "terminal", "help" }, + filetype = { 'notify', 'packer', 'qf', 'diff', 'fugitive', 'fugitiveblame' }, + buftype = { 'nofile', 'terminal', 'help' }, }, }, }, }, }) -local api = require("nvim-tree.api") +local api = require('nvim-tree.api') local event = api.events.Event api.events.subscribe(event.TreeOpen, function(_) vim.cmd([[setlocal statuscolumn=\ ]]) @@ -254,17 +254,17 @@ api.events.subscribe(event.TreeOpen, function(_) end) local function open_nvim_tree(data) - vim.cmd.cd(data.file:match("(.+)/[^/]*$")) + vim.cmd.cd(data.file:match('(.+)/[^/]*$')) local directory = vim.fn.isdirectory(data.file) == 1 if not directory then return end - require("nvim-tree.api").tree.open() + require('nvim-tree.api').tree.open() end -vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) +vim.api.nvim_create_autocmd({ 'VimEnter' }, { callback = open_nvim_tree }) -- Highlight Groups -vim.api.nvim_command("highlight NvimTreeNormal guibg=none") +vim.api.nvim_command('highlight NvimTreeNormal guibg=none') --vim.api.nvim_command("highlight NvimTreeSymlink ") --vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) --vim.api.nvim_command("highlight NvimTreeFolderName ") --(Directory) -- cgit v1.2.3 From 96e346502adacbd7886fe545c911447287c90ffe Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 21 Aug 2023 18:29:30 +0200 Subject: Little change to telescopes's find_files --- lua/user/keys.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 4b70553..00dc3fd 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -276,9 +276,7 @@ map('n', 'gm', ':Gmove') --map("n", "gpl", ":Dispatch! git pull") -- Telescope -map('n', 'ff', function() - require('telescope.builtin').find_files({ hidden = true, no_ignore = false }) -end) -- find files +map('n', 'ff', "lua 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', 'ff.', function() require('telescope.builtin').find_files({ hidden = false, no_ignore = true }) -- cgit v1.2.3 From a20928095162679989784bd5ecac60f54ac0b1e0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 23 Aug 2023 16:18:41 +0200 Subject: Changed statusline to be rounded edges --- lua/plugins/heirline.lua | 493 ++++++++++++++++++++++++----------------------- 1 file changed, 248 insertions(+), 245 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 5c3eb44..786f5cb 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -1,44 +1,44 @@ -local conditions = require("heirline.conditions") -local utils = require("heirline.utils") +local conditions = require('heirline.conditions') +local utils = require('heirline.utils') local colors = { --bg = "#23232e", bg = nil, - nobg = "NONE", - white = "#f8f8f2", - black = "#000000", - darkgray = "#23232e", - gray = "#2d2b3a", - lightgray = "#d6d3ea", - pink = "#f92672", - green = "#50fa7b", - blue = "#39BAE6", - yellow = "#f1fa8c", - orange = "#ffb86c", - purple = "#BF40BF", - violet = "#7F00FF", - red = "#ff5555", - cyan = "#66d9eC", + nobg = 'NONE', + white = '#f8f8f2', + black = '#000000', + darkgray = '#23232e', + gray = '#2d2b3a', + lightgray = '#d6d3ea', + pink = '#f92672', + green = '#50fa7b', + blue = '#39BAE6', + yellow = '#f1fa8c', + orange = '#ffb86c', + purple = '#BF40BF', + violet = '#7F00FF', + red = '#ff5555', + cyan = '#66d9eC', diag = { - warn = utils.get_highlight("DiagnosticSignWarn").fg, - error = utils.get_highlight("DiagnosticSignError").fg, - hint = utils.get_highlight("DiagnosticSignHint").fg, - info = utils.get_highlight("DiagnosticSignInfo").fg, + warn = utils.get_highlight('DiagnosticSignWarn').fg, + error = utils.get_highlight('DiagnosticSignError').fg, + hint = utils.get_highlight('DiagnosticSignHint').fg, + info = utils.get_highlight('DiagnosticSignInfo').fg, }, git = { - del = "#e95678", - add = "#a6e22e", - change = "#ae81ff", + del = '#e95678', + add = '#a6e22e', + change = '#ae81ff', }, } -require("heirline").load_colors(colors) +require('heirline').load_colors(colors) -local Align = { provider = "%=", hl = { bg = colors.bg } } -local Space = { provider = " ", hl = { bg = colors.bg } } -local Tab = { provider = " " } -local LeftSpace = { provider = "" } -local RightSpace = { provider = "" } +local Align = { provider = '%=', hl = { bg = colors.bg } } +local Space = { provider = ' ', hl = { bg = colors.bg } } +local Tab = { provider = ' ' } +local LeftSpace = { provider = '' } +local RightSpace = { provider = '' } local ViMode = { init = function(self) @@ -50,100 +50,104 @@ local ViMode = { end, static = { mode_names = { - n = " NORMAL ", - no = "PENDING ", - nov = " N? ", - noV = " N? ", - ["no\22"] = " N? ", - niI = " Ni ", - niR = " Nr ", - niV = " Nv ", - nt = "TERMINAL", - v = " VISUAL ", - vs = " Vs ", - V = " V·LINE ", - ["\22"] = "V·BLOCK ", - ["\22s"] = "V·BLOCK ", - s = " SELECT ", - S = " S·LINE ", - ["\19"] = "S·BLOCK ", - i = " INSERT ", - ix = "insert x", - ic = "insert c", - R = "REPLACE ", - Rc = " Rc ", - Rx = " Rx ", - Rv = "V·REPLACE ", - Rvc = " Rv ", - Rvx = " Rv ", - c = "COMMAND ", - cv = " VIM EX ", - ce = " EX ", - r = " PROMPT ", - rm = " MORE ", - ["r?"] = "CONFIRM ", - ["!"] = " SHELL ", - t = "TERMINAL", + n = ' NORMAL ', + no = 'PENDING ', + nov = ' N? ', + noV = ' N? ', + ['no\22'] = ' N? ', + niI = ' Ni ', + niR = ' Nr ', + niV = ' Nv ', + nt = 'TERMINAL', + v = ' VISUAL ', + vs = ' Vs ', + V = ' V·LINE ', + ['\22'] = 'V·BLOCK ', + ['\22s'] = 'V·BLOCK ', + s = ' SELECT ', + S = ' S·LINE ', + ['\19'] = 'S·BLOCK ', + i = ' INSERT ', + ix = 'insert x', + ic = 'insert c', + R = 'REPLACE ', + Rc = ' Rc ', + Rx = ' Rx ', + Rv = 'V·REPLACE ', + Rvc = ' Rv ', + Rvx = ' Rv ', + c = 'COMMAND ', + cv = ' VIM EX ', + ce = ' EX ', + r = ' PROMPT ', + rm = ' MORE ', + ['r?'] = 'CONFIRM ', + ['!'] = ' SHELL ', + t = 'TERMINAL', }, }, provider = function(self) - return " %2(" .. self.mode_names[self.mode] .. "%) " + return ' %2(' .. self.mode_names[self.mode] .. '%) ' + end, + hl = function(self) + return { fg = 'darkgray', bg = self.mode_color, bold = true } end, - hl = function(self) return { fg = "darkgray", bg = self.mode_color, bold = true } end, update = { - "ModeChanged", + 'ModeChanged', }, } -- LSP local LSPActive = { condition = conditions.lsp_attached, - update = { "LspAttach", "LspDetach" }, + update = { 'LspAttach', 'LspDetach' }, provider = function() local buf_clients = vim.lsp.buf_get_clients() local buf_client_names = {} -- add client for _, client in pairs(buf_clients) do - if client.name ~= "null-ls" then + if client.name ~= 'null-ls' then table.insert(buf_client_names, client.name) end end - return "⚙️ " .. table.concat(buf_client_names, "") + return '⚙️ ' .. table.concat(buf_client_names, '') end, hl = { fg = colors.lightgray, bold = false }, } local Navic = { - condition = function() return require("nvim-navic").is_available() end, + condition = function() + return require('nvim-navic').is_available() + end, static = { -- create a type highlight map type_hl = { - File = "Directory", - Module = "@include", - Namespace = "@namespace", - Package = "@include", - Class = "@structure", - Method = "@method", - Property = "@property", - Field = "@field", - Constructor = "@constructor", - Enum = "@field", - Interface = "@type", - Function = "@function", - Variable = "@variable", - Constant = "@constant", - String = "@string", - Number = "@number", - Boolean = "@boolean", - Array = "@field", - Object = "@type", - Key = "@keyword", - Null = "@comment", - EnumMember = "@field", - Struct = "@structure", - Event = "@keyword", - Operator = "@operator", - TypeParameter = "@type", + File = 'Directory', + Module = '@include', + Namespace = '@namespace', + Package = '@include', + Class = '@structure', + Method = '@method', + Property = '@property', + Field = '@field', + Constructor = '@constructor', + Enum = '@field', + Interface = '@type', + Function = '@function', + Variable = '@variable', + Constant = '@constant', + String = '@string', + Number = '@number', + Boolean = '@boolean', + Array = '@field', + Object = '@type', + Key = '@keyword', + Null = '@comment', + EnumMember = '@field', + Struct = '@structure', + Event = '@keyword', + Operator = '@operator', + TypeParameter = '@type', }, -- bit operation dark magic, see below... enc = function(line, col, winnr) @@ -155,10 +159,10 @@ local Navic = { local col = bit.band(bit.rshift(c, 6), 1023) local winnr = bit.band(c, 63) return line, col, winnr - end + end, }, init = function(self) - local data = require("nvim-navic").get_data() or {} + local data = require('nvim-navic').get_data() or {} local children = {} -- create a child for each level for i, d in ipairs(data) do @@ -171,7 +175,7 @@ local Navic = { }, { -- escape `%`s (elixir) and buggy default separators - provider = d.name:gsub("%%", "%%%%"):gsub("%s*->%s*", ''), + provider = d.name:gsub('%%', '%%%%'):gsub('%s*->%s*', ''), -- highlight icon only or location name as well -- hl = self.type_hl[d.type], @@ -183,14 +187,14 @@ local Navic = { local line, col, winnr = self.dec(minwid) vim.api.nvim_win_set_cursor(vim.fn.win_getid(winnr), { line, col }) end, - name = "heirline_navic", + name = 'heirline_navic', }, }, } -- add a separator only if needed if #data > 1 and i < #data then table.insert(child, { - provider = " > ", + provider = ' > ', hl = { fg = 'bright_fg' }, }) end @@ -203,18 +207,18 @@ local Navic = { provider = function(self) return self.child:eval() end, - hl = { fg = "gray" }, - update = 'CursorMoved' + hl = { fg = 'gray' }, + update = 'CursorMoved', } -- Diagnostics local Diagnostics = { condition = conditions.has_diagnostics, static = { - error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text, - warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text, - info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text, - hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text, + error_icon = vim.fn.sign_getdefined('DiagnosticSignError')[1].text, + warn_icon = vim.fn.sign_getdefined('DiagnosticSignWarn')[1].text, + info_icon = vim.fn.sign_getdefined('DiagnosticSignInfo')[1].text, + hint_icon = vim.fn.sign_getdefined('DiagnosticSignHint')[1].text, }, init = function(self) self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) @@ -222,23 +226,23 @@ local Diagnostics = { self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }) self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }) end, - update = { "DiagnosticChanged", "BufEnter" }, + update = { 'DiagnosticChanged', 'BufEnter' }, { provider = function(self) -- 0 is just another output, we can decide to print it or not! - return self.errors > 0 and (self.error_icon .. self.errors .. " ") + return self.errors > 0 and (self.error_icon .. self.errors .. ' ') end, hl = { fg = colors.diag.error, bg = colors.bg }, }, { provider = function(self) - return self.warnings > 0 and (self.warn_icon .. self.warnings .. " ") + return self.warnings > 0 and (self.warn_icon .. self.warnings .. ' ') end, hl = { fg = colors.diag.warn, bg = colors.bg }, }, { provider = function(self) - return self.info > 0 and (self.info_icon .. self.info .. " ") + return self.info > 0 and (self.info_icon .. self.info .. ' ') end, hl = { fg = colors.diag.info, bg = colors.bg }, }, @@ -250,11 +254,11 @@ local Diagnostics = { }, on_click = { callback = function() - require("trouble").toggle({ mode = "document_diagnostics" }) + require('trouble').toggle({ mode = 'document_diagnostics' }) -- or -- vim.diagnostic.setqflist() end, - name = "heirline_diagnostics", + name = 'heirline_diagnostics', }, } @@ -271,7 +275,7 @@ local Git = { { -- git branch name provider = function(self) - return " " .. self.status_dict.head + return ' ' .. self.status_dict.head end, --hl = { bold = true }, hl = { bold = true, bg = colors.bg }, @@ -282,13 +286,13 @@ local Git = { return self.has_changes end, --provider = "(" - provider = " ", + provider = ' ', }, { provider = function(self) local count = self.status_dict.added or 0 --return count > 0 and ("+" .. count) - return count > 0 and ("  " .. count) + return count > 0 and ('  ' .. count) end, --hl = { fg = "git_add" }, hl = { fg = colors.git.add, bg = colors.bg }, @@ -297,7 +301,7 @@ local Git = { provider = function(self) local count = self.status_dict.removed or 0 --return count > 0 and ("-" .. count) - return count > 0 and ("  " .. count) + return count > 0 and ('  ' .. count) end, --hl = { fg = "git_del" }, hl = { fg = colors.git.del, bg = colors.bg }, @@ -306,7 +310,7 @@ local Git = { provider = function(self) local count = self.status_dict.changed or 0 --return count > 0 and ("~" .. count) - return count > 0 and (" 柳" .. count) + return count > 0 and (' 柳' .. count) end, --hl = { fg = "git_change" }, hl = { fg = colors.git.change, bg = colors.bg }, @@ -327,10 +331,10 @@ local Git = { -- opening of a floating window -- (this also applies to telescope) vim.defer_fn(function() - vim.cmd("Lazygit") + vim.cmd('Lazygit') end, 100) end, - name = "heirline_git", + name = 'heirline_git', }, } @@ -455,12 +459,11 @@ local FileNameBlock = { local FileIcon = { init = function(self) local filename = self.filename - local extension = vim.fn.fnamemodify(filename, ":e") - self.icon, self.icon_color = - require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) + local extension = vim.fn.fnamemodify(filename, ':e') + self.icon, self.icon_color = require('nvim-web-devicons').get_icon_color(filename, extension, { default = true }) end, provider = function(self) - return self.icon and (self.icon .. " ") + return self.icon and (self.icon .. ' ') end, hl = function(self) return { fg = self.icon_color, bg = colors.bg } @@ -471,9 +474,9 @@ local FileName = { provider = function(self) -- first, trim the pattern relative to the current directory. For other -- options, see :h filename-modifers - local filename = vim.fn.fnamemodify(self.filename, ":.") - if filename == "" then - return "No Name" + local filename = vim.fn.fnamemodify(self.filename, ':.') + if filename == '' then + return 'No Name' end -- now, if the filename would occupy more than 1/4th of the available -- space, we trim the file path to its initials @@ -491,7 +494,7 @@ local FileFlags = { { provider = function() if vim.bo.modified then - return " [+]" -- ±[+] + return ' [+]' -- ±[+] end end, hl = { fg = colors.green, bg = colors.bg }, @@ -499,7 +502,7 @@ local FileFlags = { { provider = function() if not vim.bo.modifiable or vim.bo.readonly then - return " " + return ' ' end end, --hl = { fg = colors.orange }, @@ -526,7 +529,7 @@ local FileType = { local FileEncoding = { Space, provider = function() - local enc = (vim.bo.fenc ~= "" and vim.bo.fenc) or vim.o.enc -- :h 'enc' + local enc = (vim.bo.fenc ~= '' and vim.bo.fenc) or vim.o.enc -- :h 'enc' return enc:lower() end, --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, @@ -537,34 +540,34 @@ local FileFormat = { provider = function() local fmt = vim.bo.fileformat --return fmt ~= "unix" and fmt:upper() - return fmt ~= "unix" and fmt:lower() + return fmt ~= 'unix' and fmt:lower() end, - hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, } -- FileSize and FileLastModified local FileSize = { provider = function() -- stackoverflow, compute human readable file size - local suffix = { "b", "k", "M", "G", "T", "P", "E" } + local suffix = { 'b', 'k', 'M', 'G', 'T', 'P', 'E' } local fsize = vim.fn.getfsize(vim.api.nvim_buf_get_name(0)) fsize = (fsize < 0 and 0) or fsize if fsize < 1024 then return fsize .. suffix[1] end local i = math.floor((math.log(fsize) / math.log(1024))) - return string.format("%.2g%s", fsize / math.pow(1024, i), suffix[i + 1]) + return string.format('%.2g%s', fsize / math.pow(1024, i), suffix[i + 1]) end, - hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, } local FileLastModified = { -- did you know? Vim is full of functions! provider = function() local ftime = vim.fn.getftime(vim.api.nvim_buf_get_name(0)) - return (ftime > 0) and os.date("%c", ftime) + return (ftime > 0) and os.date('%c', ftime) end, - hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, } -- Spell @@ -573,17 +576,17 @@ local Spell = { condition = function() return vim.wo.spell end, - provider = " 暈", + provider = ' 暈', hl = { bold = true, fg = colors.yellow }, } local HelpFileName = { condition = function() - return vim.bo.filetype == "help" + return vim.bo.filetype == 'help' end, provider = function() local filename = vim.api.nvim_buf_get_name(0) - return vim.fn.fnamemodify(filename, ":t") + return vim.fn.fnamemodify(filename, ':t') end, hl = { fg = colors.blue }, } @@ -600,37 +603,37 @@ local SearchCount = { end, provider = function(self) local search = self.search - return string.format("[%d/%d]", search.current, math.min(search.total, search.maxcount)) + return string.format('[%d/%d]', search.current, math.min(search.total, search.maxcount)) end, } local MacroRec = { condition = function() - return vim.fn.reg_recording() ~= "" and vim.o.cmdheight == 0 + return vim.fn.reg_recording() ~= '' and vim.o.cmdheight == 0 end, - provider = " ", - hl = { fg = "orange", bold = true }, - utils.surround({ "[", "]" }, nil, { + provider = ' ', + hl = { fg = 'orange', bold = true }, + utils.surround({ '[', ']' }, nil, { provider = function() return vim.fn.reg_recording() end, - hl = { fg = "green", bold = true }, + hl = { fg = 'green', bold = true }, }), update = { - "RecordingEnter", - "RecordingLeave", - } + 'RecordingEnter', + 'RecordingLeave', + }, } local ShowCmd = { condition = function() return vim.o.cmdheight == 0 end, - provider = ":%3.5(%S%)", + provider = ':%3.5(%S%)', } local cursor_location = { - { provider = " %1(%4l:%-3(%c%) %)%*", hl = { fg = colors.black, bold = true } }, + { provider = ' %1(%4l:%-3(%c%)%)%*', hl = { fg = colors.black, bold = true } }, } local Ruler = { cursor_location } @@ -655,16 +658,16 @@ local WordCount = { condition = function() return conditions.buffer_matches({ filetype = { - "markdown", - "txt", - "vimwiki", + 'markdown', + 'txt', + 'vimwiki', }, }) end, Space, { provider = function() - return "W:" .. vim.fn.wordcount().words + return 'W:' .. vim.fn.wordcount().words end, }, } @@ -672,31 +675,31 @@ local WordCount = { -- Working Directory local WorkDir = { init = function(self) - self.icon = (vim.fn.haslocaldir(0) == 1 and "l" or "g") .. " " .. " " + self.icon = (vim.fn.haslocaldir(0) == 1 and 'l' or 'g') .. ' ' .. ' ' local cwd = vim.fn.getcwd(0) - self.cwd = vim.fn.fnamemodify(cwd, ":~") + self.cwd = vim.fn.fnamemodify(cwd, ':~') end, - hl = { fg = "colors.blue", bold = true }, + hl = { fg = 'colors.blue', bold = true }, flexible = 1, { -- evaluates to the full-lenth path provider = function(self) - local trail = self.cwd:sub(-1) == "/" and "" or "/" - return self.icon .. self.cwd .. trail .. " " + local trail = self.cwd:sub(-1) == '/' and '' or '/' + return self.icon .. self.cwd .. trail .. ' ' end, }, { -- evaluates to the shortened path provider = function(self) local cwd = vim.fn.pathshorten(self.cwd) - local trail = self.cwd:sub(-1) == "/" and "" or "/" - return self.icon .. cwd .. trail .. " " + local trail = self.cwd:sub(-1) == '/' and '' or '/' + return self.icon .. cwd .. trail .. ' ' end, }, { -- evaluates to "", hiding the component - provider = "", - } + provider = '', + }, } -- Snippets Indicator @@ -720,7 +723,7 @@ FileNameBlock = utils.insert( FileIcon, utils.insert(FileNameModifier, FileName), -- a new table where FileName is a child of FileNameModifier unpack(FileFlags), -- A small optimisation, since their parent does nothing - { provider = "%<" } -- this means that the statusline is cut here when there's not enough space + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space ) local FileInfoBlock = { @@ -735,30 +738,32 @@ FileInfoBlock = utils.insert( Space, FileIcon, FileType, - { provider = "%<" } -- this means that the statusline is cut here when there's not enough space + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space ) -LeftSpace = utils.surround({ "", " " }, function(self) +LeftSpace = utils.surround({ '', '' }, function(self) return self:mode_color() -end, { LeftSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }) +end, { LeftSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) -RightSpace = utils.surround({ "", "" }, function(self) +RightSpace = utils.surround({ '', '' }, function(self) return self:mode_color() -end, { RightSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }) +end, { RightSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) -LSPActive = utils.surround({ "", "" }, function(self) +LSPActive = utils.surround({ '', '' }, function(self) return self:mode_color() end, { Space, LSPActive, hl = { bg = colors.darkgray, force = true } }) -FileInfoBlock = utils.surround({ "", "" }, function(self) +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.gray, { Ruler, hl = { fg = colors.gray, force = true } }) local left = { - { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, { LeftSpace, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, { FileNameBlock, hl = { bg = colors.nobg, force = true } }, { Space, hl = { bg = colors.nobg, force = true } }, { Git, hl = { bg = colors.nobg, force = true } }, @@ -779,14 +784,15 @@ 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, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, } local sections = { left, middle, right } local DefaultStatusline = { sections } local specialleft = { - { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, { LeftSpace, hl = { bg = colors.nobg, force = true } }, } @@ -798,7 +804,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, force = true } }, } local specialsections = { specialleft, specialmiddle, specialright } @@ -807,26 +813,26 @@ local InactiveStatusline = { condition = conditions.is_not_active, --{ FileNameBlock, hl = { bg = colors.nobg, force = true } }, --{ Align, hl = { bg = colors.nobg, force = true } }, - specialsections + specialsections, } local SpecialStatusline = { condition = function() return conditions.buffer_matches({ - buftype = { "nofile", "prompt", "help", "quickfix" }, - filetype = { "^git.*", "fugitive", "dashboard", }, + buftype = { 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { '^git.*', 'fugitive', 'dashboard' }, }) end, - specialsections + specialsections, } --local InactiveStatusline = SpecialStatusline local TerminalStatusline = { condition = function() - return conditions.buffer_matches({ buftype = { "terminal" } }) + return conditions.buffer_matches({ buftype = { 'terminal' } }) end, - specialsections + specialsections, } local StatusLine = { @@ -851,7 +857,7 @@ local StatusLine = { no = colors.blue, nov = colors.blue, noV = colors.blue, - ["no\22"] = colors.blue, + ['no\22'] = colors.blue, niI = colors.blue, niR = colors.blue, niV = colors.blue, @@ -859,11 +865,11 @@ local StatusLine = { v = colors.purple, vs = colors.purple, V = colors.purple, - ["\22"] = colors.purple, - ["\22s"] = colors.purple, + ['\22'] = colors.purple, + ['\22s'] = colors.purple, s = colors.purple, S = colors.purple, - ["\19"] = colors.purple, + ['\19'] = colors.purple, i = colors.green, ix = colors.green, ic = colors.green, @@ -878,12 +884,12 @@ local StatusLine = { ce = colors.orange, r = colors.red, rm = colors.red, - ["r?"] = colors.red, - ["!"] = colors.orange, + ['r?'] = colors.red, + ['!'] = colors.orange, t = colors.orange, }, mode_color = function(self) - local mode = conditions.is_active() and vim.fn.mode() or "n" + local mode = conditions.is_active() and vim.fn.mode() or 'n' return self.mode_colors[mode] end, hl = function(self) @@ -898,7 +904,6 @@ local StatusLine = { DefaultStatusline, } - -- --- WinBar -- @@ -914,9 +919,9 @@ local WinbarFileName = { provider = function(self) -- first, trim the pattern relative to the current directory. For other -- options, see :h filename-modifers - local filename = vim.fn.fnamemodify(self.filename, ":.") - if filename == "" then - return "No Name" + local filename = vim.fn.fnamemodify(self.filename, ':.') + if filename == '' then + return 'No Name' end -- now, if the filename would occupy more than 1/4th of the available -- space, we trim the file path to its initials @@ -935,15 +940,15 @@ WinbarFileNameBlock = utils.insert( FileIcon, utils.insert(WinbarFileName), -- a new table where FileName is a child of FileNameModifier unpack(FileFlags), -- A small optimisation, since their parent does nothing - { provider = "%<" } -- this means that the statusline is cut here when there's not enough space + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space ) -vim.api.nvim_create_autocmd("User", { - pattern = "HeirlineInitWinbar", +vim.api.nvim_create_autocmd('User', { + pattern = 'HeirlineInitWinbar', callback = function(args) local buf = args.buf - local buftype = vim.tbl_contains({ "prompt", "nofile", "help", "quickfix" }, vim.bo[buf].buftype) - local filetype = vim.tbl_contains({ "gitcommit", "fugitive" }, vim.bo[buf].filetype) + local buftype = vim.tbl_contains({ 'prompt', 'nofile', 'help', 'quickfix' }, vim.bo[buf].buftype) + local filetype = vim.tbl_contains({ 'gitcommit', 'fugitive' }, vim.bo[buf].filetype) if buftype or filetype then vim.opt_local.winbar = nil end @@ -970,11 +975,11 @@ local CloseButton = { end, -- a small performance improvement: -- re register the component callback only on layout/buffer changes. - update = { "WinNew", "WinClosed", "BufEnter" }, - { provider = " " }, + update = { 'WinNew', 'WinClosed', 'BufEnter' }, + { provider = ' ' }, { - provider = "", - hl = { fg = "gray" }, + provider = '', + hl = { fg = 'gray' }, On_click = { minwid = function() return vim.api.nvim_get_current_win() @@ -982,7 +987,7 @@ local CloseButton = { callback = function(_, minwid) vim.api.nvim_win_close(minwid, true) end, - name = "heirline_winbar_close_button", + name = 'heirline_winbar_close_button', }, }, } @@ -993,8 +998,8 @@ local Center = { -- Hide the winbar for special buffers condition = function() return conditions.buffer_matches({ - buftype = { "terminal", "nofile", "prompt", "help", "quickfix" }, - filetype = { "dap-ui", "NvimTree", "^git.*", "fugitive", "dashboard", }, + buftype = { 'terminal', 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { 'dap-ui', 'NvimTree', '^git.*', 'fugitive', 'dashboard' }, }) end, init = function() @@ -1004,7 +1009,7 @@ local Center = { { -- A special winbar for terminals condition = function() - return conditions.buffer_matches({ buftype = { "terminal" } }) + return conditions.buffer_matches({ buftype = { 'terminal' } }) end, FileType, Space, @@ -1016,16 +1021,15 @@ local Center = { return not conditions.is_active() end, --utils.surround({ "", "" }, colors.nobg, { FileIcon, { WinbarFileName, hl = { fg = colors.gray } }, FileFlags } ), - utils.surround({ "", "" }, colors.nobg, { WinbarFileNameBlock }), + utils.surround({ '', '' }, colors.nobg, { WinbarFileNameBlock }), }, -- A winbar for regular files - utils.surround({ "", "" }, colors.nobg, { FileNameBlock }), + utils.surround({ '', '' }, colors.nobg, { FileNameBlock }), } --local WinBar = { Align, Center, Align } local WinBar = { Space, Center } - -- TabLine --local TablineBufnr = { -- provider = function(self) @@ -1040,7 +1044,7 @@ local TablineFileName = { provider = function(self) -- self.filename will be defined later, just keep looking at the example! local filename = self.filename - filename = filename == "" and "No Name" or vim.fn.fnamemodify(filename, ":t") + filename = filename == '' and 'No Name' or vim.fn.fnamemodify(filename, ':t') return filename end, hl = function(self) @@ -1052,7 +1056,7 @@ local TablineFileFlags = { { provider = function(self) if vim.bo[self.bufnr].modified then - return " [+] " + return ' [+] ' end end, hl = { fg = colors.green }, @@ -1060,22 +1064,21 @@ local TablineFileFlags = { { provider = function(self) if not vim.bo[self.bufnr].modifiable or vim.bo[self.bufnr].readonly then - return "  " + return '  ' end end, - hl = { fg = "orange" }, + hl = { fg = 'orange' }, }, } local TablineFileIcon = { init = function(self) local filename = self.filename - local extension = vim.fn.fnamemodify(filename, ":e") - self.icon, self.icon_color = - require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) + local extension = vim.fn.fnamemodify(filename, ':e') + self.icon, self.icon_color = require('nvim-web-devicons').get_icon_color(filename, extension, { default = true }) end, provider = function(self) - return self.icon and (" " .. self.icon .. " ") + return self.icon and (' ' .. self.icon .. ' ') end, hl = function(self) return { fg = self.icon_color } @@ -1089,17 +1092,17 @@ local TablineFileNameBlock = { end, hl = function(self) if self.is_active then - return "TabLineSel" + return 'TabLineSel' -- why not? --elseif not vim.api.nvim_buf_is_loaded(self.bufnr) then --return { fg = "gray", bg = colors.bg } else - return "TabLineFill" + return 'TabLineFill' end end, on_click = { callback = function(_, minwid, _, button) - if button == "m" then -- close on mouse middle click + if button == 'm' then -- close on mouse middle click vim.api.nvim_buf_delete(minwid, { force = false }) else vim.api.nvim_win_set_buf(0, minwid) @@ -1108,7 +1111,7 @@ local TablineFileNameBlock = { minwid = function(self) return self.bufnr end, - name = "heirline_tabline_buffer_callback", + name = 'heirline_tabline_buffer_callback', }, --TablineBufnr, TablineFileIcon, @@ -1119,11 +1122,11 @@ local TablineFileNameBlock = { -- a nice "x" button to close the buffer local TablineCloseButton = { condition = function(self) - return not vim.api.nvim_buf_get_option(self.bufnr, "modified") + return not vim.api.nvim_buf_get_option(self.bufnr, 'modified') end, - { provider = " " }, + { provider = ' ' }, { - provider = " ", + provider = ' ', --hl = { fg = "red", bg = colors.bg }, hl = { fg = colors.red }, on_click = { @@ -1133,43 +1136,43 @@ local TablineCloseButton = { minwid = function(self) return self.bufnr end, - name = "heirline_tabline_close_buffer_callback", + name = 'heirline_tabline_close_buffer_callback', }, }, } -- The final touch! -local TablineBufferBlock = utils.surround({ "", "" }, function(self) +local TablineBufferBlock = utils.surround({ '', '' }, function(self) --local TablineBufferBlock = utils.surround({ "█", "█" }, function(self) if self.is_active then - return utils.get_highlight("TabLineSel").bg + return utils.get_highlight('TabLineSel').bg else - return utils.get_highlight("TabLineFill").bg + return utils.get_highlight('TabLineFill').bg end end, { Tab, TablineFileNameBlock, TablineCloseButton }) local BufferLine = utils.make_buflist( TablineBufferBlock, - { provider = "􀰎 ", hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<") - { provider = " 􀰓", hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">") + { provider = '􀰎 ', hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<") + { provider = ' 􀰓', hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">") -- by the way, open a lot of buffers and try clicking them ;) ) -- TabList local Tabpage = { provider = function(self) - return "%" .. self.tabnr .. "T " .. self.tabnr .. " %T" + return '%' .. self.tabnr .. 'T ' .. self.tabnr .. ' %T' end, hl = function(self) if not self.is_active then - return "TabLineFill" + return 'TabLineFill' else - return "TabLineSel" + return 'TabLineSel' end end, } local TabpageClose = { - provider = "%999X  %X", + provider = '%999X  %X', --hl = "TabLine", hl = { fg = colors.red, bg = colors.bg }, } @@ -1180,7 +1183,7 @@ local TabPages = { return #vim.api.nvim_list_tabpages() >= 2 end, { - provider = "%=", + provider = '%=', }, utils.make_tablist(Tabpage), TabpageClose, @@ -1193,8 +1196,8 @@ local TabLineOffset = { local bufnr = vim.api.nvim_win_get_buf(win) self.winid = win - if vim.api.nvim_buf_get_option(bufnr, "filetype") == "NvimTree" then - self.title = "NvimTree" + if vim.api.nvim_buf_get_option(bufnr, 'filetype') == 'NvimTree' then + self.title = 'NvimTree' return true end end, @@ -1202,13 +1205,13 @@ local TabLineOffset = { local title = self.title local width = vim.api.nvim_win_get_width(self.winid) local pad = math.ceil((width - #title) / 2) - return string.rep(" ", pad) .. title .. string.rep(" ", pad) + return string.rep(' ', pad) .. title .. string.rep(' ', pad) end, hl = function(self) if vim.api.nvim_get_current_win() == self.winid then - return "TablineSel" + return 'TablineSel' else - return "TablineFill" + return 'TablineFill' end end, } @@ -1219,7 +1222,7 @@ local TabLine = { TabPages, } -require("heirline").setup({ +require('heirline').setup({ statusline = StatusLine, winbar = WinBar, tabline = TabLine, @@ -1245,7 +1248,7 @@ local function goto_buf(index) end local function addKey(key, index) - vim.keymap.set("", "", function() + vim.keymap.set('', '', function() goto_buf(index) end, { noremap = true, silent = true }) end @@ -1253,4 +1256,4 @@ end for i = 1, 9 do addKey(i, i) end -addKey("0", 10) +addKey('0', 10) -- cgit v1.2.3 From 79b6fa6f553a9f2d52f05dd73e70f2089758bdeb Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 23 Aug 2023 16:28:56 +0200 Subject: Changed TablineBufferBlock providers --- 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 786f5cb..9066adf 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -1153,8 +1153,8 @@ end, { Tab, TablineFileNameBlock, TablineCloseButton }) local BufferLine = utils.make_buflist( TablineBufferBlock, - { provider = '􀰎 ', hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<") - { provider = ' 􀰓', hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">") + { provider = ' ', hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<") + { provider = ' ', hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">") -- by the way, open a lot of buffers and try clicking them ;) ) -- TabList -- cgit v1.2.3 From e80d83d242ff4e80842d38482a32dec96c31a61f Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 23 Aug 2023 16:32:52 +0200 Subject: Add (Left/Right)Space to left and right special (DefaultStatusline) sections --- lua/plugins/heirline.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 9066adf..f8ae814 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -792,8 +792,9 @@ local sections = { left, middle, right } local DefaultStatusline = { sections } local specialleft = { - { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, - { LeftSpace, hl = { bg = colors.nobg, force = true } }, + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, } local specialmiddle = { @@ -805,6 +806,7 @@ local specialmiddle = { local specialright = { { RightSpace, hl = { bg = colors.nobg, force = true } }, { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, } local specialsections = { specialleft, specialmiddle, specialright } -- cgit v1.2.3 From f26108bc10a22fef7cc622b835aaf3ac6c63ea56 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 26 Aug 2023 23:48:35 +0200 Subject: Removed mapping 'kj' --- lua/user/keys.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 00dc3fd..5bf3ee9 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -12,7 +12,6 @@ vim.g.mapleader = ';' -- "jk" and "kj" to exit insert-mode map('i', 'jk', '') -map('i', 'kj', '') -- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" --map("n", ".", ";") -- cgit v1.2.3 From 0369fc247997f6e123f17ccc1308e0d5ab969495 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 26 Aug 2023 23:48:53 +0200 Subject: Allow .editorconfig to work better/faster --- lua/user/opts.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index f8cb064..0b3f32b 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -244,6 +244,8 @@ vim.g.netrw_winsize = 25 --vim.cmd([[ -- "filetype plugin indent on --]]) +vim.cmd('filetype plugin on') +vim.cmd('filetype indent off') -- Let clipboard register be + vim.cmd([[ -- cgit v1.2.3 From a41e5da5f9fbd91b5e803797751aabae68aa47a9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 26 Aug 2023 23:49:31 +0200 Subject: Cmd 'Mkdir' enabled from 'tpope/vim-eunuch' --- lua/user/pack.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index cc57085..d0c430a 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -165,7 +165,7 @@ return packer.startup(function(use) require('Navigator').setup() end, }) - use({ 'tpope/vim-eunuch', cmd = { 'Rename', 'Delete' } }) -- Handy unix commands inside Vim (Rename, Move etc.) + use({ 'tpope/vim-eunuch', cmd = { 'Rename', 'Delete', 'Mkdir' } }) -- Handy unix commands inside Vim (Rename, Move etc.) --use("tpope/vim-surround") -- --use("tpope/vim-obsession") -- use('tpope/vim-unimpaired') -- -- cgit v1.2.3 From f52ce320e1c56d80dabaf9f4c7faba11e9f84818 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 26 Aug 2023 23:50:07 +0200 Subject: Fixed Ruler and nvim-tree colors --- lua/plugins/heirline.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index f8ae814..2672b9d 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -633,7 +633,7 @@ local ShowCmd = { } local cursor_location = { - { provider = ' %1(%4l:%-3(%c%)%)%*', hl = { fg = colors.black, bold = true } }, + { provider = '%1(%4l:%-3(%c%)%) %*', hl = { fg = colors.black, bold = true } }, } local Ruler = { cursor_location } @@ -1209,13 +1209,15 @@ local TabLineOffset = { local pad = math.ceil((width - #title) / 2) return string.rep(' ', pad) .. title .. string.rep(' ', pad) end, - hl = function(self) - if vim.api.nvim_get_current_win() == self.winid then - return 'TablineSel' - else - return 'TablineFill' - end - end, + hl = { fg = colors.white, bold = false }, + + --hl = function(self) + -- if vim.api.nvim_get_current_win() == self.winid then + -- return 'TablineSel' + -- else + -- return 'TablineFill' + -- end + --end, } local TabLine = { -- cgit v1.2.3 From 233903da6ffa8faa74f826f55e46124cba7f6ae2 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 27 Aug 2023 15:57:36 +0200 Subject: Update todos completed --- README.md | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index a841b13..2849262 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,33 @@ ## Neovim + #### Dependencies + nvm nvm install --lts - #### TODOS: -- [ ] Markdown filetype plugin or autocommand to add two spaces each line -- [ ] Markdown filetype plugin or autocommand to make backtick auto-correct properly -- [ ] Indent by filetype/fix global indent (2) -- [ ] Check history or telescope history of last files edited or opened. -- [ ] * Windows native support configuration -- [ ] * Python debugger -- [ ] README file heirachcy -- [ ] Markdown snippet for code blocks with list, ie.- `` and - ``` ``` -- [ ] Snippet for filler text with variations, ie. common sentences: The quick brown fox... and more and placeholder words -- [ ] Configure snippets.lua -- [ ] Documentation shortcuts for different languages quote in quote "locally" (preffered) or opening web browser -- [ ] Dictionary, an actual dictionary -- [ ] Null-ls/lsp keymap to check current buffer servers must check both same time -> NOTE: Different servers must be configured only to one or another, research null-ls being archived -- [ ] Don't highlight whitespaces in lazygit (maybe exclusively markdown) -- [ ] Configure prettier/prettierd servers to join a lot of different files (null-ls) -- [ ] Nvim-tree preview window similar to telescope -- [ ] Nvim-tree behaviour when delete current buffer -> NOTE: One idea is to create an autocmd to make a blank window (hidden) as a secondary window but when creating a opening a new file it does not ask which split to open in -- [ ] Nvim-tree conditionally when open going in the opposite direction will go back to nvim-tree ie. going right then goes to nvim-tree but is conditionally because of tmux etc... -- [x] Substitute keybinding -- [ ] Snippet/filetype plugin for markdown tick boxes -- [ ] Delete lua/user/func.lua -- [ ] Clean entire config by prioritizing single quotation marks over double -- [ ] + +- [ ] Markdown filetype plugin or autocommand to add two spaces each line +- [ ] Markdown filetype plugin or autocommand to make backtick auto-correct properly +- [x] Indent by filetype/fix global indent (2) +- [x] Check history or telescope history of last files edited or opened. +- [ ] - Windows native support configuration +- [ ] - Python debugger +- [ ] README file heirachcy +- [ ] Markdown snippet for code blocks with list, ie.- ``and -` ` +- [ ] Snippet for filler text with variations, ie. common sentences: The quick brown fox... and more and placeholder words +- [ ] Configure snippets.lua +- [ ] Documentation shortcuts for different languages quote in quote "locally" (preffered) or opening web browser +- [ ] Dictionary, an actual dictionary +- [ ] Null-ls/lsp keymap to check current buffer servers must check both same time + > NOTE: Different servers must be configured only to one or another, research null-ls being archived +- [ ] Don't highlight whitespaces in lazygit (maybe exclusively markdown) +- [ ] Configure prettier/prettierd servers to join a lot of different files (null-ls) +- [ ] Nvim-tree preview window similar to telescope +- [x] Nvim-tree behaviour when delete current buffer + > NOTE: One idea is to create an autocmd to make a blank window (hidden) as a secondary window but when creating a opening a new file it does not ask which split to open in +- [ ] Nvim-tree conditionally when open going in the opposite direction will go back to nvim-tree ie. going right then goes to nvim-tree but is conditionally because of tmux etc... +- [x] Substitute keybinding +- [ ] Snippet/filetype plugin for markdown tick boxes +- [ ] Delete lua/user/func.lua +- [ ] Clean entire config by prioritizing single quotation marks over double -- cgit v1.2.3 From 6ffbb45c2aa0de9ed304b5d767510502dc245e64 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 27 Aug 2023 16:02:00 +0200 Subject: Changed git signs colors --- 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 2672b9d..eeedb5b 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -271,14 +271,14 @@ local Git = { self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0 end, --hl = { fg = "orange" }, - hl = { fg = colors.orange, bg = colors.bg }, + --hl = { fg = colors.orange, bg = colors.bg }, { -- git branch name provider = function(self) return ' ' .. self.status_dict.head end, --hl = { bold = true }, - hl = { bold = true, bg = colors.bg }, + hl = { fg = colors.orange, bold = true, bg = colors.bg }, }, -- You could handle delimiters, icons and counts similar to Diagnostics { -- cgit v1.2.3 From a94b5a37881b3fa304a3098b8275751325584714 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 27 Aug 2023 16:03:38 +0200 Subject: Changed git signs 'add' and 'del' colors --- 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 eeedb5b..f35f787 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -26,8 +26,8 @@ local colors = { info = utils.get_highlight('DiagnosticSignInfo').fg, }, git = { - del = '#e95678', - add = '#a6e22e', + del = '#ff5555', + add = '#50fa7b', change = '#ae81ff', }, } -- cgit v1.2.3 From 0507c5895a770dda409112426dca6efa7fc39f1f Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 27 Aug 2023 16:31:14 +0200 Subject: Changed git sign icon for changes --- lua/plugins/heirline.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index f35f787..5b63a4d 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -310,7 +310,7 @@ local Git = { provider = function(self) local count = self.status_dict.changed or 0 --return count > 0 and ("~" .. count) - return count > 0 and (' 柳' .. count) + return count > 0 and ('  ' .. count) end, --hl = { fg = "git_change" }, hl = { fg = colors.git.change, bg = colors.bg }, -- cgit v1.2.3 From 458d56ef36a9fefbacd9307175959100021c5a74 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 27 Aug 2023 16:31:23 +0200 Subject: Clean config --- lua/plugins/nvim-tree.lua | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 906db81..774e2f0 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -265,6 +265,7 @@ vim.api.nvim_create_autocmd({ 'VimEnter' }, { callback = open_nvim_tree }) -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') + --vim.api.nvim_command("highlight NvimTreeSymlink ") --vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) --vim.api.nvim_command("highlight NvimTreeFolderName ") --(Directory) @@ -292,15 +293,9 @@ vim.api.nvim_command('highlight NvimTreeNormal guibg=none') --vim.api.nvim_command("highlight NvimTreeGitNew ") --vim.api.nvim_command("highlight NvimTreeGitDeleted ") --vim.api.nvim_command("highlight NvimTreeGitIgnored ") --(Comment) ---vim.api.nvim_command("highlight NvimTreeWindowPicker ") --vim.api.nvim_command("highlight NvimTreeNormal ") --vim.api.nvim_command("highlight NvimTreeEndOfBuffer ") --(NonText) ---vim.api.nvim_command("highlight NvimTreeCursorLine ") --(CursorLine) ---vim.api.nvim_command("highlight NvimTreeCursorLineNr ") --(CursorLineNr) ---vim.api.nvim_command("highlight NvimTreeLineNr ") --(LineNr) ---vim.api.nvim_command("highlight NvimTreeWinSeparator ") --(WinSeparator) --vim.api.nvim_command("highlight NvimTreeCursorColumn ") --(CursorColumn) - --vim.api.nvim_command("highlight NvimTreeFileDirty ") --(NvimTreeGitDirty) --vim.api.nvim_command("highlight NvimTreeFileStaged ") --(NvimTreeGitStaged) --vim.api.nvim_command("highlight NvimTreeFileMerge ") --(NvimTreeGitMerge) @@ -308,8 +303,6 @@ vim.api.nvim_command('highlight NvimTreeNormal guibg=none') --vim.api.nvim_command("highlight NvimTreeFileNew ") --(NvimTreeGitNew) --vim.api.nvim_command("highlight NvimTreeFileDeleted ") --(NvimTreeGitDeleted) --vim.api.nvim_command("highlight NvimTreeFileIgnored ") --(NvimTreeGitIgnored) - --vim.api.nvim_command("highlight NvimTreeLiveFilterPrefix ") --vim.api.nvim_command("highlight NvimTreeLiveFilterValue ") - --vim.api.nvim_command("highlight NvimTreeBookmark ") -- cgit v1.2.3 From 272ec4292aa5c4d9e019fa2aad91c5597f849b14 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 28 Aug 2023 17:26:18 +0200 Subject: Changed color for git active on current file/buffer --- lua/plugins/heirline.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 5b63a4d..06867df 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -26,6 +26,7 @@ local colors = { info = utils.get_highlight('DiagnosticSignInfo').fg, }, git = { + active = '#f34f29', del = '#ff5555', add = '#50fa7b', change = '#ae81ff', @@ -275,10 +276,11 @@ local Git = { { -- git branch name provider = function(self) - return ' ' .. self.status_dict.head + --return ' ' .. self.status_dict.head + return '  ' .. self.status_dict.head end, --hl = { bold = true }, - hl = { fg = colors.orange, bold = true, bg = colors.bg }, + hl = { fg = colors.git.active, bold = true, bg = colors.bg }, }, -- You could handle delimiters, icons and counts similar to Diagnostics { @@ -286,7 +288,7 @@ local Git = { return self.has_changes end, --provider = "(" - provider = ' ', + provider = '', }, { provider = function(self) -- cgit v1.2.3 From 12dea167448ada8826da2e7ae4c159bf32a9bff4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 28 Aug 2023 17:42:26 +0200 Subject: Changed git branch color to white --- lua/plugins/heirline.lua | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 06867df..1951617 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -271,18 +271,32 @@ local Git = { self.status_dict = vim.b.gitsigns_status_dict self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0 end, - --hl = { fg = "orange" }, - --hl = { fg = colors.orange, bg = colors.bg }, + --{ + -- -- git branch name + -- provider = function(self) + -- --return ' ' .. self.status_dict.head + -- return '  ' .. self.status_dict.head + -- end, + -- --hl = { bold = true }, + -- hl = { fg = colors.git.active, bold = true, bg = colors.bg }, + --}, + -- You could handle delimiters, icons and counts similar to Diagnostics + { + -- git branch icon + provider = function() + return '  ' + end, + hl = { fg = colors.git.active, bg = colors.bg }, + }, + { -- git branch name provider = function(self) - --return ' ' .. self.status_dict.head - return '  ' .. self.status_dict.head + return self.status_dict.head end, - --hl = { bold = true }, - hl = { fg = colors.git.active, bold = true, bg = colors.bg }, + hl = { fg = colors.white, bg = colors.bg }, }, - -- You could handle delimiters, icons and counts similar to Diagnostics + { condition = function(self) return self.has_changes -- cgit v1.2.3 From 894054943024206c82dfc29b8c4011799adca5dd Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 28 Aug 2023 21:40:15 +0200 Subject: Install 'michaelb/sniprun' --- lua/user/pack.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index d0c430a..fc5fb4a 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -209,7 +209,7 @@ return packer.startup(function(use) --vim.cmd("let g:rooter_change_directory_for_non_project_files = ''"), --vim.cmd("let g:rooter_change_directory_for_non_project_files = 'current'") }) - + use({ 'michaelb/sniprun', run = 'bash ./install.sh' }) --use("vim-test/vim-test") -- --use({ -- "rcarriga/vim-ultest", -- -- cgit v1.2.3 From 2a9b4c48034bcde0d7b044eedb302a3d92da75f6 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 28 Aug 2023 21:40:55 +0200 Subject: Moved 'Search and replace' binding closer to 'substitute' bindings --- lua/user/keys.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 5bf3ee9..67b2ece 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -135,9 +135,6 @@ map('x', '>', '>gv', term_opts) map('n', '', ':let save_a=@a"add"ap:let @a=save_a') map('n', '', ':let save_a=@a"add"ap:let @a=save_a') --- Search and replace -map('v', 'sr', 'y:%s/"//gc') - -- Toggle Diff map('n', 'td', 'call utils#ToggleDiff()') @@ -181,12 +178,15 @@ else map[''].gx = { 'lua print("Error: gx is not supported on this OS!")' } end +-- Search and replace +map('v', 'sr', 'y:%s/"//gc') + -- Substitute globally and locally in the selected region. map('n', 'ss', ':%s//g') map('v', 'ss', ':s//g') -- Toggle completion -map('n', 'tc', ":lua require('user.mods').toggle_completion()") +map('n', 'tc', ':lua require("user.mods").toggle_completion()') -- Disable default completion. map('i', '', '') @@ -413,7 +413,7 @@ end, { desc = 'DAP-Telescope: Commands' }) --end) -- Toggle Dashboard -map('n', '', "lua require('user.mods').toggle_dashboard()") +map('n', '', 'lua require("user.mods").toggle_dashboard()') -- Lsp Lines toggle map('', 'l', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) -- cgit v1.2.3 From 8e8ad70a46dd23b6b9fcf1c5a7cee2452e5a14e0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 28 Aug 2023 21:57:40 +0200 Subject: Mapping for SnipRun --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 67b2ece..12980ac 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -417,3 +417,6 @@ map('n', '', 'lua require("user.mods").toggle_dashboard()l', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) + +-- SnipRun +map({ 'n', 'v' }, 'r', 'SnipRun') -- cgit v1.2.3 From 81442a45bc45b6c008f07b7132e2c2b06319ca02 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 28 Aug 2023 21:58:14 +0200 Subject: Made nvimtree bold --- lua/plugins/heirline.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 1951617..46e0ccc 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -1225,7 +1225,7 @@ local TabLineOffset = { local pad = math.ceil((width - #title) / 2) return string.rep(' ', pad) .. title .. string.rep(' ', pad) end, - hl = { fg = colors.white, bold = false }, + hl = { fg = colors.white, bg = '#333842', bold = true }, --hl = function(self) -- if vim.api.nvim_get_current_win() == self.winid then -- cgit v1.2.3 From b9f57794aa079f47f746c7fc46c0a85a6d73198c Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:52:30 +0200 Subject: Toggle Codi.vim --- lua/user/mods.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 457ec74..92f64ed 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -594,5 +594,23 @@ end -------------------------------------------------- +-- Toggle Codi +-- Define a global variable to track Codi's state +local is_codi_open = false + +function M.toggleCodi() + if is_codi_open then + -- Close Codi + vim.cmd('Codi!') + is_codi_open = false + else + -- Open Codi + vim.cmd('Codi') + is_codi_open = true + end +end + +-------------------------------------------------- + -- ... return M -- cgit v1.2.3 From c3c6676753761987a46b30af5e73612e9c789562 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:53:16 +0200 Subject: Scratch buffer --- lua/user/mods.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 92f64ed..0b7f406 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -612,5 +612,37 @@ end -------------------------------------------------- +-- Function to create or toggle a scratch buffer +function M.Scratch() + local scratch_dir = vim.fn.expand('~') + local scratch_date = os.date('%Y-%m-%d') + local scratch_file = 'notes-' .. scratch_date .. '.md' + local scratch_buf = vim.fn.bufnr(scratch_file) + local bufinfo = vim.fn.getbufinfo(scratch_buf) + + if scratch_buf == -1 then + -- If the buffer doesn't exist, create it + vim.cmd('vsplit ' .. scratch_dir .. '/' .. scratch_file) + if vim.fn.empty(vim.fn.glob(scratch_dir .. '/' .. scratch_file)) == 1 then + vim.cmd(':normal i# Quick Notes - ' .. scratch_date) + vim.cmd(':normal o') + vim.cmd(':normal 28a-') + vim.cmd(':normal o') + vim.cmd(':w') + --vim.cmd(':startinsert') + end + elseif vim.fn.empty(bufinfo[1].windows) == 1 then + -- If the buffer exists but is not open, open it + vim.cmd('vsplit +buffer' .. scratch_buf) + else + -- If the buffer exists and is open, close it + local scratch_win = vim.fn.filter(vim.fn.getwininfo(), 'v:val.bufnr == ' .. scratch_buf)[1].winnr + vim.cmd(':w') + vim.cmd(scratch_win .. 'wincmd c') + end +end + +-------------------------------------------------- + -- ... return M -- cgit v1.2.3 From efbdad62b06b41ebfdc9978cc8b714d62b91b0e3 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:53:48 +0200 Subject: Toggle Codi.vim --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 12980ac..c2ec1ad 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -420,3 +420,6 @@ map('', 'l', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) -- SnipRun map({ 'n', 'v' }, 'r', 'SnipRun') + +-- Codi +map('n', 'co', 'lua require("user.mods").toggleCodi()') -- cgit v1.2.3 From e439229ffffc0ac6cb190cdb31ea68112e6df596 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:54:57 +0200 Subject: Scratch buffer --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c2ec1ad..53bc712 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -423,3 +423,6 @@ map({ 'n', 'v' }, 'r', 'SnipRun') -- Codi map('n', 'co', 'lua require("user.mods").toggleCodi()') + +-- Scratch buffer +map('n', 's', 'lua require("user.mods").Scratch()') -- cgit v1.2.3 From 0b01daaec5c51d37385d44ccb4ab14f60416c51f Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:55:43 +0200 Subject: Add sniprun.lua --- init.lua | 113 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/init.lua b/init.lua index 23068e5..35c7aae 100644 --- a/init.lua +++ b/init.lua @@ -44,55 +44,56 @@ --$ nvim --startuptime startup.log -c exit && tail -100 startup.log -- Load impatient (Faster loading times) -local impatient_ok, impatient = pcall(require, "impatient") +local impatient_ok, impatient = pcall(require, 'impatient') if impatient_ok then impatient.enable_profile() end -- Schedule reading shadafile to improve the startup time -vim.opt.shadafile = "NONE" +vim.opt.shadafile = 'NONE' vim.schedule(function() - vim.opt.shadafile = "" - vim.cmd("silent! rsh") + vim.opt.shadafile = '' + vim.cmd('silent! rsh') end) -- Load/reload modules local modules = { - "user.pack", -- Packer plugin manager - "user.opts", -- Options - "user.keys", -- Keymaps - "user.mods", -- Modules/functions + 'user.pack', -- Packer plugin manager + 'user.opts', -- Options + 'user.keys', -- Keymaps + 'user.mods', -- Modules/functions --"user.scripts", - "plugins.treesitter", - "plugins.neodev", - "plugins.colorscheme", - "plugins.telescope", - "plugins.nvim-tree", - "plugins.web-devicons", - "plugins.cmp", - "plugins.quickfix", + 'plugins.treesitter', + 'plugins.neodev', + 'plugins.colorscheme', + 'plugins.telescope', + 'plugins.nvim-tree', + 'plugins.web-devicons', + 'plugins.cmp', + 'plugins.quickfix', --"plugins.snippets", --"plugins.colorizer", --"plugins.prettier", --"plugins.git", - "plugins.lsp", + 'plugins.lsp', --"plugins.fugitive", - "plugins.gitsigns", - "plugins.neoscroll", - "plugins.statuscol", - "plugins.trouble", - "plugins.goto-preview", - "plugins.autopairs", - "plugins.navic", - "plugins.toggleterm", - "plugins.zen-mode", - "plugins.fidget", - "plugins.dap", - "plugins.neotest", - "plugins.heirline", - "plugins.dashboard", - "plugins.which-key", - "plugins.harpoon", + 'plugins.gitsigns', + 'plugins.sniprun', + 'plugins.neoscroll', + 'plugins.statuscol', + 'plugins.trouble', + 'plugins.goto-preview', + 'plugins.autopairs', + 'plugins.navic', + 'plugins.toggleterm', + 'plugins.zen-mode', + 'plugins.fidget', + 'plugins.dap', + 'plugins.neotest', + 'plugins.heirline', + 'plugins.dashboard', + 'plugins.which-key', + 'plugins.harpoon', --"plugins.modify-blend", } @@ -103,39 +104,39 @@ for k, v in pairs(modules) do end -- Snippets -vim.g.snippets = "luasnip" +vim.g.snippets = 'luasnip' -- Notifications -vim.notify = require("notify") -- Requires plugin "rcarriga/nvim-notify" +vim.notify = require('notify') -- Requires plugin "rcarriga/nvim-notify" -- Improve speed by disabling some default plugins/modules local builtins = { - "gzip", - "zip", - "zipPlugin", - "tar", - "tarPlugin", - "getscript", - "getscriptPlugin", - "vimball", - "vimballPlugin", - "2html_plugin", + 'gzip', + 'zip', + 'zipPlugin', + 'tar', + 'tarPlugin', + 'getscript', + 'getscriptPlugin', + 'vimball', + 'vimballPlugin', + '2html_plugin', --"matchit", --"matchparen", - "logiPat", - "rrhelper", - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - "tutor_mode_plugin", - "fzf", - "spellfile_plugin", - "sleuth", + 'logiPat', + 'rrhelper', + 'netrw', + 'netrwPlugin', + 'netrwSettings', + 'netrwFileHandlers', + 'tutor_mode_plugin', + 'fzf', + 'spellfile_plugin', + 'sleuth', } for _, plugin in ipairs(builtins) do - vim.g["loaded_" .. plugin] = 1 + vim.g['loaded_' .. plugin] = 1 end vim.g.do_filetype_lua = 1 vim.g.did_load_filetypes = 0 -- cgit v1.2.3 From 9b31540943def560bf2391630eaf307bc7ec9024 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:55:51 +0200 Subject: Add sniprun.lua --- lua/plugins/sniprun.lua | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lua/plugins/sniprun.lua diff --git a/lua/plugins/sniprun.lua b/lua/plugins/sniprun.lua new file mode 100644 index 0000000..2556c24 --- /dev/null +++ b/lua/plugins/sniprun.lua @@ -0,0 +1,57 @@ +local status_ok, sniprun = pcall(require, 'sniprun') +if not status_ok then + return +end + +sniprun.setup({ + -- selected_interpreters = {}, --# use those instead of the default for the current filetype + -- repl_enable = { "Python3_original" }, --# enable REPL-like behavior for the given interpreters + -- repl_disable = {}, --# disable REPL-like behavior for the given interpreters + + -- interpreter_options = { --# intepreter-specific options, see docs / :SnipInfo + -- GFM_original = { + -- use_on_filetypes = { "markdown.pandoc" }, --# the 'use_on_filetypes' configuration key is + -- --# available for every interpreter + -- }, + -- }, + + --# 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) + -- "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 + -- "TerminalWithCode", --# display results and code history in a vertical split + -- "NvimNotify", --# display with the nvim-notify plugin + -- "Api" --# return output to a programming interface + }, + + display_options = { + terminal_width = 45, --# change the terminal display option width + notification_timeout = 5, --# timeout for nvim_notify output + }, + + --# You can use the same keys to customize whether a sniprun producing + --# no output should display nothing or '(no output)' + show_no_output = { + 'Classic', + 'TempFloatingWindow', --# implies LongTempFloatingWindow, which has no effect on its own + }, + + --# customize highlight groups (setting this overrides colorscheme) + -- snipruncolors = { + -- SniprunVirtualTextOk = { bg = "NONE", fg = "#66eeff", ctermbg = "Black", cterfg = "Cyan" }, + -- SniprunFloatingWinOk = { fg = "NONE", ctermfg = "Cyan" }, + -- SniprunVirtualTextErr = { bg = "#881515", fg = "#000000", ctermbg = "DarkRed", cterfg = "Black" }, + -- SniprunFloatingWinErr = { fg = "#881515", ctermfg = "DarkRed" }, + -- }, + + --# miscellaneous compatibility/adjustement settings + inline_messages = 0, --# inline_message (0/1) is a one-line way to display messages + --# to workaround sniprun not being able to display anything + + borders = 'single', --# display borders around floating windows + --# possible values are 'none', 'single', 'double', or 'shadow' +}) -- cgit v1.2.3 From 962bcff7b62eb947bd2fdfe59f24e87c74cf4593 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 29 Aug 2023 10:56:23 +0200 Subject: Add metakirby5/codi.vim --- lua/user/pack.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index fc5fb4a..39941c8 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -308,7 +308,8 @@ return packer.startup(function(use) use({ 'j-hui/fidget.nvim', tag = 'legacy', - }) -- UI to show nvim-lsp progress + }) -- UI to show nvim-lsp progress + use('metakirby5/codi.vim') use({ 'simrat39/symbols-outline.nvim', -- config = function() -- cgit v1.2.3 From 582df9edfe0843ffda460d5177b4f6d4a66044f4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 10:54:58 +0200 Subject: Binding for telescope.extensions.file_browser --- lua/user/keys.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 53bc712..797c4fe 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -298,6 +298,7 @@ map('n', 'fw', [[lua require'plugins.telescope'.find_projects() map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications map('n', 'ffr', "lua require('telescope').extensions.recent_files.pick()") +map('n', 'ffb', "lua require('telescope').extensions.file_browser.file_browser()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- Map a shortcut to open the picker. -- cgit v1.2.3 From 443b582eb00d1d3e0f6887071ceff8886ab8a83b Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 10:57:44 +0200 Subject: Normal mode binding 'cd' added --- lua/plugins/telescope.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 9ed43ca..f6f7558 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -130,7 +130,13 @@ require('telescope').setup({ [''] = actions.results_scrolling_up, [''] = actions.results_scrolling_down, - + ['cd'] = function(prompt_bufnr) + local selection = require('telescope.actions.state').get_selected_entry() + local dir = vim.fn.fnamemodify(selection.path, ':p:h') + require('telescope.actions').close(prompt_bufnr) + -- Depending on what you want put `cd`, `lcd`, `tcd` + vim.cmd(string.format('silent lcd %s', dir)) + end, ['?'] = actions.which_key, --[""] = function(prompt_bufnr) -- local selection = require("telescope.actions.state").get_selected_entry() -- cgit v1.2.3 From e4b2ba38ce816aadb067d1c76561d8fe2b23394d Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 11:01:31 +0200 Subject: Fix to annoying timestamp issue on write (The file has been changed since reading it...) --- autoload/utils.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/autoload/utils.vim b/autoload/utils.vim index fc078f7..3bb83bf 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -163,4 +163,17 @@ endfu autocmd! BufNewFile,BufRead *.* call utils#DisableBr() +"------------------------------------------------- + +" Annoying timestamp issue on write (The file has been changed since reading it...) +function! utils#ProcessFileChangedShell() + if v:fcs_reason == 'mode' || v:fcs_reason == 'time' + let v:fcs_choice = '' + else + let v:fcs_choice = 'ask' + endif +endfunction +autocmd FileChangedShell call utils#ProcessFileChangedShell() + + "------------------------------------------------- -- cgit v1.2.3 From 710d7ba9394761b5cb1ccff85dc6788118d765e6 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 11:07:56 +0200 Subject: Changed substitute keybindings to 'leader-sg' --- lua/user/keys.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 797c4fe..1813f20 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -182,8 +182,8 @@ end map('v', 'sr', 'y:%s/"//gc') -- Substitute globally and locally in the selected region. -map('n', 'ss', ':%s//g') -map('v', 'ss', ':s//g') +map('n', 'sg', ':%s//g') +map('v', 'sg', ':s//g') -- Toggle completion map('n', 'tc', ':lua require("user.mods").toggle_completion()') -- cgit v1.2.3 From dfa351c9d1419a8ce2c409e06b4ed9859dc2f857 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 11:08:25 +0200 Subject: Changed session-lens.search_session to 'ss' --- lua/user/pack.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 39941c8..20af851 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -240,7 +240,7 @@ return packer.startup(function(use) config = function() require('session-lens').setup({ --[[your custom config--]] }) - vim.keymap.set('n', 's', require('session-lens').search_session) -- <-- this sets it to `Ctrl + s` + vim.keymap.set('n', 'ss', require('session-lens').search_session) -- <-- this sets it to `Ctrl + s` end, }) -- cgit v1.2.3 From ba99fce7121472affc7cd0b3ca2be38d11da4820 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:45:59 +0200 Subject: Changed mapping for substitute to 'ss' --- lua/user/keys.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 1813f20..6bc3c04 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -182,8 +182,8 @@ end map('v', 'sr', 'y:%s/"//gc') -- Substitute globally and locally in the selected region. -map('n', 'sg', ':%s//g') -map('v', 'sg', ':s//g') +map('n', 'ss', ':%s//g') +map('v', 'ss', ':s//g') -- Toggle completion map('n', 'tc', ':lua require("user.mods").toggle_completion()') @@ -284,21 +284,22 @@ map('n', 'fg', "lua require('telescope.builtin').live_grep()") map('n', 'fb', "lua require('telescope.builtin').buffers()") map('n', 'fh', "lua require('telescope.builtin').help_tags()") map('n', 'fc', "lua require('telescope.builtin').commands()") -map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'cf', 'Telescope changed_files') map('n', 'fp', 'Telescope pickers') map('n', 'fd', "lua require('telescope.builtin').diagnostics()") map('n', 'fk', "lua require('telescope.builtin').keymaps()") map('n', 'fr', "lua require('telescope.builtin').registers({})") -- registers picker -map('n', 'fn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes -map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files +map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications map('n', 'f.', [[lua require'plugins.telescope'.find_configs()]]) -- find configs map('n', 'fs', [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts map('n', 'fw', [[lua require'plugins.telescope'.find_projects()]]) -- find projects -map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files -map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications +map('n', 'fn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'ffr', "lua require('telescope').extensions.recent_files.pick()") map('n', 'ffb', "lua require('telescope').extensions.file_browser.file_browser()") +map('n', 'ffs', 'lua require("session-lens").search_session()') --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- Map a shortcut to open the picker. -- cgit v1.2.3 From 358bba51fe623b52a8522aeff32e6c11a62b7e8f Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:51:37 +0200 Subject: Moved configuration for sessions to session.lua --- lua/user/pack.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 20af851..95faf05 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -156,6 +156,8 @@ return packer.startup(function(use) use('nvim-telescope/telescope-dap.nvim') use('axkirillov/telescope-changed-files') -- use('smartpde/telescope-recent-files') + use('rmagatti/auto-session') + use('rmagatti/session-lens') -- UX use('folke/neodev.nvim') @@ -234,15 +236,6 @@ return packer.startup(function(use) }, }, }) - use({ - 'rmagatti/session-lens', - requires = { 'rmagatti/auto-session', 'nvim-telescope/telescope.nvim' }, - config = function() - require('session-lens').setup({ --[[your custom config--]] - }) - vim.keymap.set('n', 'ss', require('session-lens').search_session) -- <-- this sets it to `Ctrl + s` - end, - }) -- Colorschemes use('bluz71/vim-nightfly-guicolors') -- cgit v1.2.3 From 8e40e9f1a31de6cafea695c27f8c56f160417b49 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:51:45 +0200 Subject: Add session.lua --- lua/plugins/session.lua | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lua/plugins/session.lua diff --git a/lua/plugins/session.lua b/lua/plugins/session.lua new file mode 100644 index 0000000..0c84625 --- /dev/null +++ b/lua/plugins/session.lua @@ -0,0 +1,5 @@ +require('auto-session').setup({ + log_level = 'error', + auto_session_suppress_dirs = { '~/', '~/projects', '~/downloads', '/' }, +}) +require('session-lens').setup({}) -- cgit v1.2.3 From ce8be9d6aefbab3af340e1f2192a54d83ead6543 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:51:54 +0200 Subject: Add session.lua --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 35c7aae..1184200 100644 --- a/init.lua +++ b/init.lua @@ -79,6 +79,7 @@ local modules = { --"plugins.fugitive", 'plugins.gitsigns', 'plugins.sniprun', + 'plugins.session', 'plugins.neoscroll', 'plugins.statuscol', 'plugins.trouble', -- cgit v1.2.3 From 1571ea0736954c250c2f15d4819b2fead626b121 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:52:18 +0200 Subject: Changed colorscheme to 'nightfly' --- lua/plugins/colorscheme.lua | 49 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 14edbdf..2e04581 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -3,15 +3,15 @@ -- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] -- Define default color scheme -local default_colorscheme = "tokyonight-night" -local fallback_colorscheme = "desert" +local default_colorscheme = 'nightfly' +local fallback_colorscheme = 'desert' -- Attempt to set the default color scheme -local status_ok, _ = pcall(vim.cmd, "colorscheme " .. default_colorscheme) +local status_ok, _ = pcall(vim.cmd, 'colorscheme ' .. default_colorscheme) -- If the default color scheme is not found, use the fallback color scheme if not status_ok then - vim.cmd("colorscheme " .. fallback_colorscheme) + vim.cmd('colorscheme ' .. fallback_colorscheme) end --local function MyHighlights() @@ -30,20 +30,19 @@ end -- --setupMyColors() - -vim.api.nvim_command("syntax on") -vim.api.nvim_command("highlight Normal guibg=NONE") -vim.api.nvim_command("highlight NormalNC guibg=none") -vim.api.nvim_command("highlight SignColumn guibg=none") +vim.api.nvim_command('syntax on') +vim.api.nvim_command('highlight Normal guibg=NONE') +vim.api.nvim_command('highlight NormalNC guibg=none') +vim.api.nvim_command('highlight SignColumn guibg=none') --vim.api.nvim_command("highlight FoldColumn guibg=none") --vim.api.nvim_command("highlight CursorLineSign guibg=none ctermbg=NONE") -vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold") -vim.api.nvim_command("highlight Title guibg=none gui=bold") -vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") -vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold") -vim.api.nvim_command("highlight WinBar guibg=none gui=bold") -vim.api.nvim_command("highlight NormalFloat guibg=none") -vim.api.nvim_command("highlight LineNr guibg=none") +vim.api.nvim_command('highlight TabLine guibg=#333842 gui=bold') +vim.api.nvim_command('highlight Title guibg=none gui=bold') +vim.api.nvim_command('highlight TabLineSel guibg=#333842 gui=bold') +vim.api.nvim_command('highlight TabLineFill guibg=none gui=bold') +vim.api.nvim_command('highlight WinBar guibg=none gui=bold') +vim.api.nvim_command('highlight NormalFloat guibg=none') +vim.api.nvim_command('highlight LineNr guibg=none') --vim.api.nvim_command("highlight FoldColumn guibg=none") --vim.api.nvim_command("highlight SignColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") @@ -52,19 +51,19 @@ vim.api.nvim_command("highlight LineNr guibg=none") --vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") --vim.api.nvim_command("highlight StatusLineNC guibg=none ctermfg=Cyan guifg=#80a0ff gui=bold") -vim.api.nvim_command("highlight WinSeparator guibg=none gui=bold") -vim.api.nvim_command("highlight MsgSeparator guibg=none") -vim.api.nvim_command("highlight PmenuSel guibg=none") -vim.api.nvim_command("highlight winblend guibg=none") -vim.api.nvim_command("highlight EndOfBuffer guibg=NONE guifg=Normal") +vim.api.nvim_command('highlight WinSeparator guibg=none gui=bold') +vim.api.nvim_command('highlight MsgSeparator guibg=none') +vim.api.nvim_command('highlight PmenuSel guibg=none') +vim.api.nvim_command('highlight winblend guibg=none') +vim.api.nvim_command('highlight EndOfBuffer guibg=NONE guifg=Normal') -- Set different window separator colorscheme -vim.cmd [[ +vim.cmd([[ au WinEnter * setl winhl=WinSeparator:WinSeparatorA au WinLeave * setl winhl=WinSeparator:WinSeparator -]] +]]) -require("notify").setup({ - background_colour = "#000000", +require('notify').setup({ + background_colour = '#000000', }) -- Custom colorscheme -- cgit v1.2.3 From 030ade0e07d9c6c9b6a9d0984204c6214d365e38 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:52:43 +0200 Subject: Add session-lens --- lua/plugins/telescope.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index f6f7558..96dc2ce 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -291,7 +291,6 @@ require('telescope').load_extension('ui-select') require('telescope').load_extension('file_browser') require('telescope').load_extension('changed_files') require('telescope').load_extension('media_files') ---require('telescope').extensions.notify.notify() require('telescope').load_extension('notify') require('telescope').load_extension('dap') require('telescope').load_extension('session-lens') @@ -316,6 +315,8 @@ function M.find_configs() results_title = 'Config Files', path_display = { 'smart' }, search_dirs = { + '~/.ssh', + '~/.vim', '~/.config/nvim', '~/.config/zsh', '~/.config/tmux', @@ -328,7 +329,6 @@ function M.find_configs() '~/.config/picom', '~/.config/polybar', '~/.bashrc', - '~/.vim', '~/.profile', '~/.zprofile', '~/.gitconfig', @@ -363,7 +363,6 @@ function M.find_scripts() prompt_title = ' Find Scripts', path_display = { 'smart' }, search_dirs = { - '~/.ssh', '~/.local/bin/scripts', }, layout_strategy = 'horizontal', @@ -371,7 +370,7 @@ function M.find_scripts() }) end -function M.find_projects() +function M.find_projects() -- aka Workspaces require('telescope.builtin').find_files({ hidden = true, no_ignore = true, -- cgit v1.2.3 From 0099ea4927b9b5e7599d33cbc835ede09184b66b Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 17:53:09 +0200 Subject: Still trying to fix annoying timestamp issue --- autoload/utils.vim | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/autoload/utils.vim b/autoload/utils.vim index 3bb83bf..f11a769 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -165,6 +165,24 @@ autocmd! BufNewFile,BufRead *.* call utils#DisableBr() "------------------------------------------------- +" Annoying timestamp issue on write (The file has been changed since reading it...) +"function! utils#ProcessFileChangedShell() +" if v:fcs_reason == 'mode' || v:fcs_reason == 'time' +" let v:fcs_choice = '' +" else +" let v:fcs_choice = 'ask' +" endif +"endfunction +"autocmd FileChangedShell call utils#ProcessFileChangedShell() +" +"let lastline = line('$') +"let bufcontents = getline(1, lastline) +"edit! +"call setline(1, bufcontents) +"if line('$') > lastline +" execute lastline+1.',$:d _' +"endif + " Annoying timestamp issue on write (The file has been changed since reading it...) function! utils#ProcessFileChangedShell() if v:fcs_reason == 'mode' || v:fcs_reason == 'time' @@ -173,7 +191,21 @@ function! utils#ProcessFileChangedShell() let v:fcs_choice = 'ask' endif endfunction + +" Triggered when the file is changed externally autocmd FileChangedShell call utils#ProcessFileChangedShell() +" Triggered before writing the buffer to the file +autocmd BufWritePre call utils#BeforeWrite() + +function! utils#BeforeWrite() + let lastline = line('$') + let bufcontents = getline(1, lastline) + edit! + call setline(1, bufcontents) + if line('$') > lastline + execute lastline+1.',$:d _' + endif +endfunction "------------------------------------------------- -- cgit v1.2.3 From 8bddd30437663cf9b1b606cae0a5e4d3bdb4421e Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 31 Aug 2023 18:03:49 +0200 Subject: Mapping to delete file of current buffer --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 6bc3c04..fca56ca 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -49,6 +49,9 @@ map('n', 'n', ':bn') map('n', 'p', ':bp') map('n', 'd', ':bd') +-- Delete file of current buffer +map('n', 'rm', "call delete(expand('%')) | bdelete!") + -- List marks map('n', 'm', ':marks') -- cgit v1.2.3 From e5716618f750a9f2d8b33f851406a074ed1f1ae3 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 1 Sep 2023 10:16:08 +0200 Subject: Updated find_notes() to also search for scratch notes --- lua/plugins/telescope.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 96dc2ce..d86ab8c 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -315,7 +315,6 @@ function M.find_configs() results_title = 'Config Files', path_display = { 'smart' }, search_dirs = { - '~/.ssh', '~/.vim', '~/.config/nvim', '~/.config/zsh', @@ -336,6 +335,7 @@ function M.find_configs() '~/.gitignore', '~/.editorconfig', '~/.prettierrc.yml', + '~/.ssh', '~/README.md', }, file_ignore_patterns = { @@ -398,14 +398,16 @@ end function M.find_notes() require('telescope.builtin').find_files({ - hidden = false, + hidden = true, + no_ignore = false, prompt_title = ' Find Notes', path_display = { 'smart' }, search_dirs = { '~/documents/notes/private/', '~/documents/notes', + '~/notes/private', + '~/notes', }, - --cwd = "~documents/notes", layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, }) -- cgit v1.2.3 From 60ba15bd72f0da554ef645bc2c7a50511b0224d9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 1 Sep 2023 10:16:40 +0200 Subject: Create the directory if it does not exist for scratch() --- lua/user/mods.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 0b7f406..63b3ac0 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -614,12 +614,16 @@ end -- Function to create or toggle a scratch buffer function M.Scratch() - local scratch_dir = vim.fn.expand('~') + local scratch_dir = vim.fn.expand('~/notes/private') local scratch_date = os.date('%Y-%m-%d') - local scratch_file = 'notes-' .. scratch_date .. '.md' + local scratch_file = 'scratch-' .. scratch_date .. '.md' local scratch_buf = vim.fn.bufnr(scratch_file) local bufinfo = vim.fn.getbufinfo(scratch_buf) + -- Check if the directory exists, and create it if it doesn't + if vim.fn.isdirectory(scratch_dir) == 0 then + vim.fn.mkdir(scratch_dir, 'p') + end if scratch_buf == -1 then -- If the buffer doesn't exist, create it vim.cmd('vsplit ' .. scratch_dir .. '/' .. scratch_file) -- cgit v1.2.3 From 228e1b0a1e1e27adb046a16551dfb6c5dfa142cb Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:36:06 +0200 Subject: New mappings for float/horizontal/vertical scratch buffer --- lua/user/keys.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index fca56ca..69fd9c4 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -185,8 +185,8 @@ end map('v', 'sr', 'y:%s/"//gc') -- Substitute globally and locally in the selected region. -map('n', 'ss', ':%s//g') -map('v', 'ss', ':s//g') +map('n', 's', ':%s//g') +map('v', 's', ':s//g') -- Toggle completion map('n', 'tc', ':lua require("user.mods").toggle_completion()') @@ -430,4 +430,6 @@ map({ 'n', 'v' }, 'r', 'SnipRun') map('n', 'co', 'lua require("user.mods").toggleCodi()') -- Scratch buffer -map('n', 's', 'lua require("user.mods").Scratch()') +map('n', 'ss', 'lua require("user.mods").Scratch("float")') +map('n', 'sh', 'lua require("user.mods").Scratch("horizontal")') +map('n', 'sv', 'lua require("user.mods").Scratch("vertical")') -- cgit v1.2.3 From 0a5d62dac7bd9de16b8cf727d003cd8653a4719a Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:36:31 +0200 Subject: Made scratch buffer into either float/vertical/horizontal --- lua/user/mods.lua | 120 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 24 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 63b3ac0..f9efd5a 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -612,37 +612,109 @@ end -------------------------------------------------- --- Function to create or toggle a scratch buffer -function M.Scratch() - local scratch_dir = vim.fn.expand('~/notes/private') - local scratch_date = os.date('%Y-%m-%d') - local scratch_file = 'scratch-' .. scratch_date .. '.md' - local scratch_buf = vim.fn.bufnr(scratch_file) - local bufinfo = vim.fn.getbufinfo(scratch_buf) - +---- Function to create or toggle a scratch buffer +local scratch_buf = nil -- Store the scratch buffer globally +local scratch_win = nil -- Store the scratch window globally +local scratch_date = os.date('%Y-%m-%d') +local scratch_dir = vim.fn.expand('~/notes/private') +local scratch_file = 'scratch-' .. scratch_date .. '.md' + +function M.Scratch(Split_direction) -- Check if the directory exists, and create it if it doesn't if vim.fn.isdirectory(scratch_dir) == 0 then vim.fn.mkdir(scratch_dir, 'p') end - if scratch_buf == -1 then - -- If the buffer doesn't exist, create it - vim.cmd('vsplit ' .. scratch_dir .. '/' .. scratch_file) - if vim.fn.empty(vim.fn.glob(scratch_dir .. '/' .. scratch_file)) == 1 then - vim.cmd(':normal i# Quick Notes - ' .. scratch_date) - vim.cmd(':normal o') - vim.cmd(':normal 28a-') - vim.cmd(':normal o') - vim.cmd(':w') - --vim.cmd(':startinsert') + + -- Determine the window type based on Split_direction + local current_window_type = 'float' + if Split_direction == 'float' then + current_window_type = 'float' + elseif Split_direction == 'vertical' then + current_window_type = 'vertical' + elseif Split_direction == 'horizontal' then + current_window_type = 'horizontal' + end + + local file_path = scratch_dir .. '/' .. scratch_file + + if scratch_win and vim.api.nvim_win_is_valid(scratch_win) then + -- Window exists, save buffer to file and close it + WriteScratchBufferToFile(scratch_buf, file_path) + vim.cmd(':w!') + vim.api.nvim_win_close(scratch_win, true) + scratch_win = nil + else + if scratch_buf and vim.api.nvim_buf_is_valid(scratch_buf) then + -- Buffer exists, reuse it + OpenScratchWindow(scratch_buf, current_window_type) + else + -- Buffer doesn't exist, create it and load the file if it exists + scratch_buf = OpenScratchBuffer(file_path) + OpenScratchWindow(scratch_buf, current_window_type) end - elseif vim.fn.empty(bufinfo[1].windows) == 1 then - -- If the buffer exists but is not open, open it - vim.cmd('vsplit +buffer' .. scratch_buf) + end +end + +function WriteScratchBufferToFile(buf, file_path) + local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) + local content = table.concat(lines, '\n') + local escaped_file_path = vim.fn.fnameescape(file_path) + + -- Write the buffer content to the file + local file = io.open(escaped_file_path, 'w') + if file then + file:write(content) + file:close() + end +end + +function OpenScratchBuffer(file_path) + local buf = vim.api.nvim_create_buf(true, false) + + -- Set the file name for the buffer + local escaped_file_path = vim.fn.fnameescape(file_path) + vim.api.nvim_buf_set_name(buf, escaped_file_path) + + -- Check if the file exists and load it if it does + if vim.fn.filereadable(file_path) == 1 then + local file_contents = vim.fn.readfile(file_path) + vim.api.nvim_buf_set_lines(buf, 0, -1, true, file_contents) else - -- If the buffer exists and is open, close it - local scratch_win = vim.fn.filter(vim.fn.getwininfo(), 'v:val.bufnr == ' .. scratch_buf)[1].winnr + -- Insert initial content + vim.api.nvim_buf_set_lines(buf, 0, -1, true, { + '# Quick Notes - ' .. scratch_date, + '--------------------------', + '', + }) + + -- Save the initial content to the file vim.cmd(':w') - vim.cmd(scratch_win .. 'wincmd c') + end + + return buf +end + +function OpenScratchWindow(buf, current_window_type) + if current_window_type == 'float' then + local opts = { + relative = 'win', + width = 120, + height = 10, + border = 'single', + row = 20, + col = 20, + } + scratch_win = vim.api.nvim_open_win(buf, true, opts) + -- Go to the last line of the buffer + vim.api.nvim_win_set_cursor(0, { vim.api.nvim_buf_line_count(buf), 1 }) + elseif current_window_type == 'vertical' then + vim.cmd('vsplit') + vim.api.nvim_win_set_buf(0, buf) + scratch_win = 0 + elseif current_window_type == 'horizontal' then + vim.cmd('split') + vim.api.nvim_win_set_buf(0, buf) + scratch_win = 0 end end -- cgit v1.2.3 From 2835bdf6005626b3f377fd36aa8e10d0051aa0ef Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:46:54 +0200 Subject: Allow webdev icons for folders --- lua/plugins/nvim-tree.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 774e2f0..95b6f93 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -6,7 +6,8 @@ --- To see default mappings `:nvim-tree-default-mappings` local icons = { - git_placement = 'after', + webdev_colors = true, + git_placement = 'signcolumn', modified_placement = 'after', padding = ' ', show = { @@ -30,6 +31,7 @@ local icons = { symlink = '', symlink_open = '', }, + git = { deleted = '', unmerged = '', @@ -40,6 +42,12 @@ local icons = { ignored = '◌', }, }, + web_devicons = { + folder = { + enable = true, + color = true, + }, + }, } local renderer = { -- cgit v1.2.3 From 7a045812d1a80448e1593278b8a7479a48185cdc Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:50:10 +0200 Subject: Some changes to the renderer --- lua/plugins/nvim-tree.lua | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 95b6f93..742ffad 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -51,6 +51,12 @@ local icons = { } local renderer = { + group_empty = true, -- default: true. Compact folders that only contain a single folder into one node in the file tree. + highlight_git = false, + full_name = false, + highlight_opened_files = 'icon', -- "none" (default), "icon", "name" or "all" + highlight_modified = 'icon', -- "none", "name" or "all". Nice and subtle, override the open icon + root_folder_label = ':~:s?$?/..?', indent_width = 2, indent_markers = { enable = true, @@ -66,33 +72,6 @@ local renderer = { icons = icons, } -local system_open = { cmd = 'zathura' } - -local HEIGHT_RATIO = 0.8 -local WIDTH_RATIO = 0.15 - -local float = { - enable = false, - open_win_config = function() - local screen_w = vim.opt.columns:get() - local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() - local window_w = screen_w * WIDTH_RATIO - local window_h = screen_h * HEIGHT_RATIO - local window_w_int = math.floor(window_w) - local window_h_int = math.floor(window_h) - local center_x = (screen_w - window_w) / 2 - local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() - return { - border = 'rounded', - relative = 'editor', - row = center_y, - col = center_x, - width = window_w_int, - height = window_h_int, - } - end, -} - local view = { cursorline = false, hide_root_folder = false, -- cgit v1.2.3 From 36d11ecbd919f98bb53a1e9406caa3ba102a5ba1 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:51:46 +0200 Subject: More configurations for float window --- lua/plugins/nvim-tree.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 742ffad..e24a299 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -72,6 +72,33 @@ local renderer = { icons = icons, } +local system_open = { cmd = 'zathura' } + +local HEIGHT_RATIO = 0.8 +local WIDTH_RATIO = 0.15 + +local float = { + enable = false, + open_win_config = function() + local screen_w = vim.opt.columns:get() + local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() + local window_w = screen_w * WIDTH_RATIO + local window_h = screen_h * HEIGHT_RATIO + local window_w_int = math.floor(window_w) + local window_h_int = math.floor(window_h) + local center_x = (screen_w - window_w) / 2 + local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() + return { + border = 'rounded', + relative = 'editor', + row = center_y, + col = center_x, + width = window_w_int, + height = window_h_int, + } + end, +} + local view = { cursorline = false, hide_root_folder = false, -- cgit v1.2.3 From 5a873e0d0d4d0b4587b850d696f3717103f529a0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:54:15 +0200 Subject: Improved general behaviour of the tree --- lua/plugins/nvim-tree.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index e24a299..4db4313 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -187,18 +187,21 @@ api.events.subscribe(api.events.Event.FileCreated, function(file) end) require('nvim-tree').setup({ + auto_reload_on_write = true, + create_in_closed_folder = false, + hijack_cursor = true, disable_netrw = true, hijack_netrw = true, - auto_reload_on_write = true, + hijack_unnamed_buffer_when_opening = false, + --ignore_buffer_on_setup = false, update_focused_file = { enable = true, - update_cwd = false, + update_cwd = true, update_root = true, ignore_list = {}, }, root_dirs = {}, prefer_startup_root = true, - hijack_cursor = true, --hijack_directories = { -- enable = false, --}, @@ -228,10 +231,17 @@ require('nvim-tree').setup({ require_confirm = true, }, modified = { - enable = false, + enable = true, show_on_dirs = true, show_on_open_dirs = true, }, + filters = { + dotfiles = false, + git_clean = false, + no_buffer = false, + custom = {}, + exclude = {}, + }, actions = { use_system_clipboard = true, change_dir = { @@ -243,7 +253,8 @@ require('nvim-tree').setup({ close_window = true, }, open_file = { - quit_on_open = true, + quit_on_open = false, + eject = true, resize_window = false, window_picker = { enable = true, -- cgit v1.2.3 From 04ae882be220c87d9c2fb57443b34cdd41e7e3e1 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:56:08 +0200 Subject: Change Root To Global Current Working Directory --- lua/plugins/nvim-tree.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 4db4313..7571696 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -270,13 +270,13 @@ require('nvim-tree').setup({ local api = require('nvim-tree.api') local event = api.events.Event -api.events.subscribe(event.TreeOpen, function(_) - vim.cmd([[setlocal statuscolumn=\ ]]) - vim.cmd([[setlocal cursorlineopt=number]]) - vim.cmd([[setlocal fillchars+=vert:🮇]]) - vim.cmd([[setlocal fillchars+=horizup:🮇]]) - vim.cmd([[setlocal fillchars+=vertright:🮇]]) -end) +--api.events.subscribe(event.TreeOpen, function(_) +-- vim.cmd([[setlocal statuscolumn=\ ]]) +-- vim.cmd([[setlocal cursorlineopt=number]]) +-- vim.cmd([[setlocal fillchars+=vert:🮇]]) +-- vim.cmd([[setlocal fillchars+=horizup:🮇]]) +-- vim.cmd([[setlocal fillchars+=vertright:🮇]]) +--end) local function open_nvim_tree(data) vim.cmd.cd(data.file:match('(.+)/[^/]*$')) @@ -288,6 +288,12 @@ local function open_nvim_tree(data) end vim.api.nvim_create_autocmd({ 'VimEnter' }, { callback = open_nvim_tree }) +-- Change Root To Global Current Working Directory +local function change_root_to_global_cwd() + local api = require('nvim-tree.api') + local global_cwd = vim.fn.getcwd(-1, -1) + api.tree.change_root(global_cwd) +end -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') -- cgit v1.2.3 From 099801fc1dcda0fbeb4d5526d22df53bcf9ac309 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 22:56:36 +0200 Subject: Changed utils#ToggleDiff() mapping to 'df' --- 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 69fd9c4..3305653 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -139,7 +139,7 @@ map('n', '', ':let save_a=@a"add"ap:let @a=save_a') map('n', '', ':let save_a=@a"add"ap:let @a=save_a') -- Toggle Diff -map('n', 'td', 'call utils#ToggleDiff()') +map('n', 'df', 'call utils#ToggleDiff()') -- Toggle Verbose map('n', 'vt', 'call utils#VerboseToggle()') -- cgit v1.2.3 From 0e2e166fca112354fa30fec33089149f435ac434 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 23:03:25 +0200 Subject: Function copy_file_to(node) --- lua/plugins/nvim-tree.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 7571696..cc0b104 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -294,6 +294,18 @@ local function change_root_to_global_cwd() local global_cwd = vim.fn.getcwd(-1, -1) api.tree.change_root(global_cwd) end + +local function copy_file_to(node) + local file_src = node['absolute_path'] + -- The args of input are {prompt}, {default}, {completion} + -- Read in the new file path using the existing file's path as the baseline. + local file_out = vim.fn.input('COPY TO: ', file_src, 'file') + -- Create any parent dirs as required + local dir = vim.fn.fnamemodify(file_out, ':h') + vim.fn.system({ 'mkdir', '-p', dir }) + -- Copy the file + vim.fn.system({ 'cp', '-R', file_src, file_out }) +end -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') -- cgit v1.2.3 From e0dcd0fc39801174067cac09d340f952ae9fa62e Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 23:05:06 +0200 Subject: Made cursorline configurable and allow refreshing --- lua/plugins/nvim-tree.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index cc0b104..79bc366 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -306,6 +306,33 @@ local function copy_file_to(node) -- Copy the file vim.fn.system({ 'cp', '-R', file_src, file_out }) end + +local function edit_and_close(node) + api.node.open.edit(node, {}) + api.tree.close() +end + +vim.api.nvim_create_augroup('NvimTreeRefresh', {}) +vim.api.nvim_create_autocmd('BufEnter', { + pattern = 'NvimTree_1', + command = 'NvimTreeRefresh', + group = 'NvimTreeRefresh', +}) + +vim.api.nvim_create_autocmd({ 'CursorHold' }, { + pattern = 'NvimTree*', + callback = function() + local def = vim.api.nvim_get_hl_by_name('Cursor', true) + vim.api.nvim_set_hl( + 0, + 'Cursor', + vim.tbl_extend('force', def, { + blend = 100, + }) + ) + vim.opt.guicursor:append('a:Cursor/lCursor') + end, +}) -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') -- cgit v1.2.3 From 87b24862af2bae49e12549e624739ae200a90cbd Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 23:06:34 +0200 Subject: Edited some highlights --- lua/plugins/nvim-tree.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 79bc366..1e9eca1 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -333,8 +333,30 @@ vim.api.nvim_create_autocmd({ 'CursorHold' }, { vim.opt.guicursor:append('a:Cursor/lCursor') end, }) + +vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { + pattern = 'NvimTree*', + callback = function() + local def = vim.api.nvim_get_hl_by_name('Cursor', true) + vim.api.nvim_set_hl( + 0, + 'Cursor', + vim.tbl_extend('force', def, { + blend = 0, + }) + ) + vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20' + end, +}) -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') +vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') +vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2') +vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2') +vim.api.nvim_command('highlight NvimTreeRootFolder guifg=#f8f8f2') +vim.api.nvim_command('highlight NvimTreeEmptyFolderName guifg=#f8f8f2') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFolderName guifg=#f8f8f2') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=#000000') --vim.api.nvim_command("highlight NvimTreeSymlink ") --vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) -- cgit v1.2.3 From b606b2eac7b1942ca7a60dace432e829998758eb Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 23:15:59 +0200 Subject: Allow cursorline = true --- lua/plugins/nvim-tree.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 1e9eca1..c6bec35 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -100,10 +100,10 @@ local float = { } local view = { - cursorline = false, + cursorline = true, hide_root_folder = false, float = float, - signcolumn = 'no', + --signcolumn = 'no', width = function() return math.floor(vim.opt.columns:get() * WIDTH_RATIO) end, @@ -182,9 +182,9 @@ local function on_attach(bufnr) vim.keymap.set('n', keys, mapping[1], opts(mapping[2])) end end -api.events.subscribe(api.events.Event.FileCreated, function(file) - vim.cmd('edit' .. file.fname) -end) +--api.events.subscribe(api.events.Event.FileCreated, function(file) +-- vim.cmd('edit' .. file.fname) +--end) require('nvim-tree').setup({ auto_reload_on_write = true, @@ -348,6 +348,7 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20' end, }) + -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') -- cgit v1.2.3 From 58098da6b912f1bd36d602cbf712ada7af7fd6fd Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 4 Sep 2023 23:17:23 +0200 Subject: Mapping '' also works in terminal now --- lua/user/keys.lua | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 3305653..07a1b12 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -87,17 +87,11 @@ map('n', '<', ':vertical resize +5') map('n', '>', ':vertical resize -5') map('n', '=', '=') --- Map Alt+(h/j/k/l) in insert mode to move directional -map('i', '', '') -map('i', '', '') -map('i', '', '') -map('i', '', '') - --- Map Alt+(h/j/k/l) in command mode to move directional -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) +-- Map Alt+(h/j/k/l) in insert(include terminal/command) mode to move directional +map({ 'i', 't', 'c' }, '', '') +map({ 'i', 't', 'c' }, '', '') +map({ 'i', 't', 'c' }, '', '') +map({ 'i', 't', 'c' }, '', '') -- Create tab, edit and move between them map('n', 'n', ':tabnew') -- cgit v1.2.3 From 77181e7da2bcf5f1907d06146c69379b5dabf1f6 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Sep 2023 23:15:13 +0200 Subject: Disabled autocmd Bufenter 'Rooter' --- lua/user/mods.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index f9efd5a..e4b6b41 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -481,7 +481,7 @@ vim.api.nvim_create_autocmd({ 'VimLeave' }, { -------------------------------------------------- -- Rooter -vim.cmd([[autocmd BufEnter * lua vim.cmd('Rooter')]]) +--vim.cmd([[autocmd BufEnter * lua vim.cmd('Rooter')]]) -------------------------------------------------- -- cgit v1.2.3 From 5820199baa9f572f4ae26d36a9bfaf8ae40fe3f1 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Sep 2023 23:37:40 +0200 Subject: Moved colors to init.lua --- lua/plugins/colorscheme.lua | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 2e04581..be78ac8 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,19 +1,3 @@ --- Colorscheme --- Available colorschemes: --- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] - --- Define default color scheme -local default_colorscheme = 'nightfly' -local fallback_colorscheme = 'desert' - --- Attempt to set the default color scheme -local status_ok, _ = pcall(vim.cmd, 'colorscheme ' .. default_colorscheme) - --- If the default color scheme is not found, use the fallback color scheme -if not status_ok then - vim.cmd('colorscheme ' .. fallback_colorscheme) -end - --local function MyHighlights() -- vim.cmd('highlight Visual cterm=NONE ctermbg=76 ctermfg=16 gui=NONE guibg=#5fd700 guifg=#000000') -- vim.cmd('highlight StatusLine cterm=NONE ctermbg=231 ctermfg=160 gui=NONE guibg=#ffffff guifg=#d70000') @@ -30,19 +14,6 @@ end -- --setupMyColors() -vim.api.nvim_command('syntax on') -vim.api.nvim_command('highlight Normal guibg=NONE') -vim.api.nvim_command('highlight NormalNC guibg=none') -vim.api.nvim_command('highlight SignColumn guibg=none') ---vim.api.nvim_command("highlight FoldColumn guibg=none") ---vim.api.nvim_command("highlight CursorLineSign guibg=none ctermbg=NONE") -vim.api.nvim_command('highlight TabLine guibg=#333842 gui=bold') -vim.api.nvim_command('highlight Title guibg=none gui=bold') -vim.api.nvim_command('highlight TabLineSel guibg=#333842 gui=bold') -vim.api.nvim_command('highlight TabLineFill guibg=none gui=bold') -vim.api.nvim_command('highlight WinBar guibg=none gui=bold') -vim.api.nvim_command('highlight NormalFloat guibg=none') -vim.api.nvim_command('highlight LineNr guibg=none') --vim.api.nvim_command("highlight FoldColumn guibg=none") --vim.api.nvim_command("highlight SignColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") @@ -51,20 +22,6 @@ vim.api.nvim_command('highlight LineNr guibg=none') --vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") --vim.api.nvim_command("highlight StatusLineNC guibg=none ctermfg=Cyan guifg=#80a0ff gui=bold") -vim.api.nvim_command('highlight WinSeparator guibg=none gui=bold') -vim.api.nvim_command('highlight MsgSeparator guibg=none') -vim.api.nvim_command('highlight PmenuSel guibg=none') -vim.api.nvim_command('highlight winblend guibg=none') -vim.api.nvim_command('highlight EndOfBuffer guibg=NONE guifg=Normal') --- Set different window separator colorscheme -vim.cmd([[ -au WinEnter * setl winhl=WinSeparator:WinSeparatorA -au WinLeave * setl winhl=WinSeparator:WinSeparator -]]) - -require('notify').setup({ - background_colour = '#000000', -}) -- Custom colorscheme --vim.cmd([[ -- cgit v1.2.3 From 0482c387d5606e720dfee3e56f7a321fe9a0b3f5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Sep 2023 23:38:04 +0200 Subject: Moved colorscheme settings here --- init.lua | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 1184200..ac05023 100644 --- a/init.lua +++ b/init.lua @@ -65,7 +65,7 @@ local modules = { --"user.scripts", 'plugins.treesitter', 'plugins.neodev', - 'plugins.colorscheme', + --'plugins.colorscheme', 'plugins.telescope', 'plugins.nvim-tree', 'plugins.web-devicons', @@ -104,12 +104,6 @@ for k, v in pairs(modules) do require(v) end --- Snippets -vim.g.snippets = 'luasnip' - --- Notifications -vim.notify = require('notify') -- Requires plugin "rcarriga/nvim-notify" - -- Improve speed by disabling some default plugins/modules local builtins = { 'gzip', @@ -141,3 +135,58 @@ for _, plugin in ipairs(builtins) do end vim.g.do_filetype_lua = 1 vim.g.did_load_filetypes = 0 + +-- Snippets +vim.g.snippets = 'luasnip' + +-- Notifications +vim.notify = require('notify') -- Requires plugin "rcarriga/nvim-notify" + +-- Colorscheme + +-- Colors +vim.opt.termguicolors = true + +-- Available colorschemes: +-- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] + +-- Define default color scheme +local default_colorscheme = 'tokyonight-night' +local fallback_colorscheme = 'desert' + +-- Attempt to set the default color scheme +local status_ok, _ = pcall(vim.cmd, 'colorscheme ' .. default_colorscheme) + +-- If the default color scheme is not found, use the fallback color scheme +if not status_ok then + vim.cmd('colorscheme ' .. fallback_colorscheme) +end + +vim.api.nvim_command('syntax on') +vim.api.nvim_command('highlight Normal guibg=none') +vim.api.nvim_command('highlight NormalNC guibg=none') +vim.api.nvim_command('highlight SignColumn guibg=none') +vim.api.nvim_command('highlight FoldColumn guibg=none') +vim.api.nvim_command('highlight CursorLineSign guibg=none ctermbg=NONE') +vim.api.nvim_command('highlight TabLine guibg=#333842 gui=bold') +vim.api.nvim_command('highlight Title guibg=none gui=bold') +vim.api.nvim_command('highlight TabLineSel guibg=#333842 gui=bold') +vim.api.nvim_command('highlight TabLineFill guibg=none gui=bold') +vim.api.nvim_command('highlight WinBar guibg=none gui=bold') +vim.api.nvim_command('highlight NormalFloat guibg=none') +vim.api.nvim_command('highlight LineNr guibg=none') +vim.api.nvim_command('highlight WinSeparator guibg=none gui=bold') +vim.api.nvim_command('highlight MsgSeparator guibg=none') +vim.api.nvim_command('highlight PmenuSel guibg=none') +vim.api.nvim_command('highlight winblend guibg=none') +vim.api.nvim_command('highlight EndOfBuffer guibg=NONE guifg=Normal') + +-- Set different window separator colorscheme +vim.cmd([[ +au WinEnter * setl winhl=WinSeparator:WinSeparatorA +au WinLeave * setl winhl=WinSeparator:WinSeparator +]]) + +require('notify').setup({ + background_colour = '#000000', +}) -- cgit v1.2.3 From 4d244e6d32dd8abb3847eefac073e609dca89f68 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Sep 2023 23:38:25 +0200 Subject: Moved termguicolors to init.lua --- lua/user/opts.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 0b3f32b..c724710 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -13,9 +13,6 @@ vim.g.sh_noisk = 1 -- iskeyword word boundaries when e vim.o.autochdir = true --vim.o.writeany= true --- Colors -vim.opt.termguicolors = true - -- Clipboard vim.opt.clipboard:append({ 'unnamedplus' }) -- Install xclip or this will slowdown startup -- cgit v1.2.3 From 6932db57d88ce2bab25c488f6a4afe37d19cccc7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Sep 2023 23:38:41 +0200 Subject: Disable webdev_colors for now --- lua/plugins/nvim-tree.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index c6bec35..f29cf83 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -6,7 +6,7 @@ --- To see default mappings `:nvim-tree-default-mappings` local icons = { - webdev_colors = true, + --webdev_colors = true, git_placement = 'signcolumn', modified_placement = 'after', padding = ' ', @@ -312,12 +312,12 @@ local function edit_and_close(node) api.tree.close() end -vim.api.nvim_create_augroup('NvimTreeRefresh', {}) -vim.api.nvim_create_autocmd('BufEnter', { - pattern = 'NvimTree_1', - command = 'NvimTreeRefresh', - group = 'NvimTreeRefresh', -}) +--vim.api.nvim_create_augroup('NvimTreeRefresh', {}) +--vim.api.nvim_create_autocmd('BufEnter', { +-- pattern = 'NvimTree_1', +-- command = 'NvimTreeRefresh', +-- group = 'NvimTreeRefresh', +--}) vim.api.nvim_create_autocmd({ 'CursorHold' }, { pattern = 'NvimTree*', @@ -351,6 +351,8 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { -- Highlight Groups vim.api.nvim_command('highlight NvimTreeNormal guibg=none') +vim.api.nvim_command('highlight NvimTreeNormalFloat guibg=none') +vim.api.nvim_command('highlight NvimTreeEndOfBuffer guibg=none') --(NonText) vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2') vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2') -- cgit v1.2.3 From decb9a33971e99db3dbb6d41c7757a07a7d4addc Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 13:01:11 +0200 Subject: Intercept file open --- lua/user/mods.lua | 112 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 10 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index e4b6b41..6420ed5 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -27,14 +27,14 @@ end -------------------------------------------------- -- Format on save -local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) +local format_augroup = vim.api.nvim_create_augroup('LspFormatting', {}) require('null-ls').setup({ -- you can reuse a shared lspconfig on_attach callback here on_attach = function(client, bufnr) if client.supports_method('textDocument/formatting') then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_clear_autocmds({ group = format_augroup, buffer = bufnr }) vim.api.nvim_create_autocmd('BufWritePre', { - group = augroup, + group = format_augroup, buffer = bufnr, callback = function() -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead @@ -134,15 +134,9 @@ end -- Define a global function to retrieve LSP clients based on Neovim version function M.get_lsp_clients(bufnr) local mods = require('user.mods') - local expected_ver = '0.10.0' + --local expected_ver = '0.10.0' local nvim_ver = mods.get_nvim_version() - --if nvim_ver ~= expected_ver then - -- local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) - -- vim.api.nvim_err_writeln(msg) - -- return - --end - local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') version_major = tonumber(version_major) version_minor = tonumber(version_minor) @@ -720,5 +714,103 @@ end -------------------------------------------------- +-- Intercept file open +local augroup = vim.api.nvim_create_augroup('user-autocmds', { clear = true }) +local intercept_file_open = true +vim.api.nvim_create_user_command('InterceptToggle', function() + intercept_file_open = not intercept_file_open + local intercept_state = '`Enabled`' + if not intercept_file_open then + intercept_state = '`Disabled`' + end + vim.notify('Intercept file open set to ' .. intercept_state, vim.log.levels.INFO, { + title = 'Intercept File Open', + ---@param win integer The window handle + on_open = function(win) + vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), 'filetype', 'markdown') + end, + }) +end, { desc = 'Toggles intercepting BufNew to open files in custom programs' }) + +-- NOTE: Add "BufReadPre" to the autocmd events to also intercept files given on the command line, e.g. +-- `nvim myfile.txt` +vim.api.nvim_create_autocmd({ 'BufNew' }, { + group = augroup, + callback = function(args) + ---@type string + local path = args.match + ---@type integer + local bufnr = args.buf + + ---@type string? The file extension if detected + local extension = vim.fn.fnamemodify(path, ':e') + ---@type string? The filename if detected + local filename = vim.fn.fnamemodify(path, ':t') + + ---Open a given file path in a given program and remove the buffer for the file. + ---@param buf integer The buffer handle for the opening buffer + ---@param fpath string The file path given to the program + ---@param fname string The file name used in notifications + ---@param prog string The program to execute against the file path + local function open_in_prog(buf, fpath, fname, prog) + vim.notify(string.format('Opening `%s` in `%s`', fname, prog), vim.log.levels.INFO, { + title = 'Open File in External Program', + ---@param win integer The window handle + on_open = function(win) + vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), 'filetype', 'markdown') + end, + }) + local mods = require('user.mods') + local nvim_ver = mods.get_nvim_version() + + local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') + version_major = tonumber(version_major) + version_minor = tonumber(version_minor) + + if version_major > 0 or (version_major == 0 and version_minor >= 10) then + vim.system({ prog, fpath }, { detach = true }) + else + vim.fn.jobstart({ prog, fpath }, { detach = true }) + end + vim.api.nvim_buf_delete(buf, { force = true }) + end + + local extension_callbacks = { + ['pdf'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'zathura') + end, + ['png'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'feh') + end, + ['jpg'] = 'png', + ['mp4'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'mpv') + end, + ['gif'] = 'mp4', + } + + ---Get the extension callback for a given extension. Will do a recursive lookup if an extension callback is actually + ---of type string to get the correct extension + ---@param ext string A file extension. Example: `png`. + ---@return fun(bufnr: integer, path: string, filename: string?) extension_callback The extension callback to invoke, expects a buffer handle, file path, and filename. + local function extension_lookup(ext) + local callback = extension_callbacks[ext] + if type(callback) == 'string' then + callback = extension_lookup(callback) + end + return callback + end + + if extension ~= nil and not extension:match('^%s*$') and intercept_file_open then + local callback = extension_lookup(extension) + if type(callback) == 'function' then + callback(bufnr, path, filename) + end + end + end, +}) + +-------------------------------------------------- + -- ... return M -- cgit v1.2.3 From 4cb5d762460477dddb559bd006d77c9cef0ddbaf Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 21:39:47 +0200 Subject: New binding for loclist --- lua/user/keys.lua | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 07a1b12..c838903 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -6,6 +6,7 @@ local map = function(mode, l, r, opts) keymap.set(mode, l, r, opts) end local term_opts = { noremap = true, silent = false } +local bufnr = vim.api.nvim_get_current_buf() -- Semi-colon as leader key vim.g.mapleader = ';' @@ -115,10 +116,6 @@ map('n', '8', '8gt') map('n', '9', '9gt') map('n', '0', '10gt') --- Move to the next and previous item in the quickfixlist ---map("n", "]c", "cnext") ---map("n", "[c", "cprevious") - -- Hitting ESC when inside a terminal to get into normal mode --map("t", "", [[]]) @@ -324,11 +321,11 @@ map('n', 'zm', "ZenMode | :echom ('Zen Mode') | :sl! | echo map('n', 'ro', "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", term_opts) -- Trouble (UI to show diagnostics) -map('n', 't', 'TroubleToggle') -map('n', 'tw', 'TroubleToggle workspace_diagnostics') -map('n', 'td', 'TroubleToggle document_diagnostics') -map('n', 'tq', 'TroubleToggle quickfix') -map('n', 'tl', 'TroubleToggle loclist') +map('n', 't', ':cd %:p:h:pwdTroubleToggle') +map('n', 'tw', ':cd %:p:h:pwdTroubleToggle workspace_diagnostics') +map('n', 'td', ':cd %:p:h:pwdTroubleToggle document_diagnostics') +map('n', 'tq', ':cd %:p:h:pwdTroubleToggle quickfix') +map('n', 'tl', ':cd %:p:h:pwdTroubleToggle loclist') map('n', 'gR', 'TroubleToggle lsp_references') -- Null-ls @@ -343,10 +340,16 @@ map('n', 'q', function() require('plugins.quickfix').close() else require('plugins.quickfix').open() - -- require("quickfix").open() end end, { desc = 'Toggle quickfix window' }) +-- Move to the next and previous item in the quickfixlist +map('n', ']c', 'cnext') +map('n', '[c', 'cprevious') + +-- Location list +map('n', 'l', 'lua require("plugins.loclist").loclist_toggle()') + -- Dap (debugging) local dap_ok, dap = pcall(require, 'dap') local dap_ui_ok, ui = pcall(require, 'dapui') @@ -415,7 +418,7 @@ end, { desc = 'DAP-Telescope: Commands' }) map('n', '', 'lua require("user.mods").toggle_dashboard()') -- Lsp Lines toggle -map('', 'l', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) +map('', 'll', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) -- SnipRun map({ 'n', 'v' }, 'r', 'SnipRun') -- cgit v1.2.3 From 17ef2292b271a8b0cce89aefde8a84c1a7e8c49a Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 21:40:21 +0200 Subject: Toggle loclist --- lua/plugins/loclist.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lua/plugins/loclist.lua diff --git a/lua/plugins/loclist.lua b/lua/plugins/loclist.lua new file mode 100644 index 0000000..9b72a94 --- /dev/null +++ b/lua/plugins/loclist.lua @@ -0,0 +1,18 @@ +local M = {} + +function M.loclist_toggle() + for _, info in ipairs(vim.fn.getwininfo()) do + if info.loclist == 1 then + vim.cmd('lclose') + return + end + end + + if next(vim.fn.getloclist(0)) == nil then + print('loc list empty') + return + end + vim.cmd('lopen') +end + +return M -- cgit v1.2.3 From 5998f2fba2063f2fc130c60e4348b0f4b6344d64 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 23:08:06 +0200 Subject: Formatted --- lua/plugins/quickfix.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lua/plugins/quickfix.lua b/lua/plugins/quickfix.lua index 4ea2374..4a76da0 100644 --- a/lua/plugins/quickfix.lua +++ b/lua/plugins/quickfix.lua @@ -1,18 +1,15 @@ local M = {} M.close = function() - vim.cmd.cclose() + vim.cmd.cclose() end M.open = function() - if vim.tbl_count(vim.fn.getqflist()) == 0 then - vim.notify( - "Nothing in quickfix list; not opening.", - vim.log.levels.WARN - ) - else - vim.cmd.copen() - end + if vim.tbl_count(vim.fn.getqflist()) == 0 then + vim.notify('Nothing in quickfix list; not opening.', vim.log.levels.WARN) + else + vim.cmd.copen() + end end return M -- cgit v1.2.3 From 0dbdc341793e29782c9a4b113abc2da21207d373 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 23:11:40 +0200 Subject: Mapping for vim.diagnostic.setloclist() and severity_sort = true, --- lua/plugins/lsp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 8802994..92278f3 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -52,7 +52,7 @@ if not vim.g.lsp_setup_done then focusable = true, }, update_in_insert = false, -- default to false - severity_sort = false, -- default to false + severity_sort = true, -- default to false }) vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) @@ -88,6 +88,7 @@ if not vim.g.lsp_setup_done then map('n', 'gf', 'lua vim.lsp.buf.formatting()') 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()') map('n', '[d', 'lua vim.diagnostic.goto_prev()') map('n', ']d', 'lua vim.diagnostic.goto_next()') map('n', 'gs', 'lua vim.lsp.buf.document_symbol()') -- cgit v1.2.3 From 4805be4f863b9234eb08c287d4eab8d912b957c0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 23:12:10 +0200 Subject: Changed diagnostics signs --- lua/plugins/trouble.lua | 88 ++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index d4f50dc..7d74730 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -1,47 +1,47 @@ -require("trouble").setup { - position = "bottom", -- position of the list can be: bottom, top, left, right - height = 10, -- height of the trouble list when position is top or bottom - width = 50, -- width of the list when position is left or right - icons = true, -- use devicons for filenames - mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - fold_open = "", -- icon used for open folds - fold_closed = "", -- icon used for closed folds - group = true, -- group results by file - padding = true, -- add an extra new line on top of the list - action_keys = { -- key mappings for actions in the trouble list - -- map to {} to remove a mapping, for example: - -- close = {}, - close = "q", -- close the list - cancel = "", -- cancel the preview and get back to your last window / buffer / cursor - refresh = "r", -- manually refresh - jump = {"", ""}, -- jump to the diagnostic or open / close folds - open_split = { "" }, -- open buffer in new split - open_vsplit = { "" }, -- open buffer in new vsplit - open_tab = { "" }, -- open buffer in new tab - jump_close = {"o"}, -- jump to the diagnostic and close the list - toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = "P", -- toggle auto_preview - hover = "K", -- opens a small popup with the full multiline message - preview = "p", -- preview the diagnostic location - close_folds = {"zM", "zm"}, -- close all folds - open_folds = {"zR", "zr"}, -- open all folds - toggle_fold = {"zA", "za"}, -- toggle fold of current file - previous = "k", -- previous item - next = "j" -- next item +require('trouble').setup({ + position = 'bottom', -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = 'document_diagnostics', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = '', -- icon used for open folds + fold_closed = '', -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = 'q', -- close the list + cancel = '', -- cancel the preview and get back to your last window / buffer / cursor + refresh = 'r', -- manually refresh + jump = { '', '' }, -- jump to the diagnostic or open / close folds + open_split = { '' }, -- open buffer in new split + open_vsplit = { '' }, -- open buffer in new vsplit + open_tab = { '' }, -- open buffer in new tab + jump_close = { 'o' }, -- jump to the diagnostic and close the list + toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = 'P', -- toggle auto_preview + hover = 'K', -- opens a small popup with the full multiline message + preview = 'p', -- preview the diagnostic location + close_folds = { 'zM', 'zm' }, -- close all folds + open_folds = { 'zR', 'zr' }, -- open all folds + toggle_fold = { 'zA', 'za' }, -- toggle fold of current file + previous = 'k', -- previous item + next = 'j', -- next item }, - indent_lines = true, -- add an indent guide below the fold icons - auto_open = false, -- automatically open the list when you have diagnostics - auto_close = false, -- automatically close the list when you have no diagnostics - auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window - auto_fold = false, -- automatically fold a file trouble list at creation - auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result signs = { - -- icons / text used for a diagnostic - error = "", - warning = "", - hint = "", - information = "", - other = "" + -- icons / text used for a diagnostic + error = '', + warning = '▲', + information = '􀅳', + hint = '⚑', + other = '', }, - use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client -} + use_diagnostic_signs = true, -- enabling this will use the signs defined in your lsp client +}) -- cgit v1.2.3 From 253c7d70a42876f523ffae93fe91c88af610465d Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 23:12:33 +0200 Subject: Changed mappings for most telescope functions --- lua/user/keys.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c838903..8739f71 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -269,9 +269,9 @@ map('n', 'gm', ':Gmove') --map("n", "gpl", ":Dispatch! git pull") -- Telescope -map('n', 'ff', "lua require('telescope.builtin').find_files()") -- find files with hidden option +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', 'ff.', function() +map('n', 'f.', function() require('telescope.builtin').find_files({ hidden = false, no_ignore = true }) end) -- find all files map('n', 'fg', "lua require('telescope.builtin').live_grep()") @@ -285,15 +285,17 @@ map('n', 'fk', "lua require('telescope.builtin').keymaps()") map('n', 'fr', "lua require('telescope.builtin').registers({})") -- registers picker map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications -map('n', 'f.', [[lua require'plugins.telescope'.find_configs()]]) -- find configs -map('n', 'fs', [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts -map('n', 'fw', [[lua require'plugins.telescope'.find_projects()]]) -- find projects -map('n', 'fn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map('n', 'fs', 'lua require("session-lens").search_session()') +map('n', 'ff.', [[lua require'plugins.telescope'.find_configs()]]) -- find configs +map('n', 'ffs', [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts +map('n', 'ffw', [[lua require'plugins.telescope'.find_projects()]]) -- find projects +map('n', 'ffp', [[lua require'plugins.telescope'.find_dirs()]]) -- find projects +map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'ffr', "lua require('telescope').extensions.recent_files.pick()") +map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'ffb', "lua require('telescope').extensions.file_browser.file_browser()") -map('n', 'ffs', 'lua require("session-lens").search_session()') +--map('n', 'ffp', "lua require('telescope').extensions.projects.projects()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- Map a shortcut to open the picker. -- cgit v1.2.3 From a7c77bfb27c1b49cf255903a2a9856f1cc23f60b Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Sep 2023 23:13:35 +0200 Subject: Find project dirs --- lua/plugins/telescope.lua | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index d86ab8c..0a2b3f1 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -260,19 +260,19 @@ require('telescope').setup({ file_browser = { theme = 'dropdown', -- disables netrw and use telescope-file-browser in its place - hijack_netrw = true, + hijack_netrw = false, mappings = { -- your custom insert mode mappings ['i'] = { [''] = function() vim.cmd('normal vbd') end, - --[""] = fb_actions.goto_parent_dir, + [''] = fb_actions.goto_parent_dir, }, ['n'] = { -- your custom normal mode mappings ['N'] = fb_actions.create, - --[""] = fb_actions.goto_parent_dir, + [''] = fb_actions.goto_parent_dir, --["/"] = function() -- vim.cmd("startinsert") --end, @@ -296,6 +296,7 @@ require('telescope').load_extension('dap') require('telescope').load_extension('session-lens') require('telescope').load_extension('flutter') require('telescope').load_extension('recent_files') +require('telescope').load_extension('projects') --M.curbuf = function(opts) -- opts = opts @@ -499,4 +500,46 @@ vim.cmd('command! Findhere lua require("plugins.telescope").findhere()') -- Merge the existing M table with the startup function table --M = vim.tbl_extend('force', M, { findhere = findhere }) +-- Find project dirs +function M.find_dirs() + local actions = require('telescope.actions') + local actions_set = require('telescope.actions.set') + local actions_state = require('telescope.actions.state') + local finders = require('telescope.finders') + local pickers = require('telescope.pickers') + local conf = require('telescope.config').values + local search_dir = '~/projects' + + pickers + .new({}, { + prompt_title = 'Change Directory', + finder = finders.new_oneshot_job({ + 'find', + vim.fn.expand(search_dir), + '-type', + 'd', + '-maxdepth', + '4', + }), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = conf.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local dir = entry.value + actions.close(prompt_bufnr, false) + --vim.cmd('lcd ' .. vim.fn.fnameescape(dir)) + vim.fn.chdir(dir) + vim.cmd('e .') + vim.cmd("echon ''") + print('cwd: ' .. vim.fn.getcwd()) + end + end) + return true + end, + }) + :find() +end + return M -- cgit v1.2.3 From 841e6681e4411fd67d4644ea226b627f930c20f4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 8 Sep 2023 20:30:23 +0200 Subject: Updated find_projects and find_dirs --- lua/plugins/telescope.lua | 145 +++++++++++++++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 48 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 0a2b3f1..123f676 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -4,12 +4,14 @@ local M = {} local actions = require('telescope.actions') local fb_actions = require('telescope').extensions.file_browser.actions --local builtin = require("telescope.builtin") ---local themes = require("telescope.themes") --local utils = require("telescope.utils") ---local action_state = require("telescope.actions.state") --local layout_actions = require("telescope.actions.layout") ---local pickers = require("telescope.pickers") -local themes = require('telescope.themes') +--local themes = require('telescope.themes') +local actions_set = require('telescope.actions.set') +local actions_state = require('telescope.actions.state') +local finders = require('telescope.finders') +local pickers = require('telescope.pickers') +local config = require('telescope.config').values require('telescope').setup({ defaults = { @@ -296,7 +298,7 @@ require('telescope').load_extension('dap') require('telescope').load_extension('session-lens') require('telescope').load_extension('flutter') require('telescope').load_extension('recent_files') -require('telescope').load_extension('projects') +--require('telescope').load_extension('projects') --M.curbuf = function(opts) -- opts = opts @@ -371,18 +373,51 @@ function M.find_scripts() }) end -function M.find_projects() -- aka Workspaces - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - prompt_title = ' Find Projects', - path_display = { 'smart' }, - search_dirs = { - '~/projects', - }, - layout_strategy = 'horizontal', - layout_config = { preview_width = 0.65, width = 0.75 }, - }) +--function M.find_projects() -- aka Workspaces +-- require('telescope.builtin').find_files({ +-- hidden = true, +-- no_ignore = true, +-- prompt_title = ' Find Projects', +-- path_display = { 'smart' }, +-- search_dirs = { +-- '~/projects', +-- }, +-- layout_strategy = 'horizontal', +-- layout_config = { preview_width = 0.65, width = 0.75 }, +-- }) +--end + +function M.find_projects() + local search_dir = '~/projects' + pickers + .new({}, { + prompt_title = 'Change Directory', + finder = finders.new_oneshot_job({ + 'find', + vim.fn.expand(search_dir), + '-type', + 'd', + '-maxdepth', + '4', + }), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local dir = entry.value + actions.close(prompt_bufnr, false) + vim.fn.chdir(dir) + vim.cmd('e .') + vim.cmd("echon ''") + print('cwd: ' .. vim.fn.getcwd()) + end + end) + return true + end, + }) + :find() end function M.grep_notes() @@ -414,6 +449,21 @@ function M.find_notes() }) end +function M.find_books() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Books', + path_display = { 'smart' }, + search_dirs = { + '~/documents/books', + '~/books', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + function M.file_explorer() require('telescope.builtin').file_browser({ prompt_title = 'File Browser', @@ -469,13 +519,7 @@ local with_title = function(opts, extra) }, extra or {}) end ---vim.api.nvim_create_augroup('findhere', { clear = true }) ---vim.api.nvim_command('augroup findhere') ---vim.api.nvim_command('autocmd!') ---vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') ---vim.api.nvim_command('augroup END') - ---local findhere = function() +-- Find here function M.findhere() -- Open file browser if argument is a folder local arg = vim.api.nvim_eval('argv(0)') @@ -494,43 +538,48 @@ end -- Define the custom command findhere/startup vim.cmd('command! Findhere lua require("plugins.telescope").findhere()') --vim.cmd('command! Startup lua require("plugins.telescope").findhere()') - --vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') --- Merge the existing M table with the startup function table ---M = vim.tbl_extend('force', M, { findhere = findhere }) - --- Find project dirs +-- Find dirs function M.find_dirs() - local actions = require('telescope.actions') - local actions_set = require('telescope.actions.set') - local actions_state = require('telescope.actions.state') - local finders = require('telescope.finders') - local pickers = require('telescope.pickers') - local conf = require('telescope.config').values - local search_dir = '~/projects' + local root_dir = vim.fn.input('Enter the root directory: ') + + -- Check if root_dir is empty + if root_dir == '' then + print('No directory entered. Aborting.') + return + end + + local entries = {} + + -- Use vim.fn.expand() to get an absolute path + local root_path = vim.fn.expand(root_dir) + + local subdirs = vim.fn.readdir(root_path) + if subdirs then + for _, subdir in ipairs(subdirs) do + if vim.fn.isdirectory(root_path .. '/' .. subdir) == 1 then + table.insert(entries, subdir) + end + end + end pickers .new({}, { prompt_title = 'Change Directory', - finder = finders.new_oneshot_job({ - 'find', - vim.fn.expand(search_dir), - '-type', - 'd', - '-maxdepth', - '4', + finder = finders.new_table({ + results = entries, }), - previewer = require('telescope.previewers').vim_buffer_cat.new({}), - sorter = conf.generic_sorter({}), + previewer = config.file_previewer({}), + sorter = config.generic_sorter({}), attach_mappings = function(prompt_bufnr, map) actions_set.select:replace(function() local entry = actions_state.get_selected_entry() if entry ~= nil then - local dir = entry.value + local selected_subdir = entry.value actions.close(prompt_bufnr, false) - --vim.cmd('lcd ' .. vim.fn.fnameescape(dir)) - vim.fn.chdir(dir) + local selected_path = root_path .. '/' .. selected_subdir + vim.fn.chdir(selected_path) vim.cmd('e .') vim.cmd("echon ''") print('cwd: ' .. vim.fn.getcwd()) -- cgit v1.2.3 From 735603499289357e81d54a4e52338acd8f52a5af Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 8 Sep 2023 23:20:48 +0200 Subject: Changed some other mappings for telescope --- lua/user/keys.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 8739f71..ebafd21 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -286,16 +286,16 @@ map('n', 'fr', "lua require('telescope.builtin').registers({})" map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications map('n', 'fs', 'lua require("session-lens").search_session()') +map('n', 'ffd', [[lua require'plugins.telescope'.find_dirs()]]) -- find dies map('n', 'ff.', [[lua require'plugins.telescope'.find_configs()]]) -- find configs map('n', 'ffs', [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts map('n', 'ffw', [[lua require'plugins.telescope'.find_projects()]]) -- find projects -map('n', 'ffp', [[lua require'plugins.telescope'.find_dirs()]]) -- find projects +map('n', 'ffb', [[lua require'plugins.telescope'.find_books()]]) -- find books map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes map('n', 'ffr', "lua require('telescope').extensions.recent_files.pick()") map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") -map('n', 'ffb', "lua require('telescope').extensions.file_browser.file_browser()") ---map('n', 'ffp', "lua require('telescope').extensions.projects.projects()") +map('n', 'f/', "lua require('telescope').extensions.file_browser.file_browser()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- Map a shortcut to open the picker. -- cgit v1.2.3 From ab87d15133f36859c3553f88381af65cecdffe81 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 8 Sep 2023 23:21:07 +0200 Subject: Changed maxdepth for find_projects --- lua/plugins/telescope.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 123f676..0167aa3 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -398,7 +398,7 @@ function M.find_projects() '-type', 'd', '-maxdepth', - '4', + '1', }), previewer = require('telescope.previewers').vim_buffer_cat.new({}), sorter = config.generic_sorter({}), -- cgit v1.2.3 From a1ff7aec8c360404a40d7cdae2cd0a460068ab8a Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 9 Sep 2023 22:44:28 +0200 Subject: Updated colors --- lua/plugins/nvim-tree.lua | 53 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index f29cf83..cab6f1b 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -6,7 +6,7 @@ --- To see default mappings `:nvim-tree-default-mappings` local icons = { - --webdev_colors = true, + webdev_colors = true, git_placement = 'signcolumn', modified_placement = 'after', padding = ' ', @@ -187,12 +187,12 @@ end --end) require('nvim-tree').setup({ - auto_reload_on_write = true, - create_in_closed_folder = false, - hijack_cursor = true, - disable_netrw = true, - hijack_netrw = true, - hijack_unnamed_buffer_when_opening = false, + --auto_reload_on_write = true, + --create_in_closed_folder = false, + --hijack_cursor = true, + --disable_netrw = true, + --hijack_netrw = true, + --hijack_unnamed_buffer_when_opening = false, --ignore_buffer_on_setup = false, update_focused_file = { enable = true, @@ -201,7 +201,7 @@ require('nvim-tree').setup({ ignore_list = {}, }, root_dirs = {}, - prefer_startup_root = true, + --prefer_startup_root = true, --hijack_directories = { -- enable = false, --}, @@ -235,13 +235,13 @@ require('nvim-tree').setup({ show_on_dirs = true, show_on_open_dirs = true, }, - filters = { - dotfiles = false, - git_clean = false, - no_buffer = false, - custom = {}, - exclude = {}, - }, + --filters = { + -- dotfiles = false, + -- git_clean = false, + -- no_buffer = false, + -- custom = {}, + -- exclude = {}, + --}, actions = { use_system_clipboard = true, change_dir = { @@ -253,8 +253,8 @@ require('nvim-tree').setup({ close_window = true, }, open_file = { - quit_on_open = false, - eject = true, + quit_on_open = true, + --eject = true, resize_window = false, window_picker = { enable = true, @@ -350,16 +350,17 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { }) -- Highlight Groups -vim.api.nvim_command('highlight NvimTreeNormal guibg=none') -vim.api.nvim_command('highlight NvimTreeNormalFloat guibg=none') -vim.api.nvim_command('highlight NvimTreeEndOfBuffer guibg=none') --(NonText) +vim.api.nvim_command('highlight NvimTreeNormal guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeNormalNC guibg=NONE ctermbg=NONE guifg=NONE') +vim.api.nvim_command('highlight NvimTreeNormalFloat guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeEndOfBuffer guibg=NONE ctermbg=NONE') --(NonText) vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') -vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2') -vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2') -vim.api.nvim_command('highlight NvimTreeRootFolder guifg=#f8f8f2') -vim.api.nvim_command('highlight NvimTreeEmptyFolderName guifg=#f8f8f2') --(Directory) -vim.api.nvim_command('highlight NvimTreeOpenedFolderName guifg=#f8f8f2') --(Directory) -vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=#000000') +vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeRootFolder guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeEmptyFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=NONE ctermbg=NONE') --vim.api.nvim_command("highlight NvimTreeSymlink ") --vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) -- cgit v1.2.3 From 4c65c248c28796da222323b6ea528136d75f459a Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 9 Sep 2023 22:45:07 +0200 Subject: Autocommand for backticks --- after/ftplugin/markdown.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua index 5bf3f16..718a871 100644 --- a/after/ftplugin/markdown.lua +++ b/after/ftplugin/markdown.lua @@ -9,3 +9,8 @@ vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. vim.b[0].undo_ftplugin = "setlocal nospell nowrap nolinebreak nobreakindent conceallevel=0" + +vim.cmd([[ + autocmd FileType markdown iabbrev `` `` +]]) + -- cgit v1.2.3 From e660a7e259d13136bc42e0ea2675a8df4609d68b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 9 Sep 2023 22:45:39 +0200 Subject: Don't autoclose markdown preview when changing buffers --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 95faf05..2f3e1e8 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -354,6 +354,7 @@ return packer.startup(function(use) run = function() vim.fn['mkdp#util#install']() end, + vim.cmd("let g:mkdp_auto_close = 0"), }) use({ 'ellisonleao/glow.nvim', -- Markdown Preview -- cgit v1.2.3 From 38ec7c480730e3f83322fa34a6a4ff700ca503d9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 9 Sep 2023 22:45:59 +0200 Subject: Fixed nvim-tree not being transparent --- init.lua | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/init.lua b/init.lua index ac05023..d1f9911 100644 --- a/init.lua +++ b/init.lua @@ -137,7 +137,7 @@ vim.g.do_filetype_lua = 1 vim.g.did_load_filetypes = 0 -- Snippets -vim.g.snippets = 'luasnip' +--vim.g.snippets = 'luasnip' -- Notifications vim.notify = require('notify') -- Requires plugin "rcarriga/nvim-notify" @@ -150,8 +150,18 @@ vim.opt.termguicolors = true -- Available colorschemes: -- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] +require('tokyonight').setup({ + style = 'night', + transparent = true, + transparent_sidebar = true, + styles = { + sidebars = 'transparent', + floats = 'transparent', + }, +}) + -- Define default color scheme -local default_colorscheme = 'tokyonight-night' +local default_colorscheme = 'tokyonight' local fallback_colorscheme = 'desert' -- Attempt to set the default color scheme @@ -163,22 +173,23 @@ if not status_ok then end vim.api.nvim_command('syntax on') -vim.api.nvim_command('highlight Normal guibg=none') -vim.api.nvim_command('highlight NormalNC guibg=none') -vim.api.nvim_command('highlight SignColumn guibg=none') -vim.api.nvim_command('highlight FoldColumn guibg=none') -vim.api.nvim_command('highlight CursorLineSign guibg=none ctermbg=NONE') +vim.api.nvim_command('highlight Normal guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NonText guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NormalNC guibg=NONE') +vim.api.nvim_command('highlight SignColumn guibg=NONE') +vim.api.nvim_command('highlight FoldColumn guibg=NONE') +vim.api.nvim_command('highlight CursorLineSign guibg=NONE ctermbg=NONE') vim.api.nvim_command('highlight TabLine guibg=#333842 gui=bold') -vim.api.nvim_command('highlight Title guibg=none gui=bold') +vim.api.nvim_command('highlight Title guibg=NONE gui=bold') vim.api.nvim_command('highlight TabLineSel guibg=#333842 gui=bold') -vim.api.nvim_command('highlight TabLineFill guibg=none gui=bold') -vim.api.nvim_command('highlight WinBar guibg=none gui=bold') -vim.api.nvim_command('highlight NormalFloat guibg=none') -vim.api.nvim_command('highlight LineNr guibg=none') -vim.api.nvim_command('highlight WinSeparator guibg=none gui=bold') -vim.api.nvim_command('highlight MsgSeparator guibg=none') -vim.api.nvim_command('highlight PmenuSel guibg=none') -vim.api.nvim_command('highlight winblend guibg=none') +vim.api.nvim_command('highlight TabLineFill guibg=NONE gui=bold') +vim.api.nvim_command('highlight WinBar guibg=NONE gui=bold') +vim.api.nvim_command('highlight NormalFloat guibg=NONE') +vim.api.nvim_command('highlight LineNr guibg=NONE') +vim.api.nvim_command('highlight WinSeparator guibg=NONE gui=bold') +vim.api.nvim_command('highlight MsgSeparator guibg=NONE') +vim.api.nvim_command('highlight PmenuSel guibg=NONE') +vim.api.nvim_command('highlight winblend guibg=NONE') vim.api.nvim_command('highlight EndOfBuffer guibg=NONE guifg=Normal') -- Set different window separator colorscheme -- cgit v1.2.3