From efc511cbcf07be0f904d8f9284d0ad55726cba71 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 9 Oct 2022 22:40:29 +0200 Subject: [PATCH] Added base folke setup --- init.lua | 7 +- lua/config/commands.lua | 21 ++ lua/config/mappings.lua | 275 +++++++++++++++ lua/config/options.lua | 100 ++++++ lua/config/plugins.lua | 177 +++++++++- lua/plugins/autopairs.lua | 12 + lua/plugins/bufferline.lua | 56 +++ lua/plugins/cmp.lua | 60 ++++ lua/plugins/colorizer.lua | 26 ++ lua/plugins/dashboard.lua | 33 ++ lua/plugins/indent-blankline.lua | 53 +++ lua/plugins/lsp/diagnostics.lua | 26 ++ lua/plugins/lsp/formatting.lua | 59 ++++ lua/plugins/lsp/init.lua | 91 +++++ lua/plugins/lsp/kind.lua | 36 ++ lua/plugins/lualine.lua | 86 +++++ lua/plugins/luasnip.lua | 49 +++ lua/plugins/mason.lua | 28 ++ lua/plugins/neo-tree.lua | 10 +- lua/plugins/neoscroll.lua | 19 + lua/plugins/null-ls.lua | 34 ++ lua/plugins/telescope.lua | 123 +++++++ lua/plugins/tokyonight.lua | 59 ++++ lua/plugins/treesitter.lua | 124 ++++++- lua/plugins/windows.lua | 21 ++ lua/util/init.lua | 194 +++++++++- lua/util/packer.lua | 44 +-- plugin/packer_compiled.lua | 468 ++++++++++++++++++++++++- selene.toml | 1 + sessions/%home%kjuulh%.config%nvim.vim | 55 +++ stylua.toml | 3 + vim.toml | 2 + 32 files changed, 2292 insertions(+), 60 deletions(-) create mode 100644 lua/config/commands.lua create mode 100644 lua/config/mappings.lua create mode 100644 lua/config/options.lua create mode 100644 lua/plugins/autopairs.lua create mode 100644 lua/plugins/bufferline.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/colorizer.lua create mode 100644 lua/plugins/dashboard.lua create mode 100644 lua/plugins/indent-blankline.lua create mode 100644 lua/plugins/lsp/diagnostics.lua create mode 100644 lua/plugins/lsp/formatting.lua create mode 100644 lua/plugins/lsp/init.lua create mode 100644 lua/plugins/lsp/kind.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/luasnip.lua create mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/neoscroll.lua create mode 100644 lua/plugins/null-ls.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/tokyonight.lua create mode 100644 lua/plugins/windows.lua create mode 100644 selene.toml create mode 100644 sessions/%home%kjuulh%.config%nvim.vim create mode 100644 stylua.toml create mode 100644 vim.toml diff --git a/init.lua b/init.lua index 5c709da..072a2be 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,11 @@ local util = require("util") +util.require("config.options") + vim.schedule(function() - util.packer_deferred() + util.packer_defered() + util.version() + util.require("config.mappings") + util.require("config.commands") util.require("config.plugins") end) diff --git a/lua/config/commands.lua b/lua/config/commands.lua new file mode 100644 index 0000000..044a588 --- /dev/null +++ b/lua/config/commands.lua @@ -0,0 +1,21 @@ +-- Check if we need to reload the file when it changed +vim.cmd("au FocusGained * :checktime") + +-- show cursor line only in active window +vim.cmd([[ + autocmd InsertLeave,WinEnter * set cursorline + autocmd InsertEnter,WinLeave * set nocursorline +]]) + +-- create directories when needed, when saving a file +vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("auto_create_dir", { clear = true }), + command = [[call mkdir(expand(':p:h'), 'p')]], +}) + +-- Highlight on yank +vim.cmd("au TextYankPost * lua vim.highlight.on_yank {}") + +-- windows to close with "q" +vim.cmd([[autocmd FileType help,startuptime,qf,lspinfo nnoremap q :close]]) +vim.cmd([[autocmd FileType man nnoremap q :quit]]) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua new file mode 100644 index 0000000..2a96778 --- /dev/null +++ b/lua/config/mappings.lua @@ -0,0 +1,275 @@ +---@diagnostic disable: missing-parameter + +local wk = require("which-key") +local util = require("util") + +vim.o.timeoutlen = 300 + +wk.setup({ + show_help = false, + triggers = "auto", + plugins = { spelling = true }, + key_labels = { [""] = "SPC" }, +}) + +-- Move to window using the movement keys +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") +vim.keymap.set("n", "", "l") + +-- Resize window using arrow keys +vim.keymap.set("n", "", "resize +2") +vim.keymap.set("n", "", "resize -2") +vim.keymap.set("n", "", "vertical resize -2") +vim.keymap.set("n", "", "vertical resize +2") + +-- Move Lines +vim.keymap.set("n", "", ":m .+1==") +vim.keymap.set("v", "", ":m '>+1gv=gv") +vim.keymap.set("i", "", ":m .+1==gi") +vim.keymap.set("n", "", ":m .-2==") +vim.keymap.set("v", "", ":m '<-2gv=gv") +vim.keymap.set("i", "", ":m .-2==gi") + +-- Switch buffers with tab +vim.keymap.set("n", "", "bprevious") +vim.keymap.set("n", "", "bnext") + +-- Easier pasting +vim.keymap.set("n", "[p", ":pu!") +vim.keymap.set("n", "]p", ":pu") + +-- Clear search with +vim.keymap.set("", "", ":noh") +vim.keymap.set("n", "gw", "*N") +vim.keymap.set("x", "gw", "*N") + +-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n +vim.keymap.set("n", "n", "'Nn'[v:searchforward]", { expr = true }) +vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true }) +vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true }) +vim.keymap.set("n", "N", "'nN'[v:searchforward]", { expr = true }) +vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true }) +vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true }) + +-- Add undo break-points +vim.keymap.set("i", ",", ",u") +vim.keymap.set("i", ".", ".u") +vim.keymap.set("i", ";", ";u") + +-- save in insert mode +vim.keymap.set("i", "", ":w") +vim.keymap.set("n", "", ":w") +vim.keymap.set("n", "", "normal ciwa") + +-- telescope in command line +-- vim.cmd([[cmap (TelescopeFuzzyCommandSearch)]]) + +-- better indenting +vim.keymap.set("v", "<", "", ">gv") + +vim.keymap.set("n", "cu", function() + local number = math.random(math.pow(2, 127) + 1, math.pow(2, 128)) + return "i" .. string.format("%.0f", number) +end, { + expr = true, + desc = "GUID", +}) + +-- makes * and # work on visual mode too. +vim.cmd([[ + function! g:VSetSearch(cmdtype) + let temp = @s + norm! gv"sy + let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g') + let @s = temp + endfunction + xnoremap * :call g:VSetSearch('/')/=@/ + xnoremap # :call g:VSetSearch('?')?=@/ +]]) + +local leader = { + ["w"] = { + name = "+windows", + ["w"] = { "p", "other-window" }, + ["d"] = { "c", "delete-window" }, + ["-"] = { "s", "split-window-below" }, + ["|"] = { "v", "split-window-right" }, + ["2"] = { "v", "layout-double-columns" }, + ["h"] = { "h", "window-left" }, + ["j"] = { "j", "window-below" }, + ["l"] = { "l", "window-right" }, + ["k"] = { "k", "window-up" }, + ["H"] = { "5<", "expand-window-left" }, + ["J"] = { ":resize +5", "expand-window-below" }, + ["L"] = { "5>", "expand-window-right" }, + ["K"] = { ":resize -5", "expand-window-up" }, + ["="] = { "=", "balance-window" }, + ["s"] = { "s", "split-window-below" }, + ["v"] = { "v", "split-window-right" }, + }, + c = { + name = "+code", + }, + b = { + name = "+buffer", + ["b"] = { ":e #", "Switch to Other Buffer" }, + ["p"] = { ":BufferLineCyclePrev", "Previous Buffer" }, + ["["] = { ":BufferLineCyclePrev", "Previous Buffer" }, + ["n"] = { ":BufferLineCycleNext", "Next Buffer" }, + ["]"] = { ":BufferLineCycleNext", "Next Buffer" }, + ["d"] = { ":Bdelete", "Delete Buffer" }, + ["D"] = { ":bd", "Delete Buffer & Window" }, + }, + g = { + name = "+git", + l = { + function() + require("util").float_terminal("lazygit") + end, + "LazyGit", + }, + c = { "Telescope git_commits", "commits" }, + b = { "Telescope git_branches", "branches" }, + s = { "Telescope git_status", "status" }, + d = { "DiffviewOpen", "DiffView" }, + h = { name = "+hunk" }, + }, + ["h"] = { + name = "+help", + t = { ":Telescope builtin", "Telescope" }, + c = { ":Telescope commands", "Commands" }, + h = { ":Telescope help_tags", "Help Pages" }, + m = { ":Telescope man_pages", "Man Pages" }, + k = { ":Telescope keymaps", "Key Maps" }, + s = { ":Telescope highlights", "Search Highlight Groups" }, + l = { [[TSHighlightCapturesUnderCursor]], "Highlight Groups at cursor" }, + f = { ":Telescope filetypes", "File Types" }, + o = { ":Telescope vim_options", "Options" }, + a = { ":Telescope autocommands", "Auto Commands" }, + p = { + name = "+packer", + p = { "PackerSync", "Sync" }, + s = { "PackerStatus", "Status" }, + i = { "PackerInstall", "Install" }, + c = { "PackerCompile", "Compile" }, + }, + }, + s = { + name = "+search", + g = { "Telescope live_grep", "Grep" }, + b = { "Telescope current_buffer_fuzzy_find", "Buffer" }, + s = { + function() + require("telescope.builtin").lsp_document_symbols({ + symbols = { "Class", "Function", "Method", "Constructor", "Interface", "Module", "Struct", "Trait" }, + }) + end, + "Goto Symbol", + }, + h = { "Telescope command_history", "Command History" }, + m = { "Telescope marks", "Jump to Mark" }, + r = { "lua require('spectre').open()", "Replace (Spectre)" }, + }, + f = { + name = "+file", + t = { "Neotree toggle", "NeoTree" }, + f = { "Telescope find_files", "Find File" }, + r = { "Telescope oldfiles", "Open Recent File" }, + n = { "enew", "New File" }, + z = "Zoxide", + d = "Dot Files", + }, + o = { + name = "+open", + p = { "MarkdownPreview", "Markdown Preview" }, + g = { "Glow", "Markdown Glow" }, + n = { "lua require('github-notifications.menu').notifications()", "GitHub Notifications" }, + }, + p = { + name = "+project", + p = "Open Project", + b = { ":Telescope file_browser cwd=~/projects", "Browse ~/projects" }, + }, + t = { + name = "toggle", + f = { + require("plugins.lsp.formatting").toggle, + "Format on Save", + }, + s = { + function() + util.toggle("spell") + end, + "Spelling", + }, + w = { + function() + util.toggle("wrap") + end, + "Word Wrap", + }, + n = { + function() + util.toggle("relativenumber", true) + util.toggle("number") + end, + "Line Numbers", + }, + }, + [""] = { + name = "tabs", + [""] = { "tabnew", "New Tab" }, + n = { "tabnext", "Next" }, + d = { "tabclose", "Close" }, + p = { "tabprevious", "Previous" }, + ["]"] = { "tabnext", "Next" }, + ["["] = { "tabprevious", "Previous" }, + f = { "tabfirst", "First" }, + l = { "tablast", "Last" }, + }, + ["`"] = { ":e #", "Switch to Other Buffer" }, + [" "] = "Find File", + ["."] = { ":Telescope file_browser", "Browse Files" }, + [","] = { "Telescope buffers show_all_buffers=true", "Switch Buffer" }, + ["/"] = { "Telescope live_grep", "Search" }, + [":"] = { "Telescope command_history", "Command History" }, + ["C"] = { + function() + util.clipman() + end, + "Paste from Clipman", + }, + ["P"] = { + ":Telescope neoclip plus", + "Paste from Clipman", + }, + q = { + name = "+quit/session", + q = { "qa", "Quit" }, + ["!"] = { ":qa!", "Quit without saving" }, + s = { [[lua require("persistence").load()]], "Restore Session" }, + l = { [[lua require("persistence").load({last=true})]], "Restore Last Session" }, + d = { [[lua require("persistence").stop()]], "Stop Current Session" }, + }, + x = { + name = "+errors", + x = { "TroubleToggle workspace_diagnostics", "Trouble" }, + t = { "TodoTrouble", "Todo Trouble" }, + T = { "TodoTelescope", "Todo Telescope" }, + l = { "lopen", "Open Location List" }, + q = { "copen", "Open Quickfix List" }, + }, + z = { [[ZenMode]], "Zen Mode" }, + T = { [[PlenaryTestFile]], "Plenary Test" }, +} + +for i = 0, 10 do + leader[tostring(i)] = "which_key_ignore" +end + +wk.register(leader, { prefix = "" }) + +wk.register({ g = { name = "+goto" } }) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..f2acef8 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,100 @@ +local indent = 2 + +vim.g.mapleader = " " +vim.g.maplocalleader = "," +vim.opt.tabstop = indent +vim.opt.termguicolors = true +vim.opt.autowrite = true -- enable auto write +vim.opt.clipboard = "unnamedplus" -- sync with system clipboard +vim.opt.concealcursor = "nc" -- Hide * markup for bold and italic +vim.opt.conceallevel = 3 -- Hide * markup for bold and italic +vim.opt.confirm = true -- confirm to save changes before exiting modified buffer +vim.opt.cursorline = true -- Enable highlighting of the current line +vim.opt.expandtab = true -- Use spaces instead of tabs + +vim.opt.guifont = "FiraCode Nerd Font:h12" +vim.opt.grepprg = "rg --vimgrep" +vim.opt.grepformat = "%f:%l:%c:%m" +vim.opt.hidden = true -- Enable modified buffers in background +vim.opt.ignorecase = true -- Ignore case +vim.opt.inccommand = "split" -- preview incremental substitute +vim.opt.joinspaces = false -- No double spaces with join after a dot +vim.opt.list = true -- Show some invisible characters (tabs... +vim.opt.mouse = "a" -- enable mouse mode +vim.opt.number = true -- Print line number +vim.opt.pumblend = 10 -- Popup blend +vim.opt.pumheight = 10 -- Maximum number of entries in a popup +vim.opt.relativenumber = true -- Relative line numbers +vim.opt.scrolloff = 4 -- Lines of context +vim.opt.shiftround = true -- Round indent +vim.opt.shiftwidth = indent -- Size of an indent +vim.opt.showmode = false -- dont show mode since we have a statusline +vim.opt.sidescrolloff = 8 -- Columns of context +vim.opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time +vim.opt.smartcase = true -- Don't ignore case with capitals +vim.opt.smartindent = true -- Insert indents automatically + +vim.opt.splitbelow = true -- Put new windows below current +vim.opt.splitright = true -- Put new windows right of current +vim.opt.tabstop = indent -- Number of spaces tabs count for +vim.opt.termguicolors = true -- True color support +vim.opt.undofile = true +vim.opt.undolevels = 10000 +vim.opt.updatetime = 200 -- save swap file and trigger CursorHold +vim.opt.wildmode = "longest:full,full" -- Command-line completion mode +vim.opt.wrap = false -- Disable line wrap +vim.opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } +vim.opt.fillchars = { + -- horiz = "\u2501", + -- horizup = "\u253b", + -- horizdown = "\u2533", + -- vert = "\u2503", + -- vertleft = "\u252b", + -- vertright = "\u2523", + -- verthoriz = "\u254b",im.o.fillchars = [[eob: , + -- fold = " ", + foldopen = "", + -- foldsep = " ", + foldclose = "", +} + +local builtins = { + "gzip", + "zip", + "zipPlugin", + "fzf", + "tar", + "tarPlugin", + "getscript", + "getscriptPlugin", + "vimball", + "vimballPlugin", + "2html_plugin", + "matchit", + "matchparen", + "logiPat", + "rrhelper", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", +} + +for _, plugin in ipairs(builtins) do + vim.g["loaded_" .. plugin] = 1 +end + +local fences = { + "lua", + -- "vim", + "json", + "typescript", + "javascript", + "js=javascript", + "ts=typescript", + "shell=sh", + "python", + "sh", + "console=sh", +} +vim.g.markdown_fenced_languages = fences diff --git a/lua/config/plugins.lua b/lua/config/plugins.lua index 4ff681e..d123705 100644 --- a/lua/config/plugins.lua +++ b/lua/config/plugins.lua @@ -5,21 +5,184 @@ local config = { auto_reload_compiled = false, } - local function plugins(use, plugin) - -- Bootstrap + ---- Bootstrap use({ "wbthomason/packer.nvim" }) - -- Explorer + -- UI + use({ "stevearc/dressing.nvim", event = "User PackerDefered" }) + + -- Layout + use({ + "folke/noice.nvim", + module = "noice", + event = "VimEnter", + config = function() + require("noice").setup() + end, + }) + plugin("anuvyklack/windows.nvim") + + -- Notifications + use({ + "rcarriga/nvim-notify", + event = "User PackerDefered", + module = "notify", + config = function() + require("notify").setup({ level = vim.log.levels.INFO, fps = 20 }) + vim.notify = require("notify") + end, + }) + + ---- Explorer plugin("nvim-neo-tree/neo-tree.nvim") use({ "MunifTanjim/nui.nvim", module = "nui", }) + use({ + "danymat/neogen", + module = "neogen", + config = function() + require("neogen").setup({ snippet_engine = "luasnip" }) + end, + }) - --plugin("nvim-treesitter/nvim-treesitter") + -- Status bar + use({ + "SmiteshP/nvim-navic", + module = "nvim-navic", + config = function() + vim.g.navic_silence = true + require("nvim-navic").setup({ separator = " ", highlight = true, depth_limit = 5 }) + end, + }) + + plugin("nvim-lualine/lualine.nvim") + + -- Bufferline + plugin("nvim-telescope/telescope.nvim") + + plugin("lukas-reineke/indent-blankline.nvim") + plugin("akinsho/nvim-bufferline.lua") + + plugin("NvChad/nvim-colorizer.lua") + + -- Dashboard + plugin("glepnir/dashboard-nvim") + + -- Notify + use({ + "j-hui/fidget.nvim", + module = "fidget", + config = function() + require("fidget").setup({ + window = { + relative = "editor", + }, + }) + -- HACK: prevent error when exiting Neovim + vim.api.nvim_create_autocmd("VimLeavePre", { command = [[silent! FidgetClose]] }) + end, + }) + + -- smooth scrolling + plugin("karb94/neoscroll.nvim") + + ---- Code + -- Formatting + plugin("jose-elias-alvarez/null-ls.nvim") + use({ "folke/lua-dev.nvim", module = "lua-dev" }) + + -- LSP + use({ "neovim/nvim-lspconfig", plugin = "lsp" }) + plugin("williamboman/mason.nvim") + use({ + "williamboman/mason-lspconfig.nvim", + module = "mason-lspconfig", + }) + + -- Autocomplete + plugin("hrsh7th/nvim-cmp") + + use({ + "folke/trouble.nvim", + event = "BufReadPre", + module = "trouble", + cmd = { "TroubleToggle", "Trouble" }, + config = function() + require("trouble").setup({ + auto_open = false, + use_diagnostic_signs = true, -- en + }) + end, + }) + + -- Utility + plugin("windwp/nvim-autopairs") + + -- Yanking + use({ + "AckslD/nvim-neoclip.lua", + event = "TextYankPost", + module = "telescope._extensions.neoclip", + requires = { { "kkharji/sqlite.lua", module = "sqlite" } }, + config = function() + require("neoclip").setup({ + enable_persistent_history = true, + continuous_sync = true, + }) + end, + }) + + -- Session management + use({ + "folke/persistence.nvim", + event = "BufReadPre", + module = "persistence", + config = function() + require("persistence").setup() + end, + }) + use({ + "dstein64/vim-startuptime", + cmd = "StartupTime", + config = function() + vim.g.startuptime_tries = 10 + end, + }) + + -- Snippets + plugin("L3MON4D3/LuaSnip") + + -- Syntax use({ "nvim-lua/plenary.nvim", module = "plenary" }) + plugin("nvim-treesitter/nvim-treesitter") + use({ "nvim-treesitter/playground", cmd = { "TSHighlightCapturesUnderCursor", "TSPlaygroundToggle" } }) + + use({ + "m-demare/hlargs.nvim", + module = "hlargs", + event = "User PackerDefered", + requires = { + "nvim-treesitter", + }, + config = function() + require("hlargs").setup({ + color = require("tokyonight.colors").setup().yellow, + }) + end, + }) + + use({ + "folke/which-key.nvim", + module = "which-key", + }) + + -- Theme: color scheme + plugin("folke/tokyonight.nvim") + -- Theme: Icons use({ "kyazdani42/nvim-web-devicons", @@ -28,12 +191,6 @@ local function plugins(use, plugin) require("nvim-web-devicons").setup({ default = true }) end, }) - - plugin("nvim-treesitter/nvim-treesitter") - - use({ "nvim-treesitter/playground", cmd = { "TSHighlightCapturesUnderCursor", "TSPlaygroundToggle" } }) - - end return packer.setup(config, plugins) diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..061c622 --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,12 @@ +return { + module = "nvim-autopairs", + config = function() + local npairs = require("nvim-autopairs") + npairs.setup({ + check_ts = true, + ts_config = { + lua = { "string", "comment" }, + }, + }) + end, +} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..247e932 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,56 @@ +local M = { + event = "BufReadPre", +} + +function M.config() + local signs = require("plugins.lsp.diagnostics").signs + + signs = { + error = signs.Error, + warning = signs.Warn, + info = signs.Info, + hint = signs.Hint, + } + + local severities = { + "error", + "warning", + -- "info", + -- "hint", + } + + require("bufferline").setup({ + options = { + show_close_icon = true, + diagnostics = "nvim_lsp", + always_show_bufferline = false, + separator_style = "thick", + diagnostics_indicator = function(_, _, diag) + local s = {} + for _, severity in ipairs(severities) do + if diag[severity] then + table.insert(s, signs[severity] .. diag[severity]) + end + end + return table.concat(s, " ") + end, + offsets = { + { + filetype = "neo-tree", + text = "Neo Tree", + highlight = "Directory", + text_align = "left", + }, + }, + }, + }) +end + +-- function M.init() +-- vim.keymap.set("n", "bp", ":BufferLineCyclePrev", { desc = "Previous Buffer" }) +-- vim.keymap.set("n", "bn", ":BufferLineCycleNext", { desc = "Next Buffer" }) +-- vim.keymap.set("n", "[b", ":BufferLineCyclePrev", { desc = "Previous Buffer" }) +-- vim.keymap.set("n", "]b", ":BufferLineCycleNext", { desc = "Next Buffer" }) +-- end + +return M diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..cd8b3d7 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,60 @@ +local M = { + event = "InsertEnter", + module = "cmp", + requires = { + { "hrsh7th/cmp-nvim-lsp", module = "cmp_nvim_lsp" }, + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-emoji", + "hrsh7th/cmp-cmdline", + "dmitmel/cmp-cmdline-history", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp-signature-help", + }, +} + +function M.config() + vim.o.completeopt = "menuone,noselect" + + -- Setup nvim-cmp. + local cmp = require("cmp") + + cmp.setup({ + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + { name = "emoji" }, + { name = "nvim_lsp_signature_help" }, + }), + formatting = { + format = require("plugins.lsp.kind").cmp_format(), + }, + experimental = { + ghost_text = { + hl_group = "LspCodeLens", + }, + }, + }) + + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) +end + +return M diff --git a/lua/plugins/colorizer.lua b/lua/plugins/colorizer.lua new file mode 100644 index 0000000..f09eebb --- /dev/null +++ b/lua/plugins/colorizer.lua @@ -0,0 +1,26 @@ +return { + event = "BufReadPre", + config = function() + require("colorizer").setup({ + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue + RRGGBBAA = true, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = true, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes: foreground, background + -- Available modes for `mode`: foreground, background, virtualtext + mode = "background", -- Set the display mode. + virtualtext = "■", + }, + }) + + vim.cmd( + [[autocmd ColorScheme * lua package.loaded['colorizer'] = nil; require('colorizer').setup(); require('colorizer').attach_to_buffer(0)]] + ) + end, +} diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua new file mode 100644 index 0000000..3ea72fb --- /dev/null +++ b/lua/plugins/dashboard.lua @@ -0,0 +1,33 @@ +return { + opt = false, + config = function() + local db = require("dashboard") + + local logo = [[ +███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗ +████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║ +██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║ +██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║ +██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║ +╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ +]] + local lines = {} + for line in logo:gmatch("[^\n]+") do + table.insert(lines, line) + end + + db.custom_header = lines + + vim.g.dashboard_custom_header = lines + + vim.g.dashboard_custom_shortcut = { + ["last_session"] = "SPC s l", + ["find_history"] = "SPC f r", + ["find_file"] = "SPC spc", + ["new_file"] = "SPC f n", + ["change_colorscheme"] = "SPC h c", + ["find_word"] = "SPC f g", + ["book_marks"] = "SPC f b", + } + end, +} diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..13f3ec1 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,53 @@ +local M = {} + +M.event = "BufReadPre" + +function M.config() + local indent = require("indent_blankline") + + --- PERF: debounce indent-blankline refresh + local refresh = indent.refresh + indent.refresh = require("util").debounce(100, refresh) + + indent.setup({ + buftype_exclude = { "terminal", "nofile" }, + filetype_exclude = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "neo-tree", + "Trouble", + }, + char = "│", + use_treesitter_scope = false, + show_trailing_blankline_indent = false, + show_current_context = true, + context_patterns = { + "class", + "return", + "function", + "method", + "^if", + "^while", + "jsx_element", + "^for", + "^object", + "^table", + "block", + "arguments", + "if_statement", + "else_clause", + "jsx_element", + "jsx_self_closing_element", + "try_statement", + "catch_clause", + "import_statement", + "operation_type", + }, + }) +end + +return M diff --git a/lua/plugins/lsp/diagnostics.lua b/lua/plugins/lsp/diagnostics.lua new file mode 100644 index 0000000..61ba212 --- /dev/null +++ b/lua/plugins/lsp/diagnostics.lua @@ -0,0 +1,26 @@ +local M = {} + +M.signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } + +function M.setup() + -- Automatically update diagnostics + vim.diagnostic.config({ + underline = true, + update_in_insert = false, + virtual_text = { spacing = 4, prefix = "●" }, + severity_sort = true, + }) + + vim.lsp.handlers["workspace/diagnostic/refresh"] = function(_, _, ctx) + local ns = vim.lsp.diagnostic.get_namespace(ctx.client_id) + pcall(vim.diagnostic.reset, ns) + return true + end + + for type, icon in pairs(M.signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end +end + +return M diff --git a/lua/plugins/lsp/formatting.lua b/lua/plugins/lsp/formatting.lua new file mode 100644 index 0000000..3a85415 --- /dev/null +++ b/lua/plugins/lsp/formatting.lua @@ -0,0 +1,59 @@ +local util = require("util") + +local M = {} + +-- vim.lsp.handlers["textDocument/hover"] = function(_, method, result) +-- print(vim.inspect(result)) +-- end + +M.autoformat = true + +function M.toggle() + M.autoformat = not M.autoformat + if M.autoformat then + util.info("enabled format on save", "Formatting") + else + util.warn("disabled format on save", "Formatting") + end +end + +function M.format() + if M.autoformat then + if vim.lsp.buf.format then + vim.lsp.buf.format() + else + vim.lsp.buf.formatting_sync() + end + end +end + +function M.setup(client, buf) + local ft = vim.api.nvim_buf_get_option(buf, "filetype") + local nls = require("plugins.null-ls") + + local enable = false + if nls.has_formatter(ft) then + enable = client.name == "null-ls" + else + enable = not (client.name == "null-ls") + end + + if client.name == "tsserver" then + enable = false + end + + -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format") + + client.server_capabilities.documentFormattingProvider = enable + -- format on save + if client.server_capabilities.documentFormattingProvider then + vim.cmd([[ + augroup LspFormat + autocmd! * + autocmd BufWritePre lua require("plugins.lsp.formatting").format() + augroup END + ]]) + end +end + +return M diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua new file mode 100644 index 0000000..cd022f6 --- /dev/null +++ b/lua/plugins/lsp/init.lua @@ -0,0 +1,91 @@ +local M = { + event = "BufReadPre" +} + +function M.config() + require("lua-dev").setup({ + library = { + runtime = "~/projects/neovim/runtime/" + } + }) + require("mason") + require("plugins.lsp.diagnostics").setup() + require("fidget").setup({text = {spinner = "dots"} }) + local function on_attach(client, bufnr) + --require("nvim-navic").attach(client, bufnr) + require("plugins.lsp.formatting").setup(client, bufnr) + --require("plugins.lsp.keys").setup(client, bufnr) + end + + ---@type lspconfig.options + local servers = { + sumneko_lua = { + single_file_support = true, + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + workspaceWord = false, + }, + misc = { + parameters = { + "--log-level=trace", + }, + }, + diagnostics = { + groupFileStatus = { + ["ambiguity"] = "Opened", + ["await"] = "Opened", + ["codestyle"] = "None", + ["duplicate"] = "Opened", + ["global"] = "Opened", + ["luadoc"] = "Opened", + ["redefined"] = "Opened", + ["strict"] = "Opened", + ["strong"] = "Opened", + ["type-check"] = "Opened", + ["unbalanced"] = "Opened", + ["unused"] = "Opened", + }, + unusedLocalExclude = { "_*" }, + }, + format = { + enable = false, + defaultConfig = { + indent_style = "space", + indent_size = "2", + continuation_indent_size = "2", + }, + }, + }, + }, + }, + vimls = {}, + } + local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) + capabilities.textDocument.foldingRange = { + dymanicRegistration = false, + lineFoldingOnly = true, + } + + ---@type _.lspconfig.options + local options = { + on_attach = on_attach, + capabilities = capabilities, + flags = { + debounce_text_change = 150, + } + } + + for server, opts in pairs(servers) do + opts = vim.tbl_deep_extend("force", {}, options, opts or {}) + require("lspconfig")[server].setup(opts) + end + + require("plugins.null-ls").setup(options) + +end + +return M diff --git a/lua/plugins/lsp/kind.lua b/lua/plugins/lsp/kind.lua new file mode 100644 index 0000000..3450edb --- /dev/null +++ b/lua/plugins/lsp/kind.lua @@ -0,0 +1,36 @@ +local M = {} + +M.icons = { + Class = " ", + Color = " ", + Constant = " ", + Constructor = " ", + Enum = "了 ", + EnumMember = " ", + Field = " ", + File = " ", + Folder = " ", + Function = " ", + Interface = "ﰮ ", + Keyword = " ", + Method = "ƒ ", + Module = " ", + Property = " ", + Snippet = "﬌ ", + Struct = " ", + Text = " ", + Unit = " ", + Value = " ", + Variable = " ", +} + +function M.cmp_format() + return function(_entry, vim_item) + if M.icons[vim_item.kind] then + vim_item.kind = M.icons[vim_item.kind] .. vim_item.kind + end + return vim_item + end +end + +return M diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..95b6811 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,86 @@ +local M = { + module = "lualine", + event = "User PackerDefered", +} + +local function clock() + return " " .. os.date("%H:%M") +end + +local function holidays() + return "🌴🌊" + -- return "\U0001f385\U0001f384\U0001f31f\U0001f381" +end + +function M.config() + require("lualine").setup({ + options = { + theme = "auto", + section_separators = { left = "", right = "" }, + component_separators = { left = "", right = "" }, + icons_enabled = true, + globalstatus = true, + disabled_filetypes = { statusline = { "dashboard" } }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch" }, + lualine_c = { + { "diagnostics", sources = { "nvim_diagnostic" } }, + { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, + { "filename", path = 1, symbols = { modified = "  ", readonly = "", unnamed = "" } }, + { + function() + local navic = require("nvim-navic") + local ret = navic.get_location() + return ret:len() > 2000 and "navic error" or ret + end, + cond = function() + local navic = require("nvim-navic") + return navic.is_available() + end, + color = { fg = "#ff9e64" }, + }, + }, + lualine_x = { + -- { + -- require("noice.status").message.get_hl, + -- cond = require("noice.status").message.has, + -- }, + -- { + -- require("noice.status").command.get, + -- cond = require("noice.status").command.has, + -- color = { fg = "#ff9e64" }, + -- }, + -- { + -- require("noice.status").mode.get, + -- cond = require("noice.status").mode.has, + -- color = { fg = "#ff9e64" }, + -- }, + -- { + -- require("noice.status").search.get, + -- cond = require("noice.status").search.has, + -- color = { fg = "#ff9e64" }, + -- }, + -- function() + -- return require("messages.view").status + -- end, + -- { require("github-notifications").statusline_notification_count }, + { holidays }, + }, + lualine_y = { "location" }, + lualine_z = { clock }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + }, + extensions = { "nvim-tree" }, + }) +end + +return M diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua new file mode 100644 index 0000000..b3cfcab --- /dev/null +++ b/lua/plugins/luasnip.lua @@ -0,0 +1,49 @@ +local M = { + module = "luasnip", + requires = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, +} + +function M.config() + local util = require("util") + local luasnip = require("luasnip") + require("neogen") + + luasnip.config.setup({ + history = true, + enable_autosnippets = true, + -- Update more often, :h events for more info. + -- updateevents = "TextChanged,TextChangedI", + }) + + --- to jump to next snippet's placeholder + local function on_tab() + return luasnip.jump(1) and "" or util.t("") + end + + --- to jump to next snippet's placeholder + local function on_s_tab() + return luasnip.jump(-1) and "" or util.t("") + end + + -- vim.keymap.set("i", "", on_tab, { expr = true }) + -- vim.keymap.set("s", "", on_tab, { expr = true }) + -- vim.keymap.set("i", "", on_s_tab, { expr = true }) + -- vim.keymap.set("s", "", on_s_tab, { expr = true }) + + vim.cmd([[ +" press to expand or jump in a snippet. These can also be mapped separately +" via luasnip-expand-snippet and luasnip-jump-next. +imap luasnip#expand_or_jumpable() ? 'luasnip-expand-or-jump' : '' +" -1 for jumping backwards. +inoremap lua require'luasnip'.jump(-1) +snoremap lua require('luasnip').jump(1) +snoremap lua require('luasnip').jump(-1) +]]) +end + +return M diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..a27c38e --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,28 @@ +local M = { + module = "mason", +} + +M.tools = { + "stylua", + "selene", +} + +function M.check() + local mr = require("mason-registry") + for _, tool in ipairs(M.tools) do + local p = mr.get_package(tool) + if not p:is_installed() then + p:install() + end + end +end + +function M.config() + require("mason").setup() + M.check() + require("mason-lspconfig").setup({ + automatic_installation = true, + }) +end + +return M diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index b10bb3c..2c94596 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -1,8 +1,8 @@ return { - cmd = "Neotree", - config = function() - vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + cmd = "Neotree", + config = function() + vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - require("neo-tree").setup({filesystem = {follow_current_file = true}}) - end, + require("neo-tree").setup({ filesystem = { follow_current_file = true } }) + end, } diff --git a/lua/plugins/neoscroll.lua b/lua/plugins/neoscroll.lua new file mode 100644 index 0000000..b9d099c --- /dev/null +++ b/lua/plugins/neoscroll.lua @@ -0,0 +1,19 @@ +return { + keys = { "", "", "gg", "G" }, + config = function() + require("neoscroll").setup({}) + local map = {} + + map[""] = { "scroll", { "-vim.wo.scroll", "true", "80" } } + map[""] = { "scroll", { "vim.wo.scroll", "true", "80" } } + map[""] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "250" } } + map[""] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "250" } } + map[""] = { "scroll", { "-0.10", "false", "80" } } + map[""] = { "scroll", { "0.10", "false", "80" } } + map["zt"] = { "zt", { "150" } } + map["zz"] = { "zz", { "150" } } + map["zb"] = { "zb", { "150" } } + + require("neoscroll.config").set_mappings(map) + end, +} diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua new file mode 100644 index 0000000..7b44a56 --- /dev/null +++ b/lua/plugins/null-ls.lua @@ -0,0 +1,34 @@ +local M = { module = "null-ls" } + +function M.setup(options) + local nls = require("null-ls") + nls.setup({ + debounce = 150, + save_after_format = false, + sources = { + -- nls.builtins.formatting.prettierd, + nls.builtins.formatting.stylua, + nls.builtins.formatting.fish_indent, + -- nls.builtins.formatting.fixjson.with({ filetypes = { "jsonc" } }), + -- nls.builtins.formatting.eslint_d, + -- nls.builtins.diagnostics.shellcheck, + --nls.builtins.formatting.shfmt, + --nls.builtins.diagnostics.markdownlint, + -- nls.builtins.formatting.deno_fmt.with({ + -- filetypes = { "markdown" }, -- only runs `deno fmt` for markdown + -- }), + -- nls.builtins.diagnostics.selene, + -- nls.builtins.code_actions.gitsigns, + }, + on_attach = options.on_attach, + root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".nvim.settings.json", ".git"), + }) +end + +function M.has_formatter(ft) + local sources = require("null-ls.sources") + local available = sources.get_available(ft, "NULL_LS_FORMATTING") + return #available > 0 +end + +return M diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..766c478 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,123 @@ +local M = { + cmd = { "Telescope" }, + module = "telescope", + requires = { + { "nvim-telescope/telescope-file-browser.nvim", module = "telescope._extensions.file_browser" }, + { "nvim-telescope/telescope-z.nvim", module = "telescope._extensions.z" }, + { "nvim-telescope/telescope-project.nvim", module = "telescope._extensions.project" }, + { "nvim-telescope/telescope-symbols.nvim", module = "telescope._extensions.symbols" }, + { "nvim-telescope/telescope-fzf-native.nvim", module = "telescope._extensions.fzf", run = "make" }, + }, +} + +function M.project_files(opts) + opts = opts or {} + opts.show_untracked = true + local ok = pcall(require("telescope.builtin").git_files, opts) + if not ok then + local client = vim.lsp.get_active_clients()[1] + if client then + opts.cwd = client.config.root_dir + end + require("telescope.builtin").find_files(opts) + end +end + +function M.config() + -- local actions = require("telescope.actions") + local trouble = require("trouble.providers.telescope") + + local telescope = require("telescope") + local borderless = true + telescope.setup({ + extensions = { + -- fzf = { + -- fuzzy = true, -- false will only do exact matching + -- override_generic_sorter = true, -- override the generic sorter + -- override_file_sorter = true, -- override the file sorter + -- case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- -- the default case_mode is "smart_case" + -- }, + }, + defaults = { + layout_strategy = "horizontal", + layout_config = { + prompt_position = "top", + }, + sorting_strategy = "ascending", + mappings = { i = { [""] = trouble.open_with_trouble } }, + -- mappings = { i = { [""] = actions.close } }, + -- vimgrep_arguments = { + -- 'rg', + -- '--color=never', + -- '--no-heading', + -- '--with-filename', + -- '--line-number', + -- '--column', + -- '--smart-case' + -- }, + -- prompt_position = "bottom", + prompt_prefix = " ", + selection_caret = " ", + -- entry_prefix = " ", + -- initial_mode = "insert", + -- selection_strategy = "reset", + -- sorting_strategy = "descending", + -- layout_strategy = "horizontal", + -- layout_defaults = { + -- horizontal = { + -- mirror = false, + -- }, + -- vertical = { + -- mirror = false, + -- }, + -- }, + -- file_sorter = require"telescope.sorters".get_fzy_file + -- file_ignore_patterns = {}, + -- generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, + -- shorten_path = true, + winblend = borderless and 0 or 10, + -- width = 0.7, + -- preview_cutoff = 120, + -- results_height = 1, + -- results_width = 0.8, + -- border = false, + -- color_devicons = true, + -- use_less = true, + -- set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil, + -- file_previewer = require'telescope.previewers'.vim_buffer_cat.new, + -- grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, + -- qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, + + -- -- Developer configurations: Not meant for general override + -- buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker + }, + }) + + -- telescope.load_extension("frecency") + telescope.load_extension("fzf") + telescope.load_extension("z") + telescope.load_extension("file_browser") + telescope.load_extension("neoclip") + -- telescope.load_extension("project") +end + +function M.init() + vim.keymap.set("n", "", function() + require("plugins.telescope").project_files() + end, { desc = "Find File" }) + + vim.keymap.set("n", "fd", function() + require("telescope.builtin").git_files({ cwd = "~/dot" }) + end, { desc = "Find Dot File" }) + + vim.keymap.set("n", "fz", function() + require("telescope").extensions.z.list({ cmd = { vim.o.shell, "-c", "zoxide query -ls" } }) + end, { desc = "Find Zoxide" }) + + vim.keymap.set("n", "pp", function() + require("telescope").extensions.project.project({}) + end, { desc = "Find Project" }) +end + +return M diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua new file mode 100644 index 0000000..0dc8ee4 --- /dev/null +++ b/lua/plugins/tokyonight.lua @@ -0,0 +1,59 @@ +return { + opt = false, + config = function() + -- vim.o.background = "dark" + local tokyonight = require("tokyonight") + tokyonight.setup({ + style = "moon", + -- transparent = true, + -- hide_inactive_statusline = false, + sidebars = { + "qf", + "vista_kind", + "terminal", + "packer", + "spectre_panel", + "NeogitStatus", + "help", + "startuptime", + "Outline", + }, + on_colors = function(c) end, + on_highlights = function(hl, c) + -- make the current line cursor orange + hl.CursorLineNr = { fg = c.orange, bold = true } + + -- borderless telescope + local prompt = "#2d3149" + hl.TelescopeNormal = { + bg = c.bg_dark, + fg = c.fg_dark, + } + hl.TelescopeBorder = { + bg = c.bg_dark, + fg = c.bg_dark, + } + hl.TelescopePromptNormal = { + bg = prompt, + } + hl.TelescopePromptBorder = { + bg = prompt, + fg = prompt, + } + hl.TelescopePromptTitle = { + bg = c.fg_gutter, + fg = c.orange, + } + hl.TelescopePreviewTitle = { + bg = c.bg_dark, + fg = c.bg_dark, + } + hl.TelescopeResultsTitle = { + bg = c.bg_dark, + fg = c.bg_dark, + } + end, + }) + tokyonight.load() + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 8ba63b2..2d72cac 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,23 +1,115 @@ local M = { - run = ":TSUpdate", - event = "User PackerDefered", - requires = { - "nvim-treesitter/nvim-treesitter-textobjects", - "RRethy/nvim-treesitter-textsubjects", - "nvim-treesitter/nvim-treesitter-refactor", - }, + run = ":TSUpdate", + event = "User PackerDefered", + module = "nvim-treesitter", + requires = { + "nvim-treesitter/nvim-treesitter-textobjects", + "RRethy/nvim-treesitter-textsubjects", + "nvim-treesitter/nvim-treesitter-refactor", + }, } function M.config() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "css", - "go", - "lua", - }, - sync_install = false, - auto_install = true, - }) + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "css", + "go", + "lua", + "vim", + "help", + "fish", + "gitignore", + }, + sync_install = false, + auto_install = true, + highlight = { enable = true }, + indent = { enable = false }, + context_commentstring = { enable = true, enable_autocmd = false }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + refactor = { + smart_rename = { + enable = true, + client = { + smart_rename = "cr", + }, + }, + navigation = { + enable = true, + keymaps = { + -- goto_definition = "gd", + -- list_definitions = "gnD", + -- list_definitions_toc = "gO", + -- goto_next_usage = "", + -- goto_previous_usage = "", + }, + }, + }, + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { "BufWrite", "CursorHold" }, + }, + textsubjects = { + enable = true, + keymaps = { + ["."] = "textsubjects-smart", + [";"] = "textsubjects-container-outer", + }, + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = true, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = "o", + toggle_hl_groups = "i", + toggle_injected_languages = "t", + toggle_anonymous_nodes = "a", + toggle_language_display = "I", + focus_language = "f", + unfocus_language = "F", + update = "R", + goto_node = "", + show_help = "?", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" }, + goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" }, + goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" }, + goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" }, + }, + lsp_interop = { + enable = true, + peek_definition_code = { + ["gD"] = "@function.outer", + }, + }, + }, + }) end return M diff --git a/lua/plugins/windows.lua b/lua/plugins/windows.lua new file mode 100644 index 0000000..abe878e --- /dev/null +++ b/lua/plugins/windows.lua @@ -0,0 +1,21 @@ +local M = { + event = "User PackerDefered", + requires = { + { "anuvyklack/middleclass", module = "middleclass" }, + { "anuvyklack/animation.nvim", module = "animation" }, + }, +} + +function M.config() + vim.o.winwidth = 5 + vim.o.winminwidth = 5 + vim.o.equalalways = false + require("windows").setup({ + animation = { + duration = 150, + }, + }) + vim.keymap.set("n", "Z", "WindowsMaximize") +end + +return M diff --git a/lua/util/init.lua b/lua/util/init.lua index 508461f..7a8a064 100644 --- a/lua/util/init.lua +++ b/lua/util/init.lua @@ -1,7 +1,44 @@ +-- selene: allow(global_usage) +_G.dump = function(...) + vim.pretty_print(...) +end + +_G.dumpp = function(...) + local msg = vim.inspect(...) + vim.notify("```lua\n" .. msg .. "\n```", vim.log.levels.INFO, { + title = "Debug", + on_open = function(win) + vim.api.nvim_win_set_option(win, "conceallevel", 3) + local buf = vim.api.nvim_win_get_buf(win) + vim.api.nvim_buf_set_option(buf, "filetype", "markdown") + vim.api.nvim_win_set_option(win, "spell", false) + end, + }) +end + +-- selene: allow(global_usage) +_G.profile = function(cmd, times) + times = times or 100 + local args = {} + if type(cmd) == "string" then + args = { cmd } + cmd = vim.cmd + end + local start = vim.loop.hrtime() + for _ = 1, times, 1 do + local ok = pcall(cmd, unpack(args)) + if not ok then + error("Command failed: " .. tostring(ok) .. " " .. vim.inspect({ cmd = cmd, args = args })) + end + end + print(((vim.loop.hrtime() - start) / 1000000 / times) .. "ms") +end + local M = {} -function M.packer_deferred() - vim.cmd([[do User PackerDefered]]) +function M.packer_defered() + --vim.cmd([[do User PackerDefered]]) + vim.api.nvim_exec_autocmds("User", { pattern = "PackerDefered" }) end function M.require(mod) @@ -38,4 +75,157 @@ function M.info(msg, name) vim.notify(msg, vim.log.levels.INFO, { title = name or "init.lua" }) end +function M.toggle(option, silent) + local info = vim.api.nvim_get_option_info(option) + local scopes = { buf = "bo", win = "wo", global = "o" } + local scope = scopes[info.scope] + local options = vim[scope] + options[option] = not options[option] + if silent ~= true then + if options[option] then + M.info("enabled vim." .. scope .. "." .. option, "Toggle") + else + M.warn("disabled vim." .. scope .. "." .. option, "Toggle") + end + end +end + +---@param fn fun(buf: buffer, win: window) +function M.float(fn) + local buf = vim.api.nvim_create_buf(false, true) + local vpad = 4 + local hpad = 10 + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = vim.o.columns - hpad * 2, + height = vim.o.lines - vpad * 2, + row = vpad, + col = hpad, + style = "minimal", + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }) + + local function close() + if vim.api.nvim_buf_is_valid(buf) then + vim.api.nvim_buf_delete(buf, { force = true }) + end + if vim.api.nvim_win_is_valid(win) then + vim.api.nvim_win_close(win, true) + end + end + + vim.keymap.set("n", "", close, { buffer = buf, nowait = true }) + vim.keymap.set("n", "q", close, { buffer = buf, nowait = true }) + vim.api.nvim_create_autocmd({ "BufDelete", "BufLeave", "BufHidden" }, { + once = true, + buffer = buf, + callback = close, + }) + fn(buf, win) +end + +function M.float_cmd(cmd) + M.float(function(buf) + local output = vim.api.nvim_exec(cmd, true) + local lines = vim.split(output, "\n") + vim.api.nvim_buf_set_lines(buf, 0, -1, true, lines) + end) +end + +function M.float_terminal(cmd) + M.float(function(buf, win) + vim.fn.termopen(cmd) + local autocmd = { + "autocmd! TermClose lua", + string.format("vim.api.nvim_win_close(%d, {force = true});", win), + string.format("vim.api.nvim_buf_delete(%d, {force = true});", buf), + } + vim.cmd(table.concat(autocmd, " ")) + vim.cmd([[startinsert]]) + end) +end + +function M.exists(fname) + local stat = vim.loop.fs_stat(fname) + return (stat and stat.type) or false +end + +function M.fqn(fname) + fname = vim.fn.fnamemodify(fname, ":p") + return vim.loop.fs_realpath(fname) or fname +end + +function M.clipman() + local file = M.fqn("~/.local/share/clipman.json") + if M.exists(file) then + local f = io.open(file) + if not f then + return + end + local data = f:read("*a") + f:close() + + -- allow empty files + data = vim.trim(data) + if data ~= "" then + local ok, json = pcall(vim.fn.json_decode, data) + if ok and json then + local items = {} + for i = #json, 1, -1 do + items[#items + 1] = json[i] + end + vim.ui.select(items, { + prompt = "Clipman", + }, function(choice) + if choice then + vim.api.nvim_paste(choice, true, 1) + -- vim.fn.setreg("+", choice) + end + end) + else + vim.notify(("failed to load clipman from %s"):format(file), vim.log.levels.ERROR) + end + end + end +end + +function M.debounce(ms, fn) + local timer = vim.loop.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end +end + +function M.throttle(ms, fn) + local timer = vim.loop.new_timer() + local running = false + return function(...) + if not running then + local argv = { ... } + local argc = select("#", ...) + + timer:start(ms, 0, function() + running = false + pcall(vim.schedule_wrap(fn), unpack(argv, 1, argc)) + end) + running = true + end + end +end + +function M.version() + local v = vim.version() + if not v.prerelease then + vim.notify( + ("Neovim v%d.%d.%d"):format(v.major, v.minor, v.patch), + vim.log.levels.WARN, + { title = "Neovim: not running nightly!" } + ) + end +end + return M diff --git a/lua/util/packer.lua b/lua/util/packer.lua index 6715167..2889617 100644 --- a/lua/util/packer.lua +++ b/lua/util/packer.lua @@ -5,13 +5,12 @@ local M = {} M.local_plugins = {} function M.bootstrap() - local fn = vim.fn - local install_path = fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path}) - return true - end - + local fn = vim.fn + local install_path = fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) + return true + end end function M.auto_compile() @@ -102,26 +101,27 @@ function M.plugin(pkg) end function M.setup(config, fn) - local bootstrapped = M.bootstrap() - M.auto_compile() + vim.fn.setenv("MACOSX_DEPLOYMENT_TARGET", "10.15") + local bootstrapped = M.bootstrap() + M.auto_compile() - vim.cmd([[packadd packer.nvim]]) + vim.cmd([[packadd packer.nvim]]) - local packer = require("packer") - packer.init(config) + local packer = require("packer") + packer.init(config) - M.local_plugins = config.local_plugins or {} + M.local_plugins = config.local_plugins or {} - packer.startup(function(use) - use = M.wrap(use) - fn(use, function(pkg) - return use(M.plugin(pkg)) - end) - end) + packer.startup(function(use) + use = M.wrap(use) + fn(use, function(pkg) + return use(M.plugin(pkg)) + end) + end) - if bootstrapped then - require("packer").sync() - end + if bootstrapped then + require("packer").sync() + end end return M diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua index beb1052..d8d67fa 100644 --- a/plugin/packer_compiled.lua +++ b/plugin/packer_compiled.lua @@ -74,6 +74,193 @@ end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { + LuaSnip = { + after = { "friendly-snippets" }, + config = { 'require("plugins.luasnip").config()' }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["animation.nvim"] = { + load_after = { + ["windows.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/animation.nvim", + url = "https://github.com/anuvyklack/animation.nvim" + }, + ["cmp-buffer"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-buffer/after/plugin/cmp_buffer.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-cmdline"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-cmdline/after/plugin/cmp_cmdline.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-cmdline", + url = "https://github.com/hrsh7th/cmp-cmdline" + }, + ["cmp-cmdline-history"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-cmdline-history/after/plugin/cmp_cmdline_history.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-cmdline-history", + url = "https://github.com/dmitmel/cmp-cmdline-history" + }, + ["cmp-emoji"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-emoji/after/plugin/cmp_emoji.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-emoji", + url = "https://github.com/hrsh7th/cmp-emoji" + }, + ["cmp-nvim-lsp"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp/after/plugin/cmp_nvim_lsp.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lsp-signature-help"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp-signature-help/after/plugin/cmp_nvim_lsp_signature_help.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp-signature-help", + url = "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help" + }, + ["cmp-path"] = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-path/after/plugin/cmp_path.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + after_files = { "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp_luasnip/after/plugin/cmp_luasnip.lua" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["dashboard-nvim"] = { + config = { 'require("plugins.dashboard").config()' }, + loaded = true, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/start/dashboard-nvim", + url = "https://github.com/glepnir/dashboard-nvim" + }, + ["dressing.nvim"] = { + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/dressing.nvim", + url = "https://github.com/stevearc/dressing.nvim" + }, + ["fidget.nvim"] = { + config = { "\27LJ\2\n\1\0\0\4\0\v\0\0156\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0005\3\3\0=\3\5\2B\0\2\0016\0\6\0009\0\a\0009\0\b\0'\2\t\0005\3\n\0B\0\3\1K\0\1\0\1\0\1\fcommand\24silent! FidgetClose\16VimLeavePre\24nvim_create_autocmd\bapi\bvim\vwindow\1\0\0\1\0\1\rrelative\veditor\nsetup\vfidget\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/fidget.nvim", + url = "https://github.com/j-hui/fidget.nvim" + }, + ["friendly-snippets"] = { + config = { "\27LJ\2\nM\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\14lazy_load luasnip.loaders.from_vscode\frequire\0" }, + load_after = { + LuaSnip = true + }, + loaded = false, + needs_bufread = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, + ["hlargs.nvim"] = { + config = { "\27LJ\2\nv\0\0\6\0\a\0\0146\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\5\0006\3\0\0'\5\3\0B\3\2\0029\3\2\3B\3\1\0029\3\4\3=\3\6\2B\0\2\1K\0\1\0\ncolor\1\0\0\vyellow\22tokyonight.colors\nsetup\vhlargs\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/hlargs.nvim", + url = "https://github.com/m-demare/hlargs.nvim" + }, + ["indent-blankline.nvim"] = { + config = { 'require("plugins.indent-blankline").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + ["lua-dev.nvim"] = { + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/lua-dev.nvim", + url = "https://github.com/folke/lua-dev.nvim" + }, + ["lualine.nvim"] = { + config = { 'require("plugins.lualine").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/lualine.nvim", + url = "https://github.com/nvim-lualine/lualine.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + config = { 'require("plugins.mason").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + middleclass = { + load_after = { + ["windows.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/middleclass", + url = "https://github.com/anuvyklack/middleclass" + }, ["neo-tree.nvim"] = { commands = { "Neotree" }, config = { 'require("plugins.neo-tree").config()' }, @@ -83,6 +270,31 @@ _G.packer_plugins = { path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/neo-tree.nvim", url = "https://github.com/nvim-neo-tree/neo-tree.nvim" }, + neogen = { + config = { "\27LJ\2\nR\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\1K\0\1\0\1\0\1\19snippet_engine\fluasnip\nsetup\vneogen\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/neogen", + url = "https://github.com/danymat/neogen" + }, + ["neoscroll.nvim"] = { + config = { 'require("plugins.neoscroll").config()' }, + keys = { { "", "" }, { "", "" }, { "", "gg" }, { "", "G" } }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/neoscroll.nvim", + url = "https://github.com/karb94/neoscroll.nvim" + }, + ["noice.nvim"] = { + config = { "\27LJ\2\n3\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\nnoice\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/noice.nvim", + url = "https://github.com/folke/noice.nvim" + }, ["nui.nvim"] = { loaded = false, needs_bufread = false, @@ -90,8 +302,81 @@ _G.packer_plugins = { path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nui.nvim", url = "https://github.com/MunifTanjim/nui.nvim" }, + ["null-ls.nvim"] = { + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["nvim-autopairs"] = { + config = { 'require("plugins.autopairs").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-bufferline.lua"] = { + config = { 'require("plugins.bufferline").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-bufferline.lua", + url = "https://github.com/akinsho/nvim-bufferline.lua" + }, + ["nvim-cmp"] = { + after = { "cmp_luasnip", "cmp-buffer", "cmp-path", "cmp-cmdline-history", "cmp-cmdline", "cmp-emoji", "cmp-nvim-lsp", "cmp-nvim-lsp-signature-help" }, + config = { 'require("plugins.cmp").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-colorizer.lua"] = { + config = { 'require("plugins.colorizer").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-colorizer.lua", + url = "https://github.com/NvChad/nvim-colorizer.lua" + }, + ["nvim-lspconfig"] = { + config = { 'require("plugins.lsp").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-navic"] = { + config = { "\27LJ\2\n\1\0\0\3\0\a\0\v6\0\0\0009\0\1\0+\1\2\0=\1\2\0006\0\3\0'\2\4\0B\0\2\0029\0\5\0005\2\6\0B\0\2\1K\0\1\0\1\0\3\14separator\6 \16depth_limit\3\5\14highlight\2\nsetup\15nvim-navic\frequire\18navic_silence\6g\bvim\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-navic", + url = "https://github.com/SmiteshP/nvim-navic" + }, + ["nvim-neoclip.lua"] = { + after = { "sqlite.lua" }, + config = { "\27LJ\2\nh\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\1K\0\1\0\1\0\2\30enable_persistent_history\2\20continuous_sync\2\nsetup\fneoclip\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-neoclip.lua", + url = "https://github.com/AckslD/nvim-neoclip.lua" + }, + ["nvim-notify"] = { + config = { "\27LJ\2\n\1\0\0\4\0\t\0\0176\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\a\0006\3\3\0009\3\4\0039\3\5\0039\3\6\3=\3\b\2B\0\2\0016\0\3\0006\1\0\0'\3\1\0B\1\2\2=\1\1\0K\0\1\0\nlevel\1\0\1\bfps\3\20\tINFO\vlevels\blog\bvim\nsetup\vnotify\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/nvim-notify", + url = "https://github.com/rcarriga/nvim-notify" + }, ["nvim-treesitter"] = { - after = { "nvim-treesitter-textsubjects", "nvim-treesitter-textobjects", "nvim-treesitter-refactor" }, + after = { "nvim-treesitter-textobjects", "nvim-treesitter-textsubjects", "nvim-treesitter-refactor" }, config = { 'require("plugins.treesitter").config()' }, loaded = false, needs_bufread = false, @@ -140,6 +425,14 @@ _G.packer_plugins = { path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/packer.nvim", url = "https://github.com/wbthomason/packer.nvim" }, + ["persistence.nvim"] = { + config = { "\27LJ\2\n9\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\16persistence\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/persistence.nvim", + url = "https://github.com/folke/persistence.nvim" + }, playground = { commands = { "TSHighlightCapturesUnderCursor", "TSPlaygroundToggle" }, loaded = false, @@ -154,14 +447,153 @@ _G.packer_plugins = { only_cond = false, path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["sqlite.lua"] = { + load_after = { + ["nvim-neoclip.lua"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/sqlite.lua", + url = "https://github.com/kkharji/sqlite.lua" + }, + ["telescope-file-browser.nvim"] = { + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/telescope-file-browser.nvim", + url = "https://github.com/nvim-telescope/telescope-file-browser.nvim" + }, + ["telescope-fzf-native.nvim"] = { + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/telescope-fzf-native.nvim", + url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + ["telescope-project.nvim"] = { + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/telescope-project.nvim", + url = "https://github.com/nvim-telescope/telescope-project.nvim" + }, + ["telescope-symbols.nvim"] = { + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/telescope-symbols.nvim", + url = "https://github.com/nvim-telescope/telescope-symbols.nvim" + }, + ["telescope-z.nvim"] = { + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/telescope-z.nvim", + url = "https://github.com/nvim-telescope/telescope-z.nvim" + }, + ["telescope.nvim"] = { + after = { "telescope-z.nvim", "telescope-file-browser.nvim", "telescope-fzf-native.nvim", "telescope-symbols.nvim", "telescope-project.nvim" }, + commands = { "Telescope" }, + config = { 'require("plugins.telescope").config()' }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["tokyonight.nvim"] = { + config = { 'require("plugins.tokyonight").config()' }, + loaded = true, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/start/tokyonight.nvim", + url = "https://github.com/folke/tokyonight.nvim" + }, + ["trouble.nvim"] = { + commands = { "TroubleToggle", "Trouble" }, + config = { "\27LJ\2\n]\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\1K\0\1\0\1\0\2\25use_diagnostic_signs\2\14auto_open\1\nsetup\ftrouble\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/trouble.nvim", + url = "https://github.com/folke/trouble.nvim" + }, + ["vim-startuptime"] = { + commands = { "StartupTime" }, + config = { "\27LJ\2\n3\0\0\2\0\3\0\0056\0\0\0009\0\1\0)\1\n\0=\1\2\0K\0\1\0\22startuptime_tries\6g\bvim\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/vim-startuptime", + url = "https://github.com/dstein64/vim-startuptime" + }, + ["which-key.nvim"] = { + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/which-key.nvim", + url = "https://github.com/folke/which-key.nvim" + }, + ["windows.nvim"] = { + after = { "animation.nvim", "middleclass" }, + config = { 'require("plugins.windows").config()' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/kjuulh/.local/share/nvim/site/pack/packer/opt/windows.nvim", + url = "https://github.com/anuvyklack/windows.nvim" } } time([[Defining packer_plugins]], false) local module_lazy_loads = { + ["^animation"] = "animation.nvim", + ["^cmp"] = "nvim-cmp", + ["^cmp_nvim_lsp"] = "cmp-nvim-lsp", + ["^fidget"] = "fidget.nvim", + ["^hlargs"] = "hlargs.nvim", + ["^lua%-dev"] = "lua-dev.nvim", + ["^lualine"] = "lualine.nvim", + ["^luasnip"] = "LuaSnip", + ["^mason"] = "mason.nvim", + ["^mason%-lspconfig"] = "mason-lspconfig.nvim", + ["^middleclass"] = "middleclass", + ["^neogen"] = "neogen", + ["^noice"] = "noice.nvim", + ["^notify"] = "nvim-notify", ["^nui"] = "nui.nvim", + ["^null%-ls"] = "null-ls.nvim", + ["^nvim%-autopairs"] = "nvim-autopairs", + ["^nvim%-navic"] = "nvim-navic", + ["^nvim%-treesitter"] = "nvim-treesitter", ["^nvim%-web%-devicons"] = "nvim-web-devicons", - ["^plenary"] = "plenary.nvim" + ["^persistence"] = "persistence.nvim", + ["^plenary"] = "plenary.nvim", + ["^sqlite"] = "sqlite.lua", + ["^telescope"] = "telescope.nvim", + ["^telescope%._extensions%.file_browser"] = "telescope-file-browser.nvim", + ["^telescope%._extensions%.fzf"] = "telescope-fzf-native.nvim", + ["^telescope%._extensions%.neoclip"] = "nvim-neoclip.lua", + ["^telescope%._extensions%.project"] = "telescope-project.nvim", + ["^telescope%._extensions%.symbols"] = "telescope-symbols.nvim", + ["^telescope%._extensions%.z"] = "telescope-z.nvim", + ["^trouble"] = "trouble.nvim", + ["^which%-key"] = "which-key.nvim" } local lazy_load_called = {['packer.load'] = true} local function lazy_load_module(module_name) @@ -188,19 +620,47 @@ if not vim.g.packer_custom_loader_enabled then vim.g.packer_custom_loader_enabled = true end +-- Setup for: telescope.nvim +time([[Setup for telescope.nvim]], true) +require("plugins.telescope").init() +time([[Setup for telescope.nvim]], false) +-- Config for: dashboard-nvim +time([[Config for dashboard-nvim]], true) +require("plugins.dashboard").config() +time([[Config for dashboard-nvim]], false) +-- Config for: tokyonight.nvim +time([[Config for tokyonight.nvim]], true) +require("plugins.tokyonight").config() +time([[Config for tokyonight.nvim]], false) -- Command lazy-loads time([[Defining lazy-load commands]], true) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file TSHighlightCapturesUnderCursor lua require("packer.load")({'playground'}, { cmd = "TSHighlightCapturesUnderCursor", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Telescope lua require("packer.load")({'telescope.nvim'}, { cmd = "Telescope", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file TroubleToggle lua require("packer.load")({'trouble.nvim'}, { cmd = "TroubleToggle", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Trouble lua require("packer.load")({'trouble.nvim'}, { cmd = "Trouble", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neotree lua require("packer.load")({'neo-tree.nvim'}, { cmd = "Neotree", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file TSPlaygroundToggle lua require("packer.load")({'playground'}, { cmd = "TSPlaygroundToggle", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file TSHighlightCapturesUnderCursor lua require("packer.load")({'playground'}, { cmd = "TSHighlightCapturesUnderCursor", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file StartupTime lua require("packer.load")({'vim-startuptime'}, { cmd = "StartupTime", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) time([[Defining lazy-load commands]], false) +-- Keymap lazy-loads +time([[Defining lazy-load keymaps]], true) +vim.cmd [[noremap lua require("packer.load")({'neoscroll.nvim'}, { keys = "C-u>", prefix = "" }, _G.packer_plugins)]] +vim.cmd [[noremap G lua require("packer.load")({'neoscroll.nvim'}, { keys = "G", prefix = "" }, _G.packer_plugins)]] +vim.cmd [[noremap gg lua require("packer.load")({'neoscroll.nvim'}, { keys = "gg", prefix = "" }, _G.packer_plugins)]] +vim.cmd [[noremap lua require("packer.load")({'neoscroll.nvim'}, { keys = "C-d>", prefix = "" }, _G.packer_plugins)]] +time([[Defining lazy-load keymaps]], false) + vim.cmd [[augroup packer_load_aucmds]] vim.cmd [[au!]] -- Event lazy-loads time([[Defining lazy-load event autocommands]], true) -vim.cmd [[au User PackerDefered ++once lua require("packer.load")({'nvim-treesitter'}, { event = "User PackerDefered" }, _G.packer_plugins)]] +vim.cmd [[au User PackerDefered ++once lua require("packer.load")({'dressing.nvim', 'hlargs.nvim', 'windows.nvim', 'nvim-notify', 'lualine.nvim', 'nvim-treesitter'}, { event = "User PackerDefered" }, _G.packer_plugins)]] +vim.cmd [[au InsertEnter * ++once lua require("packer.load")({'nvim-cmp'}, { event = "InsertEnter *" }, _G.packer_plugins)]] +vim.cmd [[au VimEnter * ++once lua require("packer.load")({'noice.nvim'}, { event = "VimEnter *" }, _G.packer_plugins)]] +vim.cmd [[au BufReadPre * ++once lua require("packer.load")({'nvim-bufferline.lua', 'nvim-colorizer.lua', 'indent-blankline.nvim', 'nvim-lspconfig', 'trouble.nvim', 'persistence.nvim'}, { event = "BufReadPre *" }, _G.packer_plugins)]] +vim.cmd [[au TextYankPost * ++once lua require("packer.load")({'nvim-neoclip.lua'}, { event = "TextYankPost *" }, _G.packer_plugins)]] time([[Defining lazy-load event autocommands]], false) vim.cmd("augroup END") diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..6540d6f --- /dev/null +++ b/selene.toml @@ -0,0 +1 @@ +std="lua51+vim" diff --git a/sessions/%home%kjuulh%.config%nvim.vim b/sessions/%home%kjuulh%.config%nvim.vim new file mode 100644 index 0000000..3216135 --- /dev/null +++ b/sessions/%home%kjuulh%.config%nvim.vim @@ -0,0 +1,55 @@ +let SessionLoad = 1 +let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1 +let v:this_session=expand(":p") +silent only +silent tabonly +cd ~/.config/nvim +if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' + let s:wipebuf = bufnr('%') +endif +let s:shortmess_save = &shortmess +if &shortmess =~ 'A' + set shortmess=aoOA +else + set shortmess=aoO +endif +badd +1 . +badd +7 lua/plugins/tokyonight.lua +argglobal +%argdel +$argadd . +edit lua/plugins/tokyonight.lua +wincmd t +let s:save_winminheight = &winminheight +let s:save_winminwidth = &winminwidth +set winminheight=0 +set winheight=1 +set winminwidth=0 +set winwidth=1 +argglobal +balt . +let s:l = 7 - ((6 * winheight(0) + 30) / 60) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 7 +normal! 07| +tabnext 1 +if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal' + silent exe 'bwipe ' . s:wipebuf +endif +unlet! s:wipebuf +set winheight=1 winwidth=5 +let &shortmess = s:shortmess_save +let &winminheight = s:save_winminheight +let &winminwidth = s:save_winminwidth +let s:sx = expand(":p:r")."x.vim" +if filereadable(s:sx) + exe "source " . fnameescape(s:sx) +endif +let &g:so = s:so_save | let &g:siso = s:siso_save +set hlsearch +nohlsearch +doautoall SessionLoadPost +unlet SessionLoad +" vim: set ft=vim : diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..0f90030 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 diff --git a/vim.toml b/vim.toml new file mode 100644 index 0000000..0fa5c4f --- /dev/null +++ b/vim.toml @@ -0,0 +1,2 @@ +[vim] +any = true