commit fddc5eeed2deffe1b34c3d719ad78abc21b15213 Author: krolyxon Date: Tue Sep 6 13:52:50 2022 +0530 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8cb205e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugin diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3f89ad2 --- /dev/null +++ b/init.lua @@ -0,0 +1,32 @@ +vim.defer_fn(function() + pcall(require, "impatient") +end, 0) + +-- setup packer + plugins +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 + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" }) + print "Cloning packer .." + fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path } + + -- install plugins + compile their configs + vim.cmd "packadd packer.nvim" + require "plugins" + vim.cmd "PackerSync" +end + +local modules = { + "core.options", + "core.packer", +} + +for _, module in ipairs(modules) do + local ok, err = pcall(require, module) + if not ok then + error("Error loading " .. module .. "\n\n" .. err) + end +end + +require ("core.utils").load_mappings() diff --git a/lua/core/lazy_load.lua b/lua/core/lazy_load.lua new file mode 100644 index 0000000..f75b63d --- /dev/null +++ b/lua/core/lazy_load.lua @@ -0,0 +1,82 @@ +local M = {} +local autocmd = vim.api.nvim_create_autocmd + +-- require("packer").loader(tb.plugins) +-- This must be used for plugins that need to be loaded just after a file +-- ex : treesitter, lspconfig etc +M.lazy_load = function(tb) + autocmd(tb.events, { + group = vim.api.nvim_create_augroup(tb.augroup_name, {}), + callback = function() + if tb.condition() then + vim.api.nvim_del_augroup_by_name(tb.augroup_name) + + -- dont defer for treesitter as it will show slow highlighting + -- This deferring only happens only when we do "nvim filename" + if tb.plugin ~= "nvim-treesitter" then + vim.defer_fn(function() + require("packer").loader(tb.plugin) + if tb.plugin == "nvim-lspconfig" then + vim.cmd "silent! do FileType" + end + end, 0) + else + require("packer").loader(tb.plugin) + end + end + end, + }) +end + +-- load certain plugins only when there's a file opened in the buffer +-- if "nvim filename" is executed -> load the plugin after nvim gui loads +-- This gives an instant preview of nvim with the file opened + +M.on_file_open = function(plugin_name) + M.lazy_load { + events = { "BufRead", "BufWinEnter", "BufNewFile" }, + augroup_name = "BeLazyOnFileOpen" .. plugin_name, + plugin = plugin_name, + condition = function() + local file = vim.fn.expand "%" + return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= "" + end, + } +end + +M.packer_cmds = { + "PackerSnapshot", + "PackerSnapshotRollback", + "PackerSnapshotDelete", + "PackerInstall", + "PackerUpdate", + "PackerSync", + "PackerClean", + "PackerCompile", + "PackerStatus", + "PackerProfile", + "PackerLoad", +} +M.treesitter_cmds = { + "TSInstall", + "TSBufEnable", + "TSBufDisable", + "TSEnable", + "TSDisable", + "TSModuleInfo", +} + +M.gitsigns = function() + autocmd({ "BufRead" }, { + callback = function() + vim.fn.system("git rev-parse " .. vim.fn.expand "%:p:h") + if vim.v.shell_error == 0 then + vim.schedule(function() + require("packer").loader "gitsigns.nvim" + end) + end + end, + }) +end + +return M diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua new file mode 100644 index 0000000..3199c36 --- /dev/null +++ b/lua/core/mappings.lua @@ -0,0 +1,113 @@ +local M = {} + +M.general = { + i = {}, + + n = { + [""] = { " noh ", "no highlight"}, + + -- switch between windows + [""] = { "h", "window left" }, + [""] = { "l", "window right" }, + [""] = { "j", "window down" }, + [""] = { "k", "window up" }, + + -- new buffer + ["b"] = { " enew ", "new buffer" }, + + -- close buffer + hide terminal buffer + ["x"] = { + function() + require("core.utils").close_buffer() + end, + "close buffer", + } + }, +} + +M.telescope = { + plugin = true, + + n = { + -- find + ["ff"] = { " Telescope find_files ", "find files" }, + ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", "find all" }, + ["fw"] = { " Telescope live_grep ", "live grep" }, + ["fb"] = { " Telescope buffers ", "find buffers" }, + ["fh"] = { " Telescope help_tags ", "help page" }, + ["fo"] = { " Telescope oldfiles ", "find oldfiles" }, + ["tk"] = { " Telescope keymaps ", "show keys" }, + + -- git + ["cm"] = { " Telescope git_commits ", "git commits" }, + ["gt"] = { " Telescope git_status ", "git status" }, + + -- theme switcher + ["th"] = { " Telescope colorscheme", "colorthemes" }, + }, +} + +M.whichkey = { + plugin = true, + + n = { + ["wK"] = { + function() + vim.cmd "WhichKey" + end, + "which-key all keymaps", + }, + ["wk"] = { + function() + local input = vim.fn.input "WhichKey: " + vim.cmd("WhichKey " .. input) + end, + "which-key query lookup", + }, + }, +} + +M.comment = { + plugin = true, + + -- toggle comment in both modes + n = { + ["/"] = { + function() + require("Comment.api").toggle.linewise.current() + end, + "toggle comment", + }, + }, + + v = { + ["/"] = { + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + "toggle comment", + }, + }, +} + +M.blankline = { + plugin = true, + + n = { + ["cc"] = { + function() + local ok, start = require("indent_blankline.utils").get_current_context( + vim.g.indent_blankline_context_patterns, + vim.g.indent_blankline_use_treesitter_scope + ) + + if ok then + vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 }) + vim.cmd [[normal! _]] + end + end, + + "Jump to current_context", + }, + }, +} + +return M diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..ac166c1 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,64 @@ +local opt = vim.opt +local g = vim.g + +-- use filetype.lua instead of filetype.vim. it's enabled by default in neovim 0.8 (nightly) +g.vim_version = vim.version().minor +if g.vim_version < 8 then + g.did_load_filetypes = 0 + g.do_filetype_lua = 1 +end + +opt.laststatus = 3 -- global statusline +opt.title = true +opt.cmdheight = 1 +opt.clipboard = "unnamedplus" +opt.cul = true -- cursor line + +-- numbers +opt.number = true +opt.numberwidth = 2 +opt.relativenumber = true +opt.ruler = false + +-- indentline +opt.expandtab = true +opt.shiftwidth = 4 +opt.smartindent = true + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +opt.whichwrap:append "<>[]hl" +g.mapleader = " " + +-- disable nvim intro +opt.shortmess:append "sI" +opt.signcolumn = "yes" +opt.termguicolors = true +opt.timeoutlen = 400 + + +-- disable some builtin vim plugins +local default_plugins = { + "2html_plugin", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", +-- "netrw", +-- "netrwPlugin", +-- "netrwSettings", +-- "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimball_plugin", + "zip", + "zipPlugin", +} + +for _, plugin in pairs(default_plugins) do + g["loaded_" .. plugin ] = 1 +end diff --git a/lua/core/packer.lua b/lua/core/packer.lua new file mode 100644 index 0000000..a2e85dc --- /dev/null +++ b/lua/core/packer.lua @@ -0,0 +1,41 @@ +local M = {} + +M.run = function(plugins) + local present, packer = pcall(require, "packer") + + if not present then + return + end + + + local final_table = {} + for key, _ in pairs(plugins) do + plugins[key][1] = key + final_table[#final_table + 1] = plugins[key] + end + + + packer.init({ + auto_clean = true, + compile_on_sync = true, + git = { clone_timeout = 6000 }, + display = { + working_sym = "ﲊ", + error_sym = "✗ ", + done_sym = " ", + removed_sym = " ", + moved_sym = "", + open_fn = function() + return require("packer.util").float { border = "single" } + end, + } + }) + + packer.startup(function(use) + for _, v in pairs(final_table) do + use(v) + end + end) +end + +return M diff --git a/lua/core/utils.lua b/lua/core/utils.lua new file mode 100644 index 0000000..26cd80d --- /dev/null +++ b/lua/core/utils.lua @@ -0,0 +1,37 @@ +local M = {} +local merge_tb = vim.tbl_deep_extend + +M.load_mappings = function(section, mapping_opt) + local function set_section_map(section_values) + if section_values.plugin then + return + end + section_values.plugin = nil + + for mode, mode_values in pairs(section_values) do + local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {}) + for keybind, mapping_info in pairs(mode_values) do + -- merge default + user opts + local opts = merge_tb("force", default_opts, mapping_info.opts or {}) + + mapping_info.opts, opts.mode = nil, nil + opts.desc = mapping_info[2] + + vim.keymap.set(mode, keybind, mapping_info[1], opts) + end + end + end + + local mappings = require("core.mappings") + + if type(section) == "string" then + mappings[section]["plugin"] = nil + mappings = { mappings[section] } + end + + for _, sect in pairs(mappings) do + set_section_map(sect) + end +end + +return M diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua new file mode 100644 index 0000000..b07f21a --- /dev/null +++ b/lua/plugins/configs/cmp.lua @@ -0,0 +1,93 @@ +local present, cmp = pcall(require, "cmp") + +if not present then + return +end + +vim.opt.completeopt = "menuone,noselect" + +local function border(hl_name) + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } +end + +local cmp_window = require "cmp.utils.window" + +cmp_window.info_ = cmp_window.info +cmp_window.info = function(self) + local info = self:info_() + info.scrollable = false + return info +end + +local options = { + window = { + completion = { + border = border "CmpBorder", + winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + documentation = { + border = border "CmpDocBorder", + }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + }, + sources = { + { name = "luasnip" }, + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +-- check for any override + +cmp.setup(options) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua new file mode 100644 index 0000000..ff29144 --- /dev/null +++ b/lua/plugins/configs/lspconfig.lua @@ -0,0 +1,66 @@ +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap=true, silent=true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- 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', 'f', vim.lsp.buf.formatting, bufopts) +end + +local lsp_flags = { + -- This is the default in Nvim 0.7+ + debounce_text_changes = 150, +} +require('lspconfig')['sumneko_lua'].setup{ + on_attach = on_attach, + flags = lsp_flags, + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + }, + maxpreload = 100000, + preloadFileSize = 10000, + }, + }, + }, +} + +require('lspconfig')['rust_analyzer'].setup{ + on_attach = on_attach, + flags = lsp_flags, + -- Server-specific settings... + settings = { + ["rust-analyzer"] = {} + } +} diff --git a/lua/plugins/configs/mason.lua b/lua/plugins/configs/mason.lua new file mode 100644 index 0000000..02424cf --- /dev/null +++ b/lua/plugins/configs/mason.lua @@ -0,0 +1,32 @@ +local present, mason = pcall(require, "mason") + +if not present then + return +end + +local options = { + ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + + ui = { + icons = { + package_pending = " ", + package_installed = " ", + package_uninstalled = "ﮊ ", + }, + + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + + max_concurrent_installers = 10, +} + +mason.setup(options) diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua new file mode 100644 index 0000000..bb63595 --- /dev/null +++ b/lua/plugins/configs/others.lua @@ -0,0 +1,140 @@ +local M = {} + +M.autopairs = function() + local present1, autopairs = pcall(require, "nvim-autopairs") + local present2, cmp = pcall(require, "cmp") + + if not (present1 and present2) then + return + end + + local options = { + fast_wrap = {}, + disable_filetype = { "TelescopePrompt", "vim" }, + } + + autopairs.setup(options) + + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) +end + +M.luasnip = function() + local present, luasnip = pcall(require, "luasnip") + + if not present then + return + end + + local options = { + history = true, + updateevents = "TextChanged,TextChangedI", + } + + luasnip.config.set_config(options) + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" } + + vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, + }) +end + +M.gitsigns = function() + local present, gitsigns = pcall(require, "gitsigns") + + if not present then + return + end + + local options = { + signs = { + add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, + change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, + delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, + topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, + changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, + }, + } + + gitsigns.setup(options) +end + +M.blankline = function() + local present, blankline = pcall(require, "indent_blankline") + + if not present then + return + end + + local options = { + indentLine_enabled = 1, + char = "▏", + filetype_exclude = { + "help", + "terminal", + "alpha", + "packer", + "lspinfo", + "TelescopePrompt", + "TelescopeResults", + "nvchad_cheatsheet", + "lsp-installer", + "", + }, + buftype_exclude = { "terminal" }, + show_trailing_blankline_indent = false, + show_first_indent_level = false, + } + + blankline.setup(options) +end + +M.colorizer = function() + local present, colorizer = pcall(require, "colorizer") + + if not present then + return + end + + local options = { + filetypes = { + "*", + }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue + RRGGBBAA = false, -- #RRGGBBAA 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 + mode = "background", -- Set the display mode. + }, + } + + colorizer.setup(options) + return vim.tbl_isempty(options.filetypes or {}) or vim.cmd [[do FileType]] +end + + +M.comment = function() + local present, nvim_comment = pcall(require, "Comment") + + if not present then + return + end + + local options = {} + nvim_comment.setup(options) +end + +return M diff --git a/lua/plugins/configs/rust-tools.lua b/lua/plugins/configs/rust-tools.lua new file mode 100644 index 0000000..d44f762 --- /dev/null +++ b/lua/plugins/configs/rust-tools.lua @@ -0,0 +1,78 @@ +local present, rust = pcall(require, "rust-tools") +if not present then + return +end + +local options = { + tools = { + on_initialized = nil, + reload_workspace_from_cargo_toml = true, + + -- inlay hints + inlay_hints = { + auto = true, + only_current_line = false, + show_parameter_hints = true, + parameter_hints_prefix = "<- ", + max_len_align = false, + }, + enabled_graphviz_backends = { + "bmp", + "cgimage", + "canon", + "dot", + "gv", + "xdot", + "xdot1.2", + "xdot1.4", + "eps", + "exr", + "fig", + "gd", + "gd2", + "gif", + "gtk", + "ico", + "cmap", + "ismap", + "imap", + "cmapx", + "imap_np", + "cmapx_np", + "jpg", + "jpeg", + "jpe", + "jp2", + "json", + "json0", + "dot_json", + "xdot_json", + "pdf", + "pic", + "pct", + "pict", + "plain", + "plain-ext", + "png", + "pov", + "ps", + "ps2", + "psd", + "sgi", + "svg", + "svgz", + "tga", + "tiff", + "tif", + "tk", + "vml", + "vmlz", + "wbmp", + "webp", + "xlib", + "x11", + }, + }, +} + +rust.setup(options) diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua new file mode 100644 index 0000000..56c426a --- /dev/null +++ b/lua/plugins/configs/statusline.lua @@ -0,0 +1,40 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua new file mode 100644 index 0000000..4160303 --- /dev/null +++ b/lua/plugins/configs/telescope.lua @@ -0,0 +1,70 @@ +local present, telescope = pcall(require, "telescope") + +if not present then + return +end + +vim.g.theme_switcher_loaded = true + +local options = { + defaults = { + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = false, + }, + width = 0.87, + height = 0.80, + preview_cutoff = 120, + }, + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = { "node_modules" }, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = 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, + mappings = { + n = { ["q"] = require("telescope.actions").close }, + }, + }, + + extensions_list = { "themes", "terms" }, +} + +-- check for any override +telescope.setup(options) + +-- load extensions +pcall(function() + for _, ext in ipairs(options.extensions_list) do + telescope.load_extension(ext) + end +end) diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua new file mode 100644 index 0000000..49c2c2d --- /dev/null +++ b/lua/plugins/configs/treesitter.lua @@ -0,0 +1,18 @@ +local present, treesitter = pcall(require, "nvim-treesitter.configs") + +if not present then + return +end + +local options = { + ensure_installed = { + "lua", + "rust", + }, + highlight = { + enable = true, + use_languagetree = true, + }, +} + +treesitter.setup(options) diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/configs/whichkey.lua new file mode 100644 index 0000000..26a1040 --- /dev/null +++ b/lua/plugins/configs/whichkey.lua @@ -0,0 +1,37 @@ +local present, wk = pcall(require, "which-key") + +if not present then + return +end + +local options = { + + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "  ", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, + + popup_mappings = { + scroll_down = "", -- binding to scroll down inside the popup + scroll_up = "", -- binding to scroll up inside the popup + }, + + window = { + border = "none", -- none/single/double/shadow + }, + + layout = { + spacing = 6, -- spacing between columns + }, + + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, + + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + i = { "j", "k" }, + v = { "j", "k" }, + }, +} + +wk.setup(options) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..86ffeea --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,179 @@ +vim.cmd "packadd packer.nvim" + +local plugins = { + ["wbthomason/packer.nvim"] = { + cmd = require("core.lazy_load").packer_cmds, + config = function() + require "plugins" + end, + }, + + ["luisiacc/gruvbox-baby"] = { + config ="vim.cmd 'colorscheme gruvbox-baby'" + }, + + ["nvim-treesitter/nvim-treesitter"] = { + module = "nvim-treesitter", + setup = function() + require("core.lazy_load").on_file_open "nvim-treesitter" + end, + cmd = require("core.lazy_load").treesitter_cmds, + run = ":TSUpdate", + config = function() + require "plugins.configs.treesitter" + end, + }, + + -- git + ["lewis6991/gitsigns.nvim"] = { + ft = "gitcommit", + setup = function() + require("core.lazy_load").gitsigns() + end, + config = function() + require("plugins.configs.others").gitsigns() + end, + }, + + ['nvim-lua/plenary.nvim'] = {}, + + ["nvim-telescope/telescope.nvim"] = { + cmd = "Telescope", + config = function() + require "plugins.configs.telescope" + end, + setup = function () + require ("core.utils").load_mappings "telescope" + end, + }, + + -- lsp stuff + + ["williamboman/mason.nvim"] = { + cmd = require("core.lazy_load").mason_cmds, + config = function() + require "plugins.configs.mason" + end, + }, + + ["neovim/nvim-lspconfig"] = { + opt = true, + setup = function() + require("core.lazy_load").on_file_open "nvim-lspconfig" + end, + config = function() + require "plugins.configs.lspconfig" + end, + }, + + ["simrat39/rust-tools.nvim"] = { + ft = "rs", + config = function () + require("plugins.configs.rust-tools") + end, + }, + + -- load luasnips + cmp related in insert mode only + + ["rafamadriz/friendly-snippets"] = { + module = { "cmp", "cmp_nvim_lsp" }, + event = "InsertEnter", + }, + + ["hrsh7th/nvim-cmp"] = { + after = "friendly-snippets", + config = function() + require "plugins.configs.cmp" + end, + }, + + ["L3MON4D3/LuaSnip"] = { + wants = "friendly-snippets", + after = "nvim-cmp", + config = function() + require("plugins.configs.others").luasnip() + end, + }, + + ["saadparwaiz1/cmp_luasnip"] = { + after = "LuaSnip", + }, + + ["hrsh7th/cmp-nvim-lua"] = { + after = "cmp_luasnip", + }, + + ["hrsh7th/cmp-nvim-lsp"] = { + after = "cmp-nvim-lua", + }, + + ["hrsh7th/cmp-buffer"] = { + after = "cmp-nvim-lsp", + }, + + ["hrsh7th/cmp-path"] = { + after = "cmp-buffer", + }, + + -- misc + ["windwp/nvim-autopairs"] = { + after = "nvim-cmp", + config = function() + require("plugins.configs.others").autopairs() + end, + }, + + ["numToStr/Comment.nvim"] = { + module = "Comment", + keys = { "gc", "gb" }, + config = function() + require("plugins.configs.others").comment() + end, + setup = function() + require("core.utils").load_mappings "comment" + end, + }, + + -- UI stuff + ["lukas-reineke/indent-blankline.nvim"] = { + event = "BufRead", + config = function() + require("plugins.configs.others").blankline() + end, + setup = function() + require("core.utils").load_mappings "blankline" + end, + }, + + ["krolyxon/nvim-colorizer.lua"] = { + opt = true, + setup = function () + require("core.lazy_load").on_file_open "nvim-colorizer.lua" + end, + config = function() + require("plugins.configs.others").colorizer() + end, + }, + + ["nvim-lualine/lualine.nvim"] = { + config = function() + require("plugins.configs.statusline") + end, + }, + + -- Only load whichkey after all the gui + ["folke/which-key.nvim"] = { + disable = false, + module = "which-key", + keys = "", + config = function() + require "plugins.configs.whichkey" + end, + setup = function() + require("core.utils").load_mappings "whichkey" + end, + }, + -- speed up deffered plugins + ["lewis6991/impatient.nvim"] = {}, +} +require("core.packer").run(plugins)