diff options
| -rw-r--r-- | .config/nvim/.gitignore | 1 | ||||
| -rw-r--r-- | .config/nvim/init.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/autopairs.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/dashboard.lua | 30 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/goto-preview.lua | 18 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 20 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/null-ls.lua | 249 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/telescope.lua | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/toggleterm.lua | 26 | ||||
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 40 | ||||
| -rw-r--r-- | .config/nvim/lua/user/opts.lua | 46 | ||||
| -rw-r--r-- | .config/nvim/lua/user/pack.lua | 18 |
12 files changed, 330 insertions, 132 deletions
diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore index 308d183..e890cff 100644 --- a/.config/nvim/.gitignore +++ b/.config/nvim/.gitignore @@ -1,2 +1,3 @@ plugin/packer_compiled.lua startup.log +tmp diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index c2dff0a..ec29d65 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -26,10 +26,10 @@ -- -------------------------------------------------------------------------- -- --- Initialize config with this one liner in the terminal (use in commandline) +-- Initialize config with this one liner in the terminal --nvim --headless -c 'call mkdir(stdpath("config"), "p") | exe "edit" stdpath("config") . "/init.lua" | write | quit' --- See startup time (use in commandline) +-- Command to see startup time --nvim --startuptime startup.log -c exit && tail -100 startup.log -- Load impatient (Faster loading times) @@ -68,6 +68,7 @@ local modules = { "plugins.neoscroll", "plugins.null-ls", "plugins.lsp", + "plugins.goto-preview", "plugins.autopairs", "plugins.web-devicons", "plugins.navic", diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua index fc39d2e..90c6d35 100644 --- a/.config/nvim/lua/plugins/autopairs.lua +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -1,4 +1,3 @@ --- Setup nvim-cmp. local status_ok, npairs = pcall(require, "nvim-autopairs") if not status_ok then return @@ -18,9 +17,9 @@ npairs.setup { disable_filetype = { "TelescopePrompt", "spectre_panel" }, disable_in_macro = true, disable_in_visualblock = true, - enalbe_moveright = true, + enable_moveright = true, enable_afterquote = true, -- add bracket pairs after quote - enable_check_bracket_line = true, --- check bracket in same line + enable_check_bracket_line = false, --- check bracket in same line enable_bracket_in_quote = true, -- break_undo = true, -- switch for basic rule break undo sequence fast_wrap = { diff --git a/.config/nvim/lua/plugins/dashboard.lua b/.config/nvim/lua/plugins/dashboard.lua index dd50c65..c6c610d 100644 --- a/.config/nvim/lua/plugins/dashboard.lua +++ b/.config/nvim/lua/plugins/dashboard.lua @@ -20,25 +20,43 @@ db.setup({ }, disable_move = false, shortcut = { - { desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, + { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, { desc = " Files", - group = "Label", + group = "Number", + --group = "Label", action = "Telescope find_files", key = "f", }, { - desc = " Text", - group = "DiagnosticHint", - action = "Telescope live_grep", + desc = " Text", + group = "Number", + --group = "Label", + action = 'enew', key = "t", }, { + desc = " Grep", + group = "Number", + --group = "Label", + action = "Telescope live_grep", + key = "g", + }, + { desc = " Scheme", - group = "Number", + group = "Number", + --group = "Label", action = "Telescope colorscheme", key = "s", }, + { + desc = ' Config', + group = "Number", + --group = "Label", + action = ':edit ~/.config.nvim/init.lua', + key = "c", + }, }, }, hide = { diff --git a/.config/nvim/lua/plugins/goto-preview.lua b/.config/nvim/lua/plugins/goto-preview.lua new file mode 100644 index 0000000..d4d2c67 --- /dev/null +++ b/.config/nvim/lua/plugins/goto-preview.lua @@ -0,0 +1,18 @@ +require('goto-preview').setup { + width = 120; -- Width of the floating window + height = 15; -- Height of the floating window + border = {"↖", "─" ,"┐", "│", "┘", "─", "└", "│"}; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + telescope = require("telescope.themes").get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 7962308..855818f 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -48,20 +48,23 @@ local on_attach = function(client, bufnr) opts.buffer = bufnr keymap.set(mode, l, r, opts) end - -- Mappings map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>") - map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>") - map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>") - map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>") + --map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>") + map("n", "gd", "<cmd>lua require('goto-preview').goto_preview_definition()<CR>") + --map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>") + map("n", "gi", "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>") + --map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>") + map("n", "gr", "<cmd>lua require('goto-preview').goto_preview_references()<CR>") map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. map("n", "<leader>k", "<Cmd>lua vim.lsp.buf.signature_help()<CR>") - map("n", "gt", "<Cmd>lua vim.lsp.buf.type_definition()<CR>") + --map("n", "gt", "<Cmd>lua vim.lsp.buf.type_definition()<CR>") + map("n", "gt", "<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>") map("n", "gn", "<Cmd>lua vim.lsp.buf.rename()<CR>") map("n", "ga", "<Cmd>lua vim.lsp.buf.code_action()<CR>") map("n", "gf", "<Cmd>lua vim.lsp.buf.formatting()<CR>") - --map("n", "go", "<Cmd>lua vim.diagnostic.open_float()<CR>") - map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") + map("n", "go", "<Cmd>lua vim.diagnostic.open_float()<CR>") + map("n", "<leader>go", ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") map("n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>") map("n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>") map("n", "gs", "<Cmd>lua vim.lsp.buf.document_symbol()<CR>") @@ -297,11 +300,12 @@ vim.diagnostic.config({ underline = false, signs = true, virtual_text = false, + virtual_lines = { only_current_line = true }, float = { show_header = true, source = 'if_many', border = 'rounded', - focusable = false, + focusable = true, }, update_in_insert = false, -- default to false severity_sort = false, -- default to false diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/null-ls.lua index b96d883..8e7ddd7 100644 --- a/.config/nvim/lua/plugins/null-ls.lua +++ b/.config/nvim/lua/plugins/null-ls.lua @@ -2,89 +2,174 @@ -- -- null-language-server i.e. a sort of language server which does not provide any services such as formatting and diagnostics you expect from a language server. Instead it will need to install corresponding external “sources” and then hook these sources into the neovim lsp client through null-ls. -- -require("null-ls").setup({ - --debug = true, - disabled_filetypes = { "PKGBUILD" }, - timeout_ms = 5000, - --async = true, - debounce = 150, - log = { - enable = true, - level = 'warn', - use_console = 'async', +local null_ls = require "null-ls" +local builtins = null_ls.builtins + +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, +} + +local sources = { + builtins.formatting.stylua, + 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.clang_format, + builtins.formatting.rustfmt, + builtins.formatting.sql_formatter, + builtins.formatting.prettierd.with { + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", "css", "scss", "less", "graphql", "vue", "svelte" }, + condition = function(utils) + return utils.root_has_file ".prettierrc" or utils.root_has_file ".prettierrc.js" or utils.root_has_file ".prettierrc.json" or utils.root_has_file "prettier.config.js" or utils.root_has_file "prettier.config.cjs" + end, }, - update_in_insert = false, - --fallback_severity = vim.diagnostic.severity.ERROR, - --log_level = "warn", - --on_attach = nil, - --on_init = nil, - --on_exit = nil, - sources = { - --require("null-ls").builtins.formatting.shfmt, -- shell script formatting - require("null-ls").builtins.diagnostics.dotenv_linter, - --require("null-ls").builtins.diagnostics.editorconfig_checker, - require("null-ls").builtins.formatting.shfmt.with({ - filetypes = { "bash", "zsh", "sh" }, - extra_args = { "-i", "2", "-ci" }, - }), - require("null-ls").builtins.formatting.prettier, -- markdown formatting - --require("null-ls").builtins.diagnostics.shellcheck, -- shell script diagnostics - require("null-ls").builtins.diagnostics.shellcheck.with({ - 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 - }), --- require("null-ls").builtins.formatting.stylua, -- lua formatting --- require("null-ls").builtins.formatting.prettier.with({ -- markdown, html/js formatting --- filetypes = { "html", "css", "javascript", "javascriptreact", "markdown", "json", "yaml" }, --- }), --- require("null-ls").builtins.formatting.black, --- require("null-ls").builtins.formatting.prettierd, --- require("null-ls").builtins.diagnostics.cspell.with { --- filetypes = { "python", "rust", "typescript" }, --- }, --- --require("null-ls").builtins.diagnostics.luacheck, --- --require("null-ls").builtins.diagnostics.eslint, --- --require("null-ls").builtins.diagnostics.eslint_d, --- require("null-ls").builtins.diagnostics.mdl, --- require("null-ls").builtins.diagnostics.vint, --- require("null-ls").builtins.completion.spell, + + 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.eslint_d.with(eslint_opts), + builtins.diagnostics.todo_comments, + builtins.diagnostics.vint, + + builtins.code_actions.shellcheck, -- shell script code actions + builtins.code_actions.eslint_d.with(eslint_opts), + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, + builtins.hover.dictionary, + builtins.hover.printenv, +} + +local M = {} + +M.setup = function(on_attach) + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + + null_ls.setup { + sources = sources, + debug = false, + on_attach = function(client, bufnr) + on_attach(client, bufnr) + -- Format on save + -- vim.cmd [[autocmd BufWritePost <buffer> lua vim.lsp.buf.formatting()]] + + -- 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() + -- -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead + -- vim.lsp.buf.format { bufnr = bufnr } + -- end, + -- }) + -- end + end, + } +end + +return M + +--require("null-ls").setup({ +-- --debug = true, +-- disabled_filetypes = { "PKGBUILD" }, +-- timeout_ms = 5000, +-- async = true, +-- debounce = 150, +-- --log = { +-- -- enable = true, +-- -- level = 'warn', +-- -- use_console = 'async', +-- --}, +-- update_in_insert = false, +-- --fallback_severity = vim.diagnostic.severity.ERROR, +-- --log_level = "warn", +-- --on_attach = nil, +-- --on_init = nil, +-- --on_exit = nil, +-- sources = { +-- --require("null-ls").builtins.formatting.shfmt, -- shell script formatting +-- require("null-ls").builtins.diagnostics.dotenv_linter, +-- --require("null-ls").builtins.diagnostics.editorconfig_checker, +-- require("null-ls").builtins.formatting.shfmt.with({ +-- filetypes = { "bash", "zsh", "sh" }, +-- extra_args = { "-i", "2", "-ci" }, +-- }), +-- require("null-ls").builtins.formatting.prettier, -- markdown formatting +-- --require("null-ls").builtins.diagnostics.shellcheck, -- shell script diagnostics +-- require("null-ls").builtins.diagnostics.shellcheck.with({ +-- 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 +-- }), +---- require("null-ls").builtins.formatting.stylua, -- lua formatting +---- require("null-ls").builtins.formatting.prettier.with({ -- markdown, html/js formatting +---- filetypes = { "html", "css", "javascript", "javascriptreact", "markdown", "json", "yaml" }, +---- }), +---- require("null-ls").builtins.formatting.black, +---- require("null-ls").builtins.formatting.prettierd, +---- require("null-ls").builtins.diagnostics.cspell.with { +---- filetypes = { "python", "rust", "typescript" }, +---- }, +---- --require("null-ls").builtins.diagnostics.luacheck, +---- --require("null-ls").builtins.diagnostics.eslint, +---- --require("null-ls").builtins.diagnostics.eslint_d, +---- require("null-ls").builtins.diagnostics.mdl, +---- require("null-ls").builtins.diagnostics.vint, +---- require("null-ls").builtins.completion.spell, +---- require("null-ls").builtins.formatting.clang_format, +---- require("null-ls").builtins.formatting.rustfmt, +---- require("null-ls").builtins.formatting.sql_formatter, +---- --require("null-ls").builtins.formatting.google_java_format, +---- require("null-ls").builtins.diagnostics.cppcheck, +-- require("null-ls").builtins.formatting.shellharden, +---- --require("null-ls").builtins.code_actions.eslint_d, +-- require("null-ls").builtins.code_actions.shellcheck, -- shell script code actions -- require("null-ls").builtins.formatting.clang_format, -- require("null-ls").builtins.formatting.rustfmt, +-- --require("null-ls").builtins.formatting.beautysh, -- require("null-ls").builtins.formatting.sql_formatter, --- --require("null-ls").builtins.formatting.google_java_format, --- require("null-ls").builtins.diagnostics.cppcheck, - require("null-ls").builtins.formatting.shellharden, --- --require("null-ls").builtins.code_actions.eslint_d, - require("null-ls").builtins.code_actions.shellcheck, -- shell script code actions - require("null-ls").builtins.formatting.clang_format, - require("null-ls").builtins.formatting.rustfmt, - --require("null-ls").builtins.formatting.beautysh, - require("null-ls").builtins.formatting.sql_formatter, - require("null-ls").builtins.diagnostics.todo_comments, - --require("null-ls").builtins.diagnostics.zsh, - require("null-ls").builtins.hover.dictionary, - require("null-ls").builtins.hover.printenv, - }, - -- default_timeout = 5000, - -- diagnostics_format = '[#{c}] #{m} (#{s})', - -- fallback_severity = vim.diagnostic.severity.ERROR, - -- log = { - -- enable = true, - -- level = 'warn', - -- use_console = 'async', - -- }, - --on_attach = nil, - --on_init = nil, - --on_exit = nil, - --update_in_insert = false, - --update_in_leave = false, -}) +-- require("null-ls").builtins.diagnostics.todo_comments, +-- --require("null-ls").builtins.diagnostics.zsh, +-- require("null-ls").builtins.hover.dictionary, +-- require("null-ls").builtins.hover.printenv, +-- }, +-- -- default_timeout = 5000, +-- -- diagnostics_format = '[#{c}] #{m} (#{s})', +-- -- fallback_severity = vim.diagnostic.severity.ERROR, +-- -- log = { +-- -- enable = true, +-- -- level = 'warn', +-- -- use_console = 'async', +-- -- }, +-- --on_attach = nil, +-- --on_init = nil, +-- --on_exit = nil, +-- --update_in_insert = false, +-- --update_in_leave = false, +--}) diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 6cd41ae..95a5dd6 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -281,6 +281,7 @@ function M.find_configs() "~/.config/bspwm", "~/.config/sxhkd", "~/.config/picom", + "~/.bashrc", }, -- cwd = "~/.config/nvim/", file_ignore_patterns = { @@ -300,7 +301,8 @@ end function M.find_scripts() require("telescope.builtin").find_files { hidden = true, - prompt_title = " Find Notes", + no_ignore = true, + prompt_title = " Find Scripts", path_display = { "smart" }, search_dirs = { "~/.local/bin/scripts", diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua index 5875fc6..a9bd450 100644 --- a/.config/nvim/lua/plugins/toggleterm.lua +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -2,7 +2,6 @@ local status_ok, toggleterm = pcall(require, "toggleterm") if not status_ok then return end - toggleterm.setup({ --size = function(term) -- if term.direction == "horizontal" then @@ -13,6 +12,7 @@ toggleterm.setup({ --end, --size = 20, open_mapping = [[<leader>tt]], + --autochdir = true, hide_numbers = true, shade_filetypes = {}, shade_terminals = false, @@ -77,12 +77,11 @@ end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') ---vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") - local Terminal = require("toggleterm.terminal").Terminal local lazygit = Terminal:new({ cmd = "lazygit", count = 5, + id = 1000, dir = "git_dir", direction = "float", on_open = float_handler, @@ -92,6 +91,7 @@ local lazygit = Terminal:new({ width = 150, height = 40 }, + ---- Function to run on opening the terminal --on_open = function(term) -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', '<cmd>close<CR>', @@ -108,7 +108,25 @@ local lazygit = Terminal:new({ }) function Lazygit_toggle() - lazygit:toggle() + -- cwd is the root of project. if cwd is changed, change the git. + local cwd = vim.fn.getcwd() + if cwd ~= Cur_cwd then + Cur_cwd = cwd + lazygit:close() + lazygit = Terminal:new({ + cmd = "lazygit", + dir = "git_dir", + direction = "float", + hidden = true, + on_open = float_handler, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40 + }, + }) + end + lazygit:toggle() end local node = Terminal:new({ cmd = "node", hidden = true }) diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua index c957e05..689ff13 100644 --- a/.config/nvim/lua/user/keys.lua +++ b/.config/nvim/lua/user/keys.lua @@ -29,6 +29,22 @@ map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nv --------------- Extended Operations --------------- +-- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros +map('n', 'q', function() + local config = vim.api.nvim_win_get_config(0) + if config.relative ~= "" then -- is_floating_window? + return ":silent! close!<CR>" + elseif + vim.o.buftype == 'quickfix' then + return ":quit<CR>" + elseif + vim.o.buftype == 'help' then + return ":close<CR>" + else + return "q" + end +end, {expr = true, replace_keycodes = true}) + -- Combine buffers list with buffer name map("n", "<Leader>b", ":buffers<CR>:buffer<Space>") @@ -43,6 +59,17 @@ map("n", "<leader>d", ":bd<cr>") -- List marks map("n", "<Leader>m", ":marks<CR>") +-- Messages +map("n", "<Leader>M", ":messages<CR>") + +-- Clear messages + +-- Clear messages or just refresh/redraw the screen +map("n", "<leader>u", ":echo '' | redraw<CR>") + +-- Unsets the 'last search pattern' register by hitting return +--map("n", "<CR>", "!silent :noh<CR><CR>") + -- Toggle set number map("n", "<leader>$", ":NumbersToggle<CR>") map("n", "<leader>%", ":NumbersOnOff<CR>") @@ -125,6 +152,9 @@ map("n", "<A-j>", ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>') -- Search and replace map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') +-- Toggle Diff +map("n", "<leader>dt", "<Cmd>call utils#ToggleDiff()<CR>") + -- Map delete to Ctrl+l map("i", "<C-l>", "<Del>") @@ -141,18 +171,12 @@ map("v", "p", '"_dP') -- visual mode to select text to swap with map("v", "<C-X>", "<Esc>`.``gvP``P") --- Clear messages or just refresh/redraw the screen -map("n", "<leader>u", ":echo '' | redraw<CR>") - -- Change Working Directory to current project map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>") -- Open the current file in the default program (on Mac this should just be just `open`) map('n', '<leader>o', ':!xdg-open %<cr><cr>') --- Unsets the 'last search pattern' register by hitting return ---map("n", "<CR>", "!silent :noh<CR><CR>") - -- Toggle completion map("n", "<Leader>tc", ":lua require('user.mods').toggle_completion()<CR>") @@ -309,3 +333,7 @@ end, { desc = "Toggle quickfix window" }) -- Dashboard map("n", "<leader>db", "<CMD>Dashboard<CR>") + +-- +map("", "<Leader>l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) + diff --git a/.config/nvim/lua/user/opts.lua b/.config/nvim/lua/user/opts.lua index c1b5027..78a84a4 100644 --- a/.config/nvim/lua/user/opts.lua +++ b/.config/nvim/lua/user/opts.lua @@ -43,7 +43,7 @@ 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 ---vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- +--vim.o.writeany= true -- Colors vim.opt.termguicolors = true @@ -122,11 +122,23 @@ vim.opt.report = 0 -- Always report changed lines. ---- it'll get replaced by the default stline). --vim.opt.stl = " " --- Backup/undo +-- Backup/undo/swap +local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") +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.noswapfile = true -- ---vim.opt.undofile = true -- -vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" } -- +vim.opt.undofile = false -- +vim.opt.swapfile = true -- +-- 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 = '*', + callback = function() + vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') + end, +}) -- Format --vim.opt.textwidth = 80 -- @@ -154,7 +166,7 @@ vim.opt.wrapscan = true -- " Searches wrap around end-of-file. --vim.opt.foldmethod = "expr" -- vim.opt.foldmethod = "manual" vim.opt.foldlevel = 3 -vim.opt.confirm = true +vim.opt.confirm = false vim.opt.shortmess:append("sI") --vim.opt.shortmess = "a" --vim.opt.shortmess = "sI" @@ -226,7 +238,11 @@ 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 = "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" }) +vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup -- Cursorline vim.cmd([[ " Only show cursorline in the current window and in normal mode augroup cline @@ -248,12 +264,12 @@ vim.cmd([[ " Only show in insert mode ]]) -- Line Return ---vim.cmd([[ " Return to the same line when we reopen a file --- augroup line_return --- au! --- au BufReadPost * --- \ if line("'\"") > 0 && line("'\"") <= line("$") | --- \ execute 'normal! g`"zvzz' | --- \ endif --- augroup END ---]]) +vim.cmd([[ " Return to the same line when we reopen a file + augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif + augroup END +]]) diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua index 957fac8..0bcb006 100644 --- a/.config/nvim/lua/user/pack.lua +++ b/.config/nvim/lua/user/pack.lua @@ -65,6 +65,13 @@ return packer.startup(function(use) use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together use("neovim/nvim-lspconfig") -- Collection of LSP configs + use({ + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + end, + }) + use("rmagatti/goto-preview") -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim @@ -72,7 +79,7 @@ return packer.startup(function(use) use("gabrielpoca/replacer.nvim") -- Linters/Formatters - use("jayp0521/mason-null-ls.nvim") + use("jay-babu/mason-null-ls.nvim") --use({"jayp0521/mason-null-ls.nvim", -- config = function() -- require('mason-null-ls.nvim').setup({ @@ -82,7 +89,7 @@ return packer.startup(function(use) --}) use({ "jose-elias-alvarez/null-ls.nvim", -- Provides LSP: linters, formatters, diagnostics, code actions and etc... - requires = { "jayp0521/mason-null-ls.nvim" }, + requires = { "jay-babu/mason-null-ls.nvim" }, }) -- Completion @@ -111,6 +118,7 @@ return packer.startup(function(use) -- File explorer/fuzzy finder 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-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm use("nvim-telescope/telescope-ui-select.nvim") -- @@ -208,10 +216,10 @@ return packer.startup(function(use) use({ "kosayoda/nvim-lightbulb", -- requires = "antoinemadec/FixCursorHold.nvim", }) - use({ + 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 requires = 'kyazdani42/nvim-web-devicons', |
