From e8279efeb6a61f7876cc9895493a3280f83f741c Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 11 Oct 2022 07:40:50 +0200 Subject: [PATCH] feat(nvim): clueless. --- dot_config/nvim/dot_stylua.toml | 7 + dot_config/nvim/init.lua | 46 +- dot_config/nvim/lua/config/barbar.lua | 38 - dot_config/nvim/lua/config/bufferline.lua | 40 ++ dot_config/nvim/lua/config/catppuccin.lua | 145 ++-- dot_config/nvim/lua/config/colorizer.lua | 26 + dot_config/nvim/lua/config/dashboard.lua | 128 ++-- dot_config/nvim/lua/config/feline.lua | 84 +-- dot_config/nvim/lua/config/gitsigns.lua | 122 ++-- dot_config/nvim/lua/config/lspsaga.lua | 16 +- dot_config/nvim/lua/config/presence.lua | 195 +++--- dot_config/nvim/lua/config/treesitter.lua | 106 ++- dot_config/nvim/lua/lsp.lua | 284 ++++---- dot_config/nvim/lua/plugins.lua | 807 ++++++++++------------ dot_config/nvim/lua/utils.lua | 14 +- 15 files changed, 1003 insertions(+), 1055 deletions(-) create mode 100644 dot_config/nvim/dot_stylua.toml delete mode 100644 dot_config/nvim/lua/config/barbar.lua create mode 100644 dot_config/nvim/lua/config/bufferline.lua create mode 100644 dot_config/nvim/lua/config/colorizer.lua diff --git a/dot_config/nvim/dot_stylua.toml b/dot_config/nvim/dot_stylua.toml new file mode 100644 index 0000000..4d49284 --- /dev/null +++ b/dot_config/nvim/dot_stylua.toml @@ -0,0 +1,7 @@ +column_width = 80 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +collapse_simple_statement = "Never" +call_parentheses = "Always" diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index b022ffb..01cd22c 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -34,6 +34,12 @@ Nmap("", "j") Nmap("", "k") Nmap("", "l") Nmap("", "h") + +-- merge conflicts +Nmap("gd", ":Gvdiff!") +Nmap("gdh", ":diffget //2") +Nmap("gdl", ":diffget //3") + -- escape :terminal easier vim.cmd([[tnoremap ]]) @@ -45,9 +51,9 @@ vim.o.expandtab = true -- indentation autocmds for some filetypes vim.cmd([[ " smol spaces for soydev -autocmd FileType html,css,js,jsreact,ts,tsreact,json,yaml setlocal ts=2 sw=2 sts=0 et +autocmd FileType html,lua,css,js,jsreact,ts,tsreact,json,yaml setlocal ts=2 sw=2 sts=0 et " Tabs, yikes -autocmd FileType go,lua setlocal ts=4 sw=4 sts=4 noet +autocmd FileType go setlocal ts=4 sw=4 sts=4 noet " Spaces, based languages autocmd FileType python,rust setlocal ts=4 sw=4 sts=4 et autocmd FileType markdown let g:table_mode_corner='|' @@ -55,22 +61,32 @@ autocmd FileType markdown let g:table_mode_corner='|' -- auto-compile when lua files in `~/.config/nvim/*` change vim.api.nvim_create_autocmd("BufWritePost", { - pattern = "*.lua", - callback = function() - local cfg_path = vim.fn.resolve(vim.fn.stdpath("config")) - vim.defer_fn(function() - if vim.fn.expand("%:p"):match(cfg_path) then - vim.cmd("silent! PackerCompile") - end - end, 0) - end, + pattern = "*.lua", + callback = function() + local cfg_path = vim.fn.resolve(vim.fn.stdpath("config")) + vim.defer_fn(function() + if vim.fn.expand("%:p"):match(cfg_path) then + vim.cmd("silent! PackerCompile") + end + end, 0) + end, +}) + +local wr_group = vim.api.nvim_create_augroup("WinResize", { clear = true }) + +-- resize splits when vim window is resized +vim.api.nvim_create_autocmd("VimResized", { + group = wr_group, + pattern = "*", + command = "wincmd =", + desc = "Automatically resize windows when the host window size changes.", }) -- neovide settings {{{ if vim.g.neovide then - vim.cmd("cd $HOME") - vim.g.neovide_cursor_vfx_mode = "ripple" - vim.g.neovide_input_macos_alt_is_meta = true - vim.o.guifont = "VictorMono Nerd Font:h18" + vim.cmd("cd $HOME") + vim.g.neovide_cursor_vfx_mode = "ripple" + vim.g.neovide_input_macos_alt_is_meta = true + vim.o.guifont = "VictorMono Nerd Font:h18" end -- }}} diff --git a/dot_config/nvim/lua/config/barbar.lua b/dot_config/nvim/lua/config/barbar.lua deleted file mode 100644 index d079aa9..0000000 --- a/dot_config/nvim/lua/config/barbar.lua +++ /dev/null @@ -1,38 +0,0 @@ -require("bufferline").setup({ - closable = false, - icons = "both", - insert_at_end = true, - no_name_title = "", -}) - --- hop between buffers in order of the bar -Nmap("", "BufferPrevious") -Nmap("", "BufferNext") --- Re-order to previous/next -Nmap("", "BufferMovePrevious") -Nmap(">", "BufferMoveNext") --- Goto buffer in position... -Nmap("", "BufferGoto 1") -Nmap("", "BufferGoto 2") -Nmap("", "BufferGoto 3") -Nmap("", "BufferGoto 4") -Nmap("", "BufferGoto 5") -Nmap("", "BufferGoto 6") -Nmap("", "BufferGoto 7") -Nmap("", "BufferGoto 8") -Nmap("", "BufferGoto 9") -Nmap("", "BufferLast") --- Pin/unpin buffer -Nmap("", "BufferPin") --- Close buffer -Nmap("", "BufferClose") -Nmap("", "BufferClose!") --- create new buffer -Nmap("", "enew") --- pick buffer -Nmap("", "BufferPick") --- Sort automatically by... -Nmap("bb", "BufferOrderByBufferNumber") -Nmap("bd", "BufferOrderByDirectory") -Nmap("bl", "BufferOrderByLanguage") -Nmap("bw", "BufferOrderByWindowNumber") diff --git a/dot_config/nvim/lua/config/bufferline.lua b/dot_config/nvim/lua/config/bufferline.lua new file mode 100644 index 0000000..6a3ce47 --- /dev/null +++ b/dot_config/nvim/lua/config/bufferline.lua @@ -0,0 +1,40 @@ +require("bufferline").setup({ + options = { + show_close_icon = false, + separator_style = "slant", + close_icon = "", + offsets = { { filetype = "NvimTree" } }, + left_mouse_command = "buffer %d", + middle_mouse_command = "bdelete! %d", + right_mouse_command = nil, + }, +}) +-- hop between buffers in order of the bar +Nmap("", "BufferLineCyclePrev") +Nmap("", "BufferLineCycleNext") +-- Re-order to previous/next +Nmap("", "BufferLineMovePrev") +Nmap(">", "BufferLineMoveNext") +-- Goto buffer in position... +Nmap("", "BufferLineGoToBuffer 1") +Nmap("", "BufferLineGoToBuffer 2") +Nmap("", "BufferLineGoToBuffer 3") +Nmap("", "BufferLineGoToBuffer 4") +Nmap("", "BufferLineGoToBuffer 5") +Nmap("", "BufferLineGoToBuffer 6") +Nmap("", "BufferLineGoToBuffer 7") +Nmap("", "BufferLineGoToBuffer 8") +Nmap("", "BufferLineGoToBuffer 9") +Nmap("", "BufferLineGoToBuffer -1") +-- Pin/unpin buffer +Nmap("", "BufferLineTogglePin") +-- Close buffer +Nmap("", "bdelete") +Nmap("", "bdelete!") +-- create new buffer +Nmap("", "enew") +-- pick buffer +Nmap("", "BufferLinePick") +-- Sort automatically by... +Nmap("bd", "BufferLineSortByDirectory") +Nmap("bl", "BufferLineSortByExtension") diff --git a/dot_config/nvim/lua/config/catppuccin.lua b/dot_config/nvim/lua/config/catppuccin.lua index 900a2e1..3a5263a 100644 --- a/dot_config/nvim/lua/config/catppuccin.lua +++ b/dot_config/nvim/lua/config/catppuccin.lua @@ -1,70 +1,83 @@ --- use transparency in terminal only -vim.g.catppuccin_flavour = "mocha" +local colors = require("catppuccin.palettes").get_palette() +vim.g.catppuccin_flavour = "frappe" require("catppuccin").setup({ - transparent_background = false, - term_colors = true, - dim_inactive = { - enable = false, - shade = "dark", - percentage = 0.05, - }, - styles = { - comments = { "italic" }, - conditionals = { "italic" }, - }, - integrations = { - treesitter = true, - native_lsp = { - enabled = true, - virtual_text = { - errors = { "italic" }, - hints = { "italic" }, - warnings = { "italic" }, - information = { "italic" }, - }, - underlines = { - errors = { "underline" }, - hints = { "underline" }, - warnings = { "underline" }, - information = { "underline" }, - }, - }, - cmp = true, - coc_nvim = false, - lsp_saga = true, - lsp_trouble = true, - nvimtree = { - enabled = false, - }, - neotree = { - enabled = true, - show_root = false, - transparent_panel = false, - }, - which_key = true, - indent_blankline = { - enabled = true, - colored_indent_levels = true, - }, - barbar = false, - bufferline = true, - dashboard = true, - fern = false, - gitgutter = false, - gitsigns = true, - hop = false, - leap = false, - lightspeed = true, - markdown = true, - neogit = true, - notify = false, - symbols_outline = true, - telekasten = false, - telescope = true, - ts_rainbow = true, - vim_sneak = false, - } + dim_inactive = { + enable = true, + shade = "dark", + percentage = 0.15, + }, + styles = { + comments = { "italic" }, + conditionals = { "italic" }, + }, + integrations = { + treesitter = true, + native_lsp = { + enabled = true, + virtual_text = { + errors = { "italic" }, + hints = { "italic" }, + warnings = { "italic" }, + information = { "italic" }, + }, + underlines = { + errors = { "underline" }, + hints = { "underline" }, + warnings = { "underline" }, + information = { "underline" }, + }, + }, + cmp = true, + coc_nvim = false, + lsp_saga = true, + lsp_trouble = true, + nvimtree = { + enabled = false, + }, + neotree = { + enabled = true, + show_root = false, + transparent_panel = false, + }, + which_key = true, + indent_blankline = { + enabled = true, + colored_indent_levels = true, + }, + barbar = false, + bufferline = true, + dashboard = false, + fern = false, + gitgutter = false, + gitsigns = true, + hop = false, + leap = false, + lightspeed = true, + markdown = true, + neogit = true, + notify = false, + symbols_outline = true, + telekasten = false, + telescope = true, + ts_rainbow = true, + vim_sneak = false, + }, + custom_highlights = { + DashboardShortCut = { fg = colors.yellow }, + DashboardHeader = { fg = colors.red }, + DashboardCenter = { fg = colors.peach }, + DashboardFooter = { fg = colors.maroon }, + }, }) -vim.cmd("colorscheme catppuccin") +vim.api.nvim_command("colorscheme catppuccin") + +vim.api.nvim_create_autocmd("ColorScheme", { + pattern = "*", + callback = function() + package.loaded["feline"] = nil + package.loaded["catppuccin.groups.integrations.feline"] = nil + require("config.feline") + end, +}) diff --git a/dot_config/nvim/lua/config/colorizer.lua b/dot_config/nvim/lua/config/colorizer.lua new file mode 100644 index 0000000..cac8982 --- /dev/null +++ b/dot_config/nvim/lua/config/colorizer.lua @@ -0,0 +1,26 @@ +require("colorizer").setup({ + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue or blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = false, -- CSS rgb() and rgba() functions + hsl_fn = false, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes for `mode`: foreground, background, virtualtext + mode = "background", -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = true, + -- parsers can contain values used in |user_default_options| + sass = { enable = true }, -- Enable sass colors + }, + buftypes = { + "*", + -- exclude prompt and popup buftypes from highlight + "!prompt", + "!popup", + }, +}) diff --git a/dot_config/nvim/lua/config/dashboard.lua b/dot_config/nvim/lua/config/dashboard.lua index 79bfe68..35af3b8 100644 --- a/dot_config/nvim/lua/config/dashboard.lua +++ b/dot_config/nvim/lua/config/dashboard.lua @@ -1,66 +1,78 @@ +local cp = require("catppuccin.palettes.init").get_palette() + local home = os.getenv("HOME") local db = require("dashboard") db.custom_header = function() - local quotes = { - "Demonic presence at unsafe levels.", - "Rip and tear, until it is done.", - "So you walk eternally through the shadow realms.", - "The only thing they fear... is you.", - "There he lies still, and ever more, in silent suffering.", - "We will send unto them...only you.", - "What you see now in this facility is the cost. Of progress.", - "You can't just shoot a hole in the surface of mars!", - "WARNING: The Slayer has entered the facility.", - "DANGER: THE SLAYER HAS CONTROL OF THE BFG.", - } - local random_quote = quotes[math.random(#quotes)] - return { - [[]], - [[ _ _ _____ _ _ _____ _____ _____ _ _ _ _ ________ ___]], - [[| | | |_ _| \ | |/ ___|_ _| _ | \ | | | | | |_ _| \/ |]], - [[| | | | | | | \| |\ `--. | | | | | | \| | | | | | | | | . . |]], - [[| |/\| | | | | . ` | `--. \ | | | | | | . ` | | | | | | | | |\/| |]], - [[\ /\ /_| |_| |\ |/\__/ / | | \ \_/ / |\ | _ \ \_/ /_| |_| | | |]], - [[ \/ \/ \___/\_| \_/\____/ \_/ \___/\_| \_/ (_) \___/ \___/\_| |_/]], - [[]], - random_quote, - [[]], - } + local quotes = { + "Demonic presence at unsafe levels.", + "Rip and tear, until it is done.", + "So you walk eternally through the shadow realms.", + "The only thing they fear... is you.", + "There he lies still, and ever more, in silent suffering.", + "We will send unto them...only you.", + "What you see now in this facility is the cost. Of progress.", + "You can't just shoot a hole in the surface of mars!", + "WARNING: The Slayer has entered the facility.", + "DANGER: THE SLAYER HAS CONTROL OF THE BFG.", + } + local random_quote = quotes[math.random(#quotes)] + return { + [[]], + [[ _ _ _____ _ _ _____ _____ _____ _ _ _ _ ________ ___]], + [[| | | |_ _| \ | |/ ___|_ _| _ | \ | | | | | |_ _| \/ |]], + [[| | | | | | | \| |\ `--. | | | | | | \| | | | | | | | | . . |]], + [[| |/\| | | | | . ` | `--. \ | | | | | | . ` | | | | | | | | |\/| |]], + [[\ /\ /_| |_| |\ |/\__/ / | | \ \_/ / |\ | _ \ \_/ /_| |_| | | |]], + [[ \/ \/ \___/\_| \_/\____/ \_/ \___/\_| \_/ (_) \___/ \___/\_| |_/]], + [[]], + random_quote, + [[]], + } end db.custom_center = { - { - icon = " ", - desc = "Restore latest session ", - action = "SessionLoad", - }, - { - icon = " ", - desc = "Open Projects ", - action = "Telescope project", - }, - { - icon = " ", - desc = "Find File ", - action = "Telescope find_files find_command=rg,--hidden,--files", - }, - { - icon = " ", - desc = "File Browser ", - action = "Telescope file_browser", - }, - { - icon = " ", - desc = "Find word ", - action = "Telescope live_grep", - }, - { - icon = " ", - desc = "Open Settings ", - action = function() - vim.cmd("cd " .. home .. "/.config/nvim/") - vim.cmd("edit init.lua") - end - }, + { + icon = " ", + desc = "Restore latest session ", + action = "SessionLoad", + }, + { + icon = " ", + desc = "Open Projects ", + action = "Telescope project", + }, + { + icon = " ", + desc = "Find File ", + action = "Telescope find_files find_command=rg,--hidden,--files", + }, + { + icon = " ", + desc = "File Browser ", + action = "Telescope file_browser", + }, + { + icon = " ", + desc = "Find word ", + action = "Telescope live_grep", + }, + { + icon = " ", + desc = "Open Settings ", + action = function() + vim.cmd("cd " .. home .. "/.config/nvim/") + vim.cmd("edit init.lua") + end, + }, } + +db.custom_footer = function() + local v = vim.version() + local vStr = string.format("%d.%d.%d", v.major, v.minor, v.patch) + local plugCount = #vim.tbl_keys(packer_plugins) + return { + "neovim " .. vStr, + plugCount .. " regrets", + } +end diff --git a/dot_config/nvim/lua/config/feline.lua b/dot_config/nvim/lua/config/feline.lua index 0bb6ef1..10590f5 100644 --- a/dot_config/nvim/lua/config/feline.lua +++ b/dot_config/nvim/lua/config/feline.lua @@ -2,57 +2,41 @@ local clrs = require("catppuccin.palettes.init").get_palette() local ctp_feline = require("catppuccin.groups.integrations.feline") ctp_feline.setup({ - assets = { - left_separator = "", - right_separator = "", - bar = "█", - mode_icon = " ", - }, - sett = { - show_modified = true, - curr_dir = clrs.mauve, - curr_file = clrs.blue, - }, + assets = { + left_separator = "", + right_separator = "", + bar = "█", + mode_icon = " ", + dir = "  ", + file = "  ", + git = { + branch = " ", + }, + }, + sett = { + show_modified = true, + curr_dir = clrs.mauve, + curr_file = clrs.blue, + }, + mode_colors = { + ["n"] = { "NORMAL", clrs.blue }, + }, }) require("feline").setup({ - components = ctp_feline.get(), - force_inactive = { - filetypes = { - "^packer$", - "^startify$", - "^fugitive$", - "^fugitiveblame$", - "^qf$", - "^help$", - }, - buftypes = { - "^terminal$", - }, - bufnames = {}, - }, + components = ctp_feline.get(), + force_inactive = { + filetypes = { + "^packer$", + "^startify$", + "^fugitive$", + "^fugitiveblame$", + "^qf$", + "^help$", + }, + buftypes = { + "^terminal$", + }, + bufnames = {}, + }, }) - --- local navic = require("nvim-navic") - --- local wbar = { --- active = {}, --- inactive = {} --- } --- table.insert(wbar.active, {}) --- table.insert(wbar.active, {}) --- table.insert(wbar.active, {}) - --- table.insert(wbar.active[1], { --- provider = function() --- return navic.get_location() --- end, --- enabled = function() --- return navic.is_available() --- end, --- }) --- table.insert(wbar.active[3], { --- provider = 'lsp_client_names' --- }) - --- require("feline").winbar.setup({ components = wbar }) diff --git a/dot_config/nvim/lua/config/gitsigns.lua b/dot_config/nvim/lua/config/gitsigns.lua index 480e01b..584cdd5 100644 --- a/dot_config/nvim/lua/config/gitsigns.lua +++ b/dot_config/nvim/lua/config/gitsigns.lua @@ -1,63 +1,63 @@ require("gitsigns").setup({ - signs = { - add = { - hl = "GitSignsAdd", - text = "+", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = "~", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = "_", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = "‾", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = "x", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - }, - linehl = false, - numhl = false, - signcolumn = true, - word_diff = false, - watch_gitdir = { interval = 1000, follow_files = true }, - attach_to_untracked = true, - -- current line highlighting - current_line_blame = true, - current_line_blame_opts = { - delay = 1000, - ignore_whitespace = true, - virt_text = true, - virt_text_pos = "eol", - }, - current_line_blame_formatter = ", - | ", - -- perf - max_file_length = 40000, - sign_priority = 6, - update_debounce = 100, - -- use the included status formatter - status_formatter = nil, - preview_config = { - border = "single", - style = "minimal", - relative = "cursor", - row = 0, - col = 1, - }, - yadm = { enable = false }, + signs = { + add = { + hl = "GitSignsAdd", + text = "+", + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn", + }, + change = { + hl = "GitSignsChange", + text = "~", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + delete = { + hl = "GitSignsDelete", + text = "_", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + topdelete = { + hl = "GitSignsDelete", + text = "‾", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + changedelete = { + hl = "GitSignsChange", + text = "x", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + linehl = false, + numhl = false, + signcolumn = true, + word_diff = false, + watch_gitdir = { interval = 1000, follow_files = true }, + attach_to_untracked = true, + -- current line highlighting + current_line_blame = true, + current_line_blame_opts = { + delay = 1000, + ignore_whitespace = true, + virt_text = true, + virt_text_pos = "eol", + }, + current_line_blame_formatter = ", - | ", + -- perf + max_file_length = 40000, + sign_priority = 6, + update_debounce = 100, + -- use the included status formatter + status_formatter = nil, + preview_config = { + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { enable = false }, }) diff --git a/dot_config/nvim/lua/config/lspsaga.lua b/dot_config/nvim/lua/config/lspsaga.lua index 959458b..6bb5e36 100644 --- a/dot_config/nvim/lua/config/lspsaga.lua +++ b/dot_config/nvim/lua/config/lspsaga.lua @@ -1,5 +1,9 @@ local saga = require("lspsaga") -saga.init_lsp_saga() +saga.init_lsp_saga({ + code_action_lightbulb = { + enable = false, + }, +}) Nmap("gr", "Lspsaga rename") Nmap("gx", "Lspsaga code_action") @@ -8,16 +12,6 @@ Nmap("K", "Lspsaga hover_doc") Nmap("go", "Lspsaga show_line_diagnostics") Nmap("gj", "Lspsaga diagnostic_jump_next") Nmap("gk", "Lspsaga diagnostic_jump_prev") --- Nmap("", "lua require('lspsaga.action').smart_scroll_with_saga(-1, '')", {}) --- Nmap("", "lua require('lspsaga.action').smart_scroll_with_saga(1, '')", {}) - --- vim.keymap.set("n", "", function() --- require("lspsaga.action").smart_scroll_with_saga(1) --- end) --- -- scroll up --- vim.keymap.set("n", "", function() --- require("lspsaga.action").smart_scroll_with_saga(-1) --- end) vim.cmd([[ nnoremap lua require('lspsaga.floaterm').open_float_terminal() diff --git a/dot_config/nvim/lua/config/presence.lua b/dot_config/nvim/lua/config/presence.lua index aa69d0f..481b07b 100644 --- a/dot_config/nvim/lua/config/presence.lua +++ b/dot_config/nvim/lua/config/presence.lua @@ -1,110 +1,109 @@ function string.starts(self, str) - return self:find('^' .. str) ~= nil + return self:find("^" .. str) ~= nil end local conceal = function() - local home = os.getenv("HOME") - local blacklist = { - [home .. "/git/work"] = "Working...", - [home .. "/git/freelance"] = "Freelancing...", - [home .. "/git/freelance"] = "Freelancing...", - } + local home = os.getenv("HOME") + local blacklist = { + [home .. "/git/work"] = "Using nvim at work.", + [home .. "/git/freelance"] = "Using nvim to freelance.", + } - local cur_file = vim.fn.expand("%:p") - for k, v in pairs(blacklist) do - if cur_file:starts(k) then - return v - end - end - return false + local cur_file = vim.fn.expand("%:p") + for k, v in pairs(blacklist) do + if cur_file:starts(k) then + return v + end + end + return false end require("presence"):setup({ - -- General options - auto_update = true, - neovim_image_text = "The Soydev's Kryptonite", - -- Main image display (either "neovim" or "file") - main_image = "file", - -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches - ---@diagnostic disable-next-line: unused-local - buttons = function(buffer, repo_url) - -- ignore where no repo_url is set - if repo_url == nil then - return false - end + -- General options + auto_update = true, + neovim_image_text = "The Soydev's Kryptonite", + -- Main image display (either "neovim" or "file") + main_image = "file", + -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches + ---@diagnostic disable-next-line: unused-local + buttons = function(buffer, repo_url) + -- ignore where no repo_url is set + if repo_url == nil then + return false + end - -- only show certain org/user repos, don't leak clients or work - local visible_urls = { - "github.com/catppuccin", - "github.com/farbenfroh", - "github.com/nekowinston", - } + -- only show certain org/user repos, don't leak clients or work + local visible_urls = { + "github.com/catppuccin", + "github.com/farbenfroh", + "github.com/nekowinston", + } - -- check if repo_url is in the list of visible urls - for _, visible_url in ipairs(visible_urls) do - if repo_url:find(visible_url) then - return { - { - label = "Steal the code", - url = repo_url, - }, - } - end - end + -- check if repo_url is in the list of visible urls + for _, visible_url in ipairs(visible_urls) do + if repo_url:find(visible_url) then + return { + { + label = "Steal the code", + url = repo_url, + }, + } + end + end - -- if not, return false - return false - end, - debounce_timeout = 10, - file_assets = { - ["k8s.yaml"] = { - "Kubernetes", - "https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png", - }, - ["Chart.yaml"] = { - "Helm Chart", - "https://raw.githubusercontent.com/helm/community/main/art/images/Logo-Tweak-Dark.png", - }, - ["helmfile.yaml"] = { - "helmfile", - "https://raw.githubusercontent.com/helm/community/main/art/images/Logo-Tweak-Dark.png", - }, - ["prisma"] = { - "Prisma", - "https://avatars.githubusercontent.com/u/17219288" - } - }, - -- Rich Presence text options - editing_text = function(s) - local concealed = conceal() - if concealed then - return concealed - end - return "✍️ " .. s - end, - reading_text = function(s) - local concealed = conceal() - if concealed then - return concealed - end - return "📖 " .. s - end, - file_explorer_text = function(s) - local concealed = conceal() - if concealed then - return concealed - end - return "📁 " .. s - end, - workspace_text = function(s) - local concealed = conceal() - if s ~= nil and not concealed then - return "🗂️ ".. s - else - return nil - end - end, - git_commit_text = "Committing changes", - plugin_manager_text = "🤹 Managing Plugins", - line_number_text = "L%s of %s", + -- if not, return false + return false + end, + debounce_timeout = 10, + file_assets = { + ["k8s.yaml"] = { + "Kubernetes", + "https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png", + }, + ["Chart.yaml"] = { + "Helm Chart", + "https://raw.githubusercontent.com/helm/community/main/art/images/Logo-Tweak-Dark.png", + }, + ["helmfile.yaml"] = { + "helmfile", + "https://raw.githubusercontent.com/helm/community/main/art/images/Logo-Tweak-Dark.png", + }, + ["prisma"] = { + "Prisma", + "https://avatars.githubusercontent.com/u/17219288", + }, + }, + -- Rich Presence text options + editing_text = function(s) + local concealed = conceal() + if concealed then + return concealed + end + return "Editing " .. s + end, + reading_text = function(s) + local concealed = conceal() + if concealed then + return concealed + end + return "Reading " .. s + end, + file_explorer_text = function(s) + local concealed = conceal() + if concealed then + return concealed + end + return "Working in " .. s + end, + workspace_text = function(s) + local concealed = conceal() + if s ~= nil and not concealed then + return "Working on " .. s + else + return nil + end + end, + git_commit_text = "Committing changes", + plugin_manager_text = "Managing Plugins", + line_number_text = "L%s of %s", }) diff --git a/dot_config/nvim/lua/config/treesitter.lua b/dot_config/nvim/lua/config/treesitter.lua index 99f96da..0f2d1c6 100644 --- a/dot_config/nvim/lua/config/treesitter.lua +++ b/dot_config/nvim/lua/config/treesitter.lua @@ -1,65 +1,45 @@ require("nvim-treesitter.configs").setup({ - auto_install = true, - ignore_install = { - -- woulnd't install sometimes, not needed - "phpdoc", - }, - highlight = { - enable = true, - }, - ensure_installed = { - "bash", - "c", - "cmake", - "comment", - "cpp", - "css", - "dockerfile", - "fish", - "gdscript", - "glsl", - "go", - "godot_resource", - "gomod", - "gowork", - "graphql", - "help", - "hjson", - "html", - "http", - "java", - "javascript", - "jsdoc", - "json", - "json5", - "jsonc", - "kotlin", - "latex", - "lua", - "make", - "markdown", - "ninja", - "perl", - "php", - "prisma", - "proto", - "pug", - "python", - "rasi", - "regex", - "ruby", - "rust", - "scss", - "sql", - "svelte", - "swift", - "teal", - "todotxt", - "toml", - "tsx", - "typescript", - "vim", - "vue", - "yaml", - }, + auto_install = true, + ignore_install = { + -- woulnd't install sometimes, not needed + "phpdoc", + }, + highlight = { + enable = true, + }, + ensure_installed = { + "bash", + "css", + "dockerfile", + "go", + "gomod", + "graphql", + "help", + "hjson", + "html", + "http", + "javascript", + "jsdoc", + "json", + "json5", + "jsonc", + "latex", + "lua", + "make", + "markdown", + "php", + "prisma", + "python", + "regex", + "rust", + "scss", + "sql", + "svelte", + "teal", + "toml", + "tsx", + "typescript", + "vim", + "yaml", + }, }) diff --git a/dot_config/nvim/lua/lsp.lua b/dot_config/nvim/lua/lsp.lua index 76929b9..3698adb 100644 --- a/dot_config/nvim/lua/lsp.lua +++ b/dot_config/nvim/lua/lsp.lua @@ -1,12 +1,12 @@ require("mason").setup({ - ui = { - border = "none", - icons = { - package_installed = " ", - package_pending = " ", - package_uninstalled = " ", - }, - }, + ui = { + border = "none", + icons = { + package_installed = " ", + package_pending = " ", + package_uninstalled = " ", + }, + }, }) require("mason-lspconfig").setup({ automatic_installation = true }) @@ -18,51 +18,53 @@ vim.opt.completeopt = "menu,menuone,noselect" -- Setup nvim-cmp. local present, cmp = pcall(require, "cmp") if not present then - return + return end cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "vsnip" }, - }, { { name = "buffer" } }), + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, + }, { { name = "buffer" } }), }) -- Set configuration for specific filetype. cmp.setup.filetype("gitcommit", { - sources = cmp.config.sources({ - { name = "cmp_git" }, - }, { { name = "buffer" } }), + sources = cmp.config.sources({ + { name = "cmp_git" }, + }, { { name = "buffer" } }), }) -- search cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { { name = "buffer" } }, + mapping = cmp.mapping.preset.cmdline(), + sources = { { name = "buffer" } }, }) -- Use cmdline & path source for ':' cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources( - { { - name = "path", - option = { trailing_slash = true }, - } }, - { { name = "cmdline" } } - ), + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources( + { { + name = "path", + option = { trailing_slash = true }, + } }, + { { name = "cmdline" } } + ), }) -- Setup lspconfig. -local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) +local capabilities = require("cmp_nvim_lsp").update_capabilities( + vim.lsp.protocol.make_client_capabilities() +) -- Mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions @@ -76,66 +78,65 @@ vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) -- after the language server attaches to the current buffer ---@diagnostic disable-next-line: unused-local local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - -- disable diagnostics on Helm files - if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then - vim.diagnostic.disable() - end + -- disable diagnostics on Helm files + if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then + vim.diagnostic.disable() + end - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) - vim.keymap.set("n", "nf", function() - end, bufopts) + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) + vim.keymap.set("n", "nf", function() end, bufopts) end local common_config = { - on_attach = on_attach, - capabilities = capabilities, + on_attach = on_attach, + capabilities = capabilities, } local present, lsp = pcall(require, "lspconfig") if not present then - return + return end lsp.sumneko_lua.setup({ - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - maxPreload = 100000, - preloadFileSize = 10000, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim" }, - }, - telemetry = { - enable = false, - }, - }, - }, + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + maxPreload = 100000, + preloadFileSize = 10000, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + telemetry = { + enable = false, + }, + }, + }, }) --- the cool kids @@ -146,29 +147,31 @@ lsp.rust_analyzer.setup(common_config) --- Web Development lsp.cssls.setup(common_config) -local emmet_cap = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) +local emmet_cap = require("cmp_nvim_lsp").update_capabilities( + vim.lsp.protocol.make_client_capabilities() +) emmet_cap.textDocument.completion.completionItem.snippetSupport = true lsp.emmet_ls.setup({ - on_attach = on_attach, - capabilities = emmet_cap, - filetypes = { - "javascriptreact", - "typescriptreact", - "html", - "svelte", - "css", - "less", - "sass", - "scss", - }, + on_attach = on_attach, + capabilities = emmet_cap, + filetypes = { + "javascriptreact", + "typescriptreact", + "html", + "svelte", + "css", + "less", + "sass", + "scss", + }, }) -- lsp.html.setup(common_config) lsp.tailwindcss.setup({ - on_attach = on_attach, - capabilities = capabilities, - settings = { - emmetCompletions = true, - }, + on_attach = on_attach, + capabilities = capabilities, + settings = { + emmetCompletions = true, + }, }) -- soydev @@ -176,59 +179,52 @@ lsp.prismals.setup(common_config) lsp.svelte.setup(common_config) -- attach tsserver only when there's a 'package.json' file in the CWD lsp.tsserver.setup({ - on_attach = on_attach, - capabilities = capabilities, - root_dir = lsp.util.root_pattern("package.json"), + on_attach = on_attach, + capabilities = capabilities, + root_dir = lsp.util.root_pattern("package.json"), }) -- attach deno only when there's a 'deps.ts' file in the CWD lsp.denols.setup({ - on_attach = on_attach, - capabilities = capabilities, - root_dir = lsp.util.root_pattern("deps.ts"), - single_file_support = false, + on_attach = on_attach, + capabilities = capabilities, + root_dir = lsp.util.root_pattern("deps.ts"), + single_file_support = false, }) -- data formats lsp.dockerls.setup(common_config) lsp.graphql.setup({ - on_attach = on_attach, - capabilities = capabilities, - root_dir = lsp.util.root_pattern(".graphqlrc*", ".graphql.config.*", "graphql.config.*"), - settings = { - graphql = { - schemaPath = "schema.graphql", - }, - }, + on_attach = on_attach, + capabilities = capabilities, + root_dir = lsp.util.root_pattern( + ".graphqlrc*", + ".graphql.config.*", + "graphql.config.*" + ), + settings = { + graphql = { + schemaPath = "schema.graphql", + }, + }, }) lsp.jsonls.setup({ - on_attach = on_attach, - capabilities = capabilities, - settings = { - json = { - schemas = require("schemastore").json.schemas(), - validate = { enable = true }, - }, - }, + on_attach = on_attach, + capabilities = capabilities, + settings = { + json = { + schemas = require("schemastore").json.schemas(), + validate = { enable = true }, + }, + }, }) lsp.yamlls.setup({ - on_attach = on_attach, - capabilities = capabilities, - settings = { - redhat = { - telemetry = { - enabled = false, - }, - }, - yaml = { - schemas = { - ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.2-standalone-strict/all.json"] = { - "*.k8s.yaml", - "*.k8s.yml", - "kubectl-edit-*.yaml", - }, - }, - }, - }, + on_attach = on_attach, + capabilities = capabilities, + settings = { + yaml = { + ["https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json"] = "/*.k8s.yaml", + }, + }, }) --- Documentation diff --git a/dot_config/nvim/lua/plugins.lua b/dot_config/nvim/lua/plugins.lua index a865a25..48e5278 100644 --- a/dot_config/nvim/lua/plugins.lua +++ b/dot_config/nvim/lua/plugins.lua @@ -2,473 +2,392 @@ require("utils") vim.cmd([[packadd packer.nvim]]) local packer = require("packer") +if not packer then + return +end + -- slow internet... packer.init({ - git = { clone_timeout = 180 }, - profile = { - enable = true, - }, + git = { clone_timeout = 180 }, + profile = { + enable = true, + }, }) return packer.startup(function(use) - -- Packer managing itself - use("wbthomason/packer.nvim") - -- startup time or some shit - use("lewis6991/impatient.nvim") + -- Packer managing itself + use("wbthomason/packer.nvim") + -- startup time or some shit + use("lewis6991/impatient.nvim") - -- colour scheme - use({ - "catppuccin/nvim", - as = "catppuccin", - config = function() - require("config/catppuccin") - end, - }) - use({ - "Pocco81/true-zen.nvim", - config = function() - require("true-zen").setup({ - modes = { - ataraxis = { - shade = "dark", - backdrop = 0.00, - quit_untoggles = true, - padding = { - left = 52, - right = 52, - top = 0, - bottom = 0, - }, - }, - narrow = { - run_ataraxis = true, - }, - }, - integrations = { - tmux = true, - }, - }) - end, - }) + -- colour scheme + use({ + "catppuccin/nvim", + as = "catppuccin", + run = ":CatppuccinCompile", + config = function() + require("config/catppuccin") + end, + }) - -- git gutter - use({ - "lewis6991/gitsigns.nvim", - config = function() - require("config/gitsigns") - end, - }) + -- git gutter + use({ + "lewis6991/gitsigns.nvim", + config = function() + require("config/gitsigns") + end, + }) - -- rainbow indents - use({ - "lukas-reineke/indent-blankline.nvim", - config = function() - require("indent_blankline").setup({ - space_char_blankline = " ", - show_current_conext = true, - char_highlight_list = { - "IndentBlanklineIndent1", - "IndentBlanklineIndent2", - "IndentBlanklineIndent3", - "IndentBlanklineIndent4", - "IndentBlanklineIndent5", - "IndentBlanklineIndent6", - }, - }) - vim.g.indent_blankline_filetype_exclude = { - "dashboard", - "help", - "neogitstatus", - "fugitive", - "packer", - "NvimTree", - "Trouble", - } - end, - }) + -- rainbow indents + use({ + "lukas-reineke/indent-blankline.nvim", + config = function() + require("indent_blankline").setup({ + space_char_blankline = " ", + show_current_conext = true, + char_highlight_list = { + "IndentBlanklineIndent1", + "IndentBlanklineIndent2", + "IndentBlanklineIndent3", + "IndentBlanklineIndent4", + "IndentBlanklineIndent5", + "IndentBlanklineIndent6", + }, + }) + vim.g.indent_blankline_filetype_exclude = { + "dashboard", + "help", + "neogitstatus", + "fugitive", + "packer", + "NvimTree", + "Trouble", + } + end, + }) - -- top bar - use({ - "akinsho/bufferline.nvim", - config = function() - require("bufferline").setup({ - options = { - show_close_icon = false, - separator_style = "slant", - close_icon = "", - offsets = { { filetype = "NvimTree" } }, - left_mouse_command = "buffer %d", - middle_mouse_command = "bdelete! %d", - right_mouse_command = nil, - }, - }) - -- hop between buffers in order of the bar - Nmap("", "BufferLineCyclePrev") - Nmap("", "BufferLineCycleNext") - -- Re-order to previous/next - Nmap("", "BufferLineMovePrev") - Nmap(">", "BufferLineMoveNext") - -- Goto buffer in position... - Nmap("", "BufferLineGoToBuffer 1") - Nmap("", "BufferLineGoToBuffer 2") - Nmap("", "BufferLineGoToBuffer 3") - Nmap("", "BufferLineGoToBuffer 4") - Nmap("", "BufferLineGoToBuffer 5") - Nmap("", "BufferLineGoToBuffer 6") - Nmap("", "BufferLineGoToBuffer 7") - Nmap("", "BufferLineGoToBuffer 8") - Nmap("", "BufferLineGoToBuffer 9") - Nmap("", "BufferLineGoToBuffer -1") - -- Pin/unpin buffer - Nmap("", "BufferLineTogglePin") - -- Close buffer - Nmap("", "bdelete") - Nmap("", "bdelete!") - -- create new buffer - Nmap("", "enew") - -- pick buffer - Nmap("", "BufferLinePick") - -- Sort automatically by... - Nmap("bd", "BufferLineSortByDirectory") - Nmap("bl", "BufferLineSortByExtension") - end, - }) + -- top bar + use({ + "akinsho/bufferline.nvim", + config = function() + require("config/bufferline") + end, + }) - -- bottom bar - use({ - "feline-nvim/feline.nvim", - requires = "kyazdani42/nvim-web-devicons", - after = { "catppuccin" }, - config = function() - require("config/feline") - end, - }) + -- bottom bar + use({ + "feline-nvim/feline.nvim", + requires = "kyazdani42/nvim-web-devicons", + after = { "catppuccin" }, + config = function() + require("config/feline") + end, + }) - -- DJI Osmo - use({ - "luukvbaal/stabilize.nvim", - config = function() - require("stabilize").setup() - end, - }) + -- DJI Osmo + use({ + "luukvbaal/stabilize.nvim", + config = function() + require("stabilize").setup() + end, + }) - -- syntax - use({ - "nvim-treesitter/nvim-treesitter", - run = function() require('nvim-treesitter.install').update({ with_sync = true }) end, - config = function() - require("config/treesitter") - end, - }) - use({ "p00f/nvim-ts-rainbow", requires = "nvim-treesitter/nvim-treesitter" }) + -- syntax + use({ + "nvim-treesitter/nvim-treesitter", + run = function() + require("nvim-treesitter.install").update({ with_sync = true }) + end, + config = function() + require("config/treesitter") + end, + }) + use({ "p00f/nvim-ts-rainbow", requires = "nvim-treesitter/nvim-treesitter" }) - -- show possible key combos - use({ - "folke/which-key.nvim", - config = function() - require("which-key").setup({}) - end, - }) - -- we IDE now - use({ - "rcarriga/nvim-notify", - config = function() - require("notify").setup({ - fps = 60, - timeout = 2500, - stages = "fade", - }) - end, - }) + -- show possible key combos + use({ + "folke/which-key.nvim", + config = function() + require("which-key").setup({}) + end, + }) - -- syntax - use("alker0/chezmoi.vim") - use("digitaltoad/vim-pug") - use("ron-rs/ron.vim") - use("elkowar/yuck.vim") + -- syntax + use("alker0/chezmoi.vim") + use("digitaltoad/vim-pug") + use("ron-rs/ron.vim") + use("elkowar/yuck.vim") - -- tooling - use({ - "editorconfig/editorconfig-vim", - config = function() - -- add fugitive buffers to the editorconfig excludes - vim.g.EditorConfig_exclude_patterns = { "fugitive://.*", "scp://.*" } - end, - }) - -- read and write encrypted pgp files - use("jamessan/vim-gnupg") + -- tooling + use("gpanders/editorconfig.nvim") + -- read and write encrypted pgp files + use("jamessan/vim-gnupg") - -- additional functionality - use("tpope/vim-commentary") - use("tpope/vim-surround") - use("ggandor/lightspeed.nvim") - -- make those above work in repeat commands - use("tpope/vim-repeat") + -- additional functionality + use({ + "numToStr/Comment.nvim", + config = function() + require("Comment").setup() + end, + }) + use({ + "kylechui/nvim-surround", + config = function() + require("nvim-surround").setup({}) + end, + }) + use("ggandor/lightspeed.nvim") + -- make those above work in repeat commands - use({ - "windwp/nvim-autopairs", - config = function() - require("nvim-autopairs").setup({}) - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - local cmp = require("cmp") - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end, - }) - use({ - "windwp/nvim-ts-autotag", - config = function() - require("nvim-ts-autotag").setup() - end, - }) - use({ - "heavenshell/vim-jsdoc", - run = "make install", - config = function() - Nmap("jd", "JsDoc") - end, - }) + use({ + "windwp/nvim-autopairs", + config = function() + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, + }) + use({ + "windwp/nvim-ts-autotag", + config = function() + require("nvim-ts-autotag").setup() + end, + }) + -- + -- git + use("tpope/vim-fugitive") + -- why not both? + use({ + "TimUntersberger/neogit", + requires = "nvim-lua/plenary.nvim", + config = function() + Nmap("ng", "Neogit") + end, + }) + use("dhruvasagar/vim-table-mode") + use({ + "kyazdani42/nvim-tree.lua", + config = function() + require("nvim-tree").setup({ update_cwd = true }) + Nmap("", ":NvimTreeToggle") + Nmap("r", ":NvimTreeRefresh") + end, + }) + use({ + "nvchad/nvim-colorizer.lua", + config = function() + require("config/colorizer") + end, + }) + use({ + "simrat39/symbols-outline.nvim", + config = function() + require("symbols-outline").setup() + Nmap("so", ":SymbolsOutline") + end, + }) - -- git - use("tpope/vim-fugitive") - -- why not both? - use({ - "TimUntersberger/neogit", - requires = "nvim-lua/plenary.nvim", - config = function() - Nmap("ng", "Neogit") - end, - }) - use("christoomey/vim-sort-motion") - use("dhruvasagar/vim-table-mode") - use({ - "kyazdani42/nvim-tree.lua", - config = function() - require("nvim-tree").setup({ update_cwd = true }) - Nmap("", ":NvimTreeToggle") - Nmap("r", ":NvimTreeRefresh") - end, - }) - use({ - "RRethy/vim-hexokinase", - run = "make", - config = function() - vim.g.Hexokinase_highlighters = { "virtual" } - end, - }) - use({ - "simrat39/symbols-outline.nvim", - config = function() - Nmap("so", ":SymbolsOutline") - end, - }) + -- databases + use({ + "kristijanhusak/vim-dadbod-ui", + requires = "tpope/vim-dadbod", + config = function() + Nmap("db", ":DBUIToggle") + vim.g.db_ui_use_nerd_fonts = true + vim.g.db_ui_win_position = "right" + end, + }) + use({ + "kristijanhusak/vim-dadbod-completion", + requires = { { "tpope/vim-dadbod" }, { "hrsh7th/nvim-cmp" } }, + config = function() + require("cmp").setup.buffer({ + sources = { { name = "vim-dadbod-completion" } }, + }) + end, + }) - -- databases - use({ - "kristijanhusak/vim-dadbod-ui", - requires = "tpope/vim-dadbod", - config = function() - Nmap("db", ":DBUIToggle") - vim.g.db_ui_use_nerd_fonts = true - vim.g.db_ui_win_position = "right" - end, - }) - use({ - "kristijanhusak/vim-dadbod-completion", - requires = { { "tpope/vim-dadbod" }, { "hrsh7th/nvim-cmp" } }, - config = function() - require("cmp").setup.buffer({ sources = { { name = "vim-dadbod-completion" } } }) - end, - }) + -- telescope + use({ + "nvim-telescope/telescope.nvim", + requires = "nvim-lua/plenary.nvim", + config = function() + -- Find files using Telescope command-line sugar. + Nmap("fc", "Telescope conventional_commits") + Nmap("fr", "Telescope asynctasks all") + Nmap("ff", "Telescope find_files") + Nmap("fg", "Telescope live_grep") + Nmap("fb", "Telescope buffers") + Nmap("fh", "Telescope help_tags") + end, + }) + use({ + "nvim-telescope/telescope-fzf-native.nvim", + run = "make", + requires = "nvim-telescope/telescope.nvim", + config = function() + local telescope = require("telescope") + telescope.setup({ + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + }, + }) + telescope.load_extension("fzf") + end, + }) + use({ + "nvim-telescope/telescope-file-browser.nvim", + config = function() + require("telescope").load_extension("file_browser") + end, + }) + use({ + "nvim-telescope/telescope-project.nvim", + config = function() + require("telescope").load_extension("project") + end, + }) + use({ + "nvim-telescope/telescope-packer.nvim", + config = function() + require("telescope").load_extension("packer") + end, + }) + use({ + "olacin/telescope-cc.nvim", + requires = { + { "nvim-telescope/telescope.nvim" }, + { "nvim-lua/popup.nvim" }, + }, + config = function() + require("telescope").load_extension("conventional_commits") + end, + }) - -- telescope - use({ - "nvim-telescope/telescope.nvim", - requires = "nvim-lua/plenary.nvim", - config = function() - -- Find files using Telescope command-line sugar. - Nmap("fc", "Telescope conventional_commits") - Nmap("fr", "Telescope asynctasks all") - Nmap("ff", "Telescope find_files") - Nmap("fg", "Telescope live_grep") - Nmap("fb", "Telescope buffers") - Nmap("fh", "Telescope help_tags") - end, - }) - use({ - "nvim-telescope/telescope-fzf-native.nvim", - run = "make", - requires = "nvim-telescope/telescope.nvim", - config = function() - local telescope = require("telescope") - telescope.setup({ - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "smart_case", - }, - }, - }) - telescope.load_extension("fzf") - end, - }) - use({ - "nvim-telescope/telescope-file-browser.nvim", - config = function() - require("telescope").load_extension("file_browser") - end, - }) - use({ - "nvim-telescope/telescope-project.nvim", - config = function() - require("telescope").load_extension("project") - end, - }) - use({ - "olacin/telescope-cc.nvim", - requires = { - { "nvim-telescope/telescope.nvim" }, - { "nvim-lua/popup.nvim" }, - }, - config = function() - require("telescope").load_extension("conventional_commits") - end, - }) - use({ - "sudormrfbin/cheatsheet.nvim", - }) + use({ + "andweeb/presence.nvim", + config = function() + require("config/presence") + end, + }) + use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install" }) - use({ - "andweeb/presence.nvim", - config = function() - require("config/presence") - end, - }) - use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install" }) + -- external extensions + use("williamboman/mason.nvim") + -- LSP + use("williamboman/mason-lspconfig.nvim") + use("neovim/nvim-lspconfig") + -- completion + use("hrsh7th/nvim-cmp") + use("hrsh7th/cmp-buffer") + use("hrsh7th/cmp-cmdline") + use("hrsh7th/cmp-nvim-lsp") + use("hrsh7th/cmp-path") + use("hrsh7th/cmp-vsnip") + use("hrsh7th/vim-vsnip") + use("petertriho/cmp-git") - -- external extensions - use("williamboman/mason.nvim") - -- LSP - use("williamboman/mason-lspconfig.nvim") - use("neovim/nvim-lspconfig") - -- completion - use("hrsh7th/nvim-cmp") - use("hrsh7th/cmp-buffer") - use("hrsh7th/cmp-cmdline") - use("hrsh7th/cmp-nvim-lsp") - use("hrsh7th/cmp-path") - use("hrsh7th/cmp-vsnip") - use("hrsh7th/vim-vsnip") - use("petertriho/cmp-git") - -- other - use({ - "jose-elias-alvarez/null-ls.nvim", - config = function() - local null_ls = require("null-ls") - null_ls.setup({ - sources = { - null_ls.builtins.formatting.gofmt, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.rustfmt, - null_ls.builtins.formatting.stylua, - }, - }) - end, - requires = { "nvim-lua/plenary.nvim" }, - }) + use({ + "simrat39/rust-tools.nvim", + config = function() + require("rust-tools").setup({}) + end, + }) + use("b0o/schemastore.nvim") + -- + use({ + "folke/trouble.nvim", + config = function() + require("trouble").setup({}) + end, + }) + use({ + "glepnir/lspsaga.nvim", + config = function() + require("config/lspsaga") + end, + }) + -- + use({ + "github/copilot.vim", + config = function() + Imap( + "", + "copilot#Accept()", + { noremap = true, silent = true, expr = true } + ) + vim.g.copilot_no_tab_map = true + end, + }) - use({ - "simrat39/rust-tools.nvim", - config = function() - require("rust-tools").setup({}) - end, - }) - use("b0o/schemastore.nvim") - -- - use({ - "folke/trouble.nvim", - config = function() - require("trouble").setup({}) - end, - }) - use({ - "glepnir/lspsaga.nvim", - config = function() - require("config/lspsaga") - end, - }) - -- - use({ - "github/copilot.vim", - config = function() - Imap("", "copilot#Accept()", { noremap = true, silent = true, expr = true }) - vim.g.copilot_no_tab_map = true - end, - }) + -- organization + use({ + "vimwiki/vimwiki", + branch = "dev", + config = function() + vim.g.vimwiki_global_ext = 0 + vim.g.vimwiki_list = { + { + auto_export = 1, + path = "~/.local/share/vimwiki/", + syntax = "markdown", + ext = ".md", + path_html = "~/vimwiki/", + template_path = "~/.config/vimwiki/templates/", + template_default = "default", + template_ext = ".tpl", + custom_wiki2html = "vimwiki_markdown", + html_filename_parameterization = 1, + }, + } + end, + }) + use("tools-life/taskwiki") + use({ + "skywind3000/asyncrun.vim", + config = function() + vim.g.asyncrun_open = 6 + end, + }) + use({ "skywind3000/asynctasks.vim" }) + use({ + "GustavoKatel/telescope-asynctasks.nvim", + config = function() + require("telescope").load_extension("asynctasks") + end, + }) - -- organization - use({ - "vimwiki/vimwiki", - branch = "dev", - config = function() - vim.g.vimwiki_global_ext = 0 - vim.g.vimwiki_list = { - { - auto_export = 1, - path = "~/.local/share/vimwiki/", - syntax = "markdown", - ext = ".md", - path_html = "~/vimwiki/", - template_path = "~/.config/vimwiki/templates/", - template_default = "default", - template_ext = ".tpl", - custom_wiki2html = "vimwiki_markdown", - html_filename_parameterization = 1, - }, - } - end, - }) - use("tools-life/taskwiki") - use({ - "skywind3000/asyncrun.vim", - config = function() - vim.g.asyncrun_open = 6 - end, - }) - use({ "skywind3000/asynctasks.vim" }) - use({ - "GustavoKatel/telescope-asynctasks.nvim", - config = function() - require("telescope").load_extension("asynctasks") - end, - }) + -- startup + use({ + "glepnir/dashboard-nvim", + config = function() + require("config/dashboard") + end, + }) - -- startup - use({ - "glepnir/dashboard-nvim", - config = function() - require("config/dashboard") - end, - }) - - -- automatic theme switching - use({ - "f-person/auto-dark-mode.nvim", - config = function() - local auto_dark_mode = require("auto-dark-mode") - auto_dark_mode.setup({ - ---@diagnostic disable-next-line: assign-type-mismatch - update_interval = 1000, - set_dark_mode = function() - vim.cmd("Catppuccin frappe") - end, - set_light_mode = function() - vim.cmd("Catppuccin latte") - end, - }) - auto_dark_mode.init() - end, - cond = vim.fn.has("macunix"), - }) + -- automatic theme switching + if vim.fn.has("macunix") then + use({ + "f-person/auto-dark-mode.nvim", + config = function() + local auto_dark_mode = require("auto-dark-mode") + auto_dark_mode.setup({ + ---@diagnostic disable-next-line: assign-type-mismatch + update_interval = 1000, + set_dark_mode = function() + vim.cmd("Catppuccin frappe") + end, + set_light_mode = function() + vim.cmd("Catppuccin latte") + end, + }) + auto_dark_mode.init() + end, + }) + end end) diff --git a/dot_config/nvim/lua/utils.lua b/dot_config/nvim/lua/utils.lua index f16d2ae..a8037e4 100644 --- a/dot_config/nvim/lua/utils.lua +++ b/dot_config/nvim/lua/utils.lua @@ -1,18 +1,18 @@ local function map(mode, shortcut, command, opt) - vim.keymap.set(mode, shortcut, command, opt) + vim.keymap.set(mode, shortcut, command, opt) end function Nmap(shortcut, command, opt) - opt = opt or { noremap = true, silent = true } - map("n", shortcut, command, opt) + opt = opt or { noremap = true, silent = true } + map("n", shortcut, command, opt) end function Imap(shortcut, command, opt) - opt = opt or { noremap = true, silent = true } - map("i", shortcut, command, opt) + opt = opt or { noremap = true, silent = true } + map("i", shortcut, command, opt) end function Xmap(shortcut, command, opt) - opt = opt or { noremap = true, silent = true } - map("x", shortcut, command, opt) + opt = opt or { noremap = true, silent = true } + map("x", shortcut, command, opt) end