diff --git a/init.lua b/init.lua index 3d114c6..bf6a2d6 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ vim.defer_fn(function() - pcall(require, "impatient") + pcall(require, "impatient") end, 0) -- setup packer + plugins @@ -7,14 +7,14 @@ 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 } + 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" + -- install plugins + compile their configs + vim.cmd "packadd packer.nvim" + require "plugins" + vim.cmd "PackerSync" end local modules = { @@ -23,12 +23,12 @@ local modules = { } for _, module in ipairs(modules) do - local ok, err = pcall(require, module) - if not ok then + local ok, err = pcall(require, module) + if not ok then error("Error loading " .. module .. "\n\n" .. err) - end + end end -require ("core.utils").load_mappings() +require("core.utils").load_mappings() vim.api.nvim_command("colorscheme gruvbox-baby") diff --git a/lua/core/lazy_load.lua b/lua/core/lazy_load.lua index f75b63d..d840ac4 100644 --- a/lua/core/lazy_load.lua +++ b/lua/core/lazy_load.lua @@ -5,27 +5,27 @@ local autocmd = vim.api.nvim_create_autocmd -- 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) + 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" + -- 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, 0) - else - require("packer").loader(tb.plugin) - end - end - end, - }) + end, + }) end -- load certain plugins only when there's a file opened in the buffer @@ -33,50 +33,50 @@ end -- 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, - } + 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", + "PackerSnapshot", + "PackerSnapshotRollback", + "PackerSnapshotDelete", + "PackerInstall", + "PackerUpdate", + "PackerSync", + "PackerClean", + "PackerCompile", + "PackerStatus", + "PackerProfile", + "PackerLoad", } M.treesitter_cmds = { - "TSInstall", - "TSBufEnable", - "TSBufDisable", - "TSEnable", - "TSDisable", - "TSModuleInfo", + "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, - }) + 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 index be3e3e1..0eda9cc 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -2,312 +2,312 @@ local M = {} M.general = { n = { - [""] = { " noh ", "no highlight"}, + [""] = { " noh ", "no highlight" }, - -- switch between windows - [""] = { "h", "window left" }, - [""] = { "l", "window right" }, - [""] = { "j", "window down" }, - [""] = { "k", "window up" }, + -- switch between windows + [""] = { "h", "window left" }, + [""] = { "l", "window right" }, + [""] = { "j", "window down" }, + [""] = { "k", "window up" }, - -- new buffer - ["b"] = { " enew ", "new buffer" }, + -- new buffer + ["b"] = { " enew ", "new buffer" }, - -- close buffer + hide terminal buffer - ["x"] = { - function() - require("core.utils").close_buffer() - end, - "close buffer", + -- close buffer + hide terminal buffer + ["x"] = { + function() + require("core.utils").close_buffer() + end, + "close buffer", } }, } M.nvimtree = { - plugin = true, + plugin = true, - n = { - -- toggle - [""] = { " NvimTreeToggle ", "toggle nvimtree" }, + n = { + -- toggle + [""] = { " NvimTreeToggle ", "toggle nvimtree" }, - -- focus - ["e"] = { " NvimTreeFocus ", "focus nvimtree" }, - }, + -- focus + ["e"] = { " NvimTreeFocus ", "focus nvimtree" }, + }, } M.nvterm = { - plugin = true, + plugin = true, - t = { - -- toggle in terminal mode - [""] = { - function() - require("nvterm.terminal").toggle "float" - end, - "toggle floating term", + t = { + -- toggle in terminal mode + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "toggle floating term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + "toggle horizontal term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + "toggle vertical term", + }, }, - [""] = { - function() - require("nvterm.terminal").toggle "horizontal" - end, - "toggle horizontal term", - }, + n = { + -- toggle in normal mode + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "toggle floating term", + }, - [""] = { - function() - require("nvterm.terminal").toggle "vertical" - end, - "toggle vertical term", - }, - }, + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + "toggle horizontal term", + }, - n = { - -- toggle in normal mode - [""] = { - function() - require("nvterm.terminal").toggle "float" - end, - "toggle floating term", + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + "toggle vertical term", + }, }, - - [""] = { - function() - require("nvterm.terminal").toggle "horizontal" - end, - "toggle horizontal term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "vertical" - end, - "toggle vertical term", - }, - }, } M.telescope = { - plugin = true, + 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" }, + 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" }, + -- git + ["cm"] = { " Telescope git_commits ", "git commits" }, + ["gt"] = { " Telescope git_status ", "git status" }, - -- theme switcher - ["th"] = { " Telescope colorscheme", "colorthemes" }, - }, + -- theme switcher + ["th"] = { " Telescope colorscheme", "colorthemes" }, + }, } M.whichkey = { - plugin = true, + plugin = true, - n = { - ["wK"] = { - function() - vim.cmd "WhichKey" - end, - "which-key all keymaps", + 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", + }, }, - ["wk"] = { - function() - local input = vim.fn.input "WhichKey: " - vim.cmd("WhichKey " .. input) - end, - "which-key query lookup", - }, - }, } M.comment = { - plugin = true, + plugin = true, - -- toggle comment in both modes - n = { - ["/"] = { - function() - require("Comment.api").toggle.linewise.current() - end, - "toggle comment", + -- 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", + v = { + ["/"] = { + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + "toggle comment", + }, }, - }, } M.lspconfig = { - plugin = true, + plugin = true, - -- See ` :help vim.lsp.*` for documentation on any of the below functions + -- See ` :help vim.lsp.*` for documentation on any of the below functions - n = { - ["gD"] = { - function() - vim.lsp.buf.declaration() - end, - "lsp declaration", + n = { + ["gD"] = { + function() + vim.lsp.buf.declaration() + end, + "lsp declaration", + }, + + ["gd"] = { + function() + vim.lsp.buf.definition() + end, + "lsp definition", + }, + + ["K"] = { + function() + vim.lsp.buf.hover() + end, + "lsp hover", + }, + + ["gi"] = { + function() + vim.lsp.buf.implementation() + end, + "lsp implementation", + }, + + ["ls"] = { + function() + vim.lsp.buf.signature_help() + end, + "lsp signature_help", + }, + + ["D"] = { + function() + vim.lsp.buf.type_definition() + end, + "lsp definition type", + }, + + ["ra"] = { + function() + require("nvchad_ui.renamer").open() + end, + "lsp rename", + }, + + ["ca"] = { + function() + vim.lsp.buf.code_action() + end, + "lsp code_action", + }, + + ["gr"] = { + function() + vim.lsp.buf.references() + end, + "lsp references", + }, + + ["f"] = { + function() + vim.diagnostic.open_float() + end, + "floating diagnostic", + }, + + ["[d"] = { + function() + vim.diagnostic.goto_prev() + end, + "goto prev", + }, + + ["d]"] = { + function() + vim.diagnostic.goto_next() + end, + "goto_next", + }, + + ["q"] = { + function() + vim.diagnostic.setloclist() + end, + "diagnostic setloclist", + }, + + ["fm"] = { + function() + vim.lsp.buf.formatting {} + end, + "lsp formatting", + }, + + ["wa"] = { + function() + vim.lsp.buf.add_workspace_folder() + end, + "add workspace folder", + }, + + ["wr"] = { + function() + vim.lsp.buf.remove_workspace_folder() + end, + "remove workspace folder", + }, + + ["wl"] = { + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, + "list workspace folders", + }, }, - - ["gd"] = { - function() - vim.lsp.buf.definition() - end, - "lsp definition", - }, - - ["K"] = { - function() - vim.lsp.buf.hover() - end, - "lsp hover", - }, - - ["gi"] = { - function() - vim.lsp.buf.implementation() - end, - "lsp implementation", - }, - - ["ls"] = { - function() - vim.lsp.buf.signature_help() - end, - "lsp signature_help", - }, - - ["D"] = { - function() - vim.lsp.buf.type_definition() - end, - "lsp definition type", - }, - - ["ra"] = { - function() - require("nvchad_ui.renamer").open() - end, - "lsp rename", - }, - - ["ca"] = { - function() - vim.lsp.buf.code_action() - end, - "lsp code_action", - }, - - ["gr"] = { - function() - vim.lsp.buf.references() - end, - "lsp references", - }, - - ["f"] = { - function() - vim.diagnostic.open_float() - end, - "floating diagnostic", - }, - - ["[d"] = { - function() - vim.diagnostic.goto_prev() - end, - "goto prev", - }, - - ["d]"] = { - function() - vim.diagnostic.goto_next() - end, - "goto_next", - }, - - ["q"] = { - function() - vim.diagnostic.setloclist() - end, - "diagnostic setloclist", - }, - - ["fm"] = { - function() - vim.lsp.buf.formatting {} - end, - "lsp formatting", - }, - - ["wa"] = { - function() - vim.lsp.buf.add_workspace_folder() - end, - "add workspace folder", - }, - - ["wr"] = { - function() - vim.lsp.buf.remove_workspace_folder() - end, - "remove workspace folder", - }, - - ["wl"] = { - function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, - "list workspace folders", - }, - }, } M.rust = { plugin = true, n = { - ["rr"] = { " RustRun ", "RustRun"}, - ["rR"] = { " RustRunnables ", "RustRunnables"}, - ["rd"] = { " RustDebuggables ", "RustDebuggables"}, - ["rha"] = { " RustHoverActions ", "RustHoverActions"}, - ["roc"] = { " RustOpenCargo ", "RustOpenCargo"}, - ["rcg"] = { " RustViewCrateGraph ", "RustViewCrateGraph"}, + ["rr"] = { " RustRun ", "RustRun" }, + ["rR"] = { " RustRunnables ", "RustRunnables" }, + ["rd"] = { " RustDebuggables ", "RustDebuggables" }, + ["rha"] = { " RustHoverActions ", "RustHoverActions" }, + ["roc"] = { " RustOpenCargo ", "RustOpenCargo" }, + ["rcg"] = { " RustViewCrateGraph ", "RustViewCrateGraph" }, }, } M.blankline = { - plugin = true, + 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 - ) + 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, + 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", + "Jump to current_context", + }, }, - }, } return M diff --git a/lua/core/options.lua b/lua/core/options.lua index 8593b11..64a1aa8 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -4,8 +4,8 @@ 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 + g.did_load_filetypes = 0 + g.do_filetype_lua = 1 end opt.laststatus = 3 -- global statusline @@ -44,26 +44,26 @@ 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", + "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 + g["loaded_" .. plugin] = 1 end diff --git a/lua/core/packer.lua b/lua/core/packer.lua index a2e85dc..f8d7d11 100644 --- a/lua/core/packer.lua +++ b/lua/core/packer.lua @@ -1,41 +1,41 @@ local M = {} M.run = function(plugins) - local present, packer = pcall(require, "packer") + 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) + if not present then + return end - 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 index a281163..d9085f3 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -2,45 +2,45 @@ local M = {} local merge_tb = vim.tbl_deep_extend M.close_buffer = function(bufnr) - if vim.bo.buftype == "terminal" then - vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") - else - bufnr = bufnr or vim.api.nvim_get_current_buf() - vim.cmd("confirm bd" .. bufnr) - end + if vim.bo.buftype == "terminal" then + vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") + else + bufnr = bufnr or vim.api.nvim_get_current_buf() + vim.cmd("confirm bd" .. bufnr) + end end M.load_mappings = function(section, mapping_opt) - local function set_section_map(section_values) - if section_values.plugin then - return + 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 - 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 {}) + local mappings = require("core.mappings") - mapping_info.opts, opts.mode = nil, nil - opts.desc = mapping_info[2] - - vim.keymap.set(mode, keybind, mapping_info[1], opts) - end + if type(section) == "string" then + mappings[section]["plugin"] = nil + mappings = { mappings[section] } 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 + 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 index c34ac5c..a40fa5b 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -1,139 +1,139 @@ local present, cmp = pcall(require, "cmp") if not present then - return + 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 }, - } + 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 + local info = self:info_() + info.scrollable = false + return info end local options = { - window = { - completion = { - border = border "CmpBorder", - winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + window = { + completion = { + border = border "CmpBorder", + winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + documentation = { + border = border "CmpDocBorder", + }, }, - documentation = { - border = border "CmpDocBorder", + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, }, - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - formatting = { + formatting = { format = function(_, vim_item) - local icons = { - Namespace = "", - Text = " ", - Method = " ", - Function = " ", - Constructor = " ", - Field = "ﰠ ", - Variable = " ", - Class = "ﴯ ", - Interface = " ", - Module = " ", - Property = "ﰠ ", - Unit = "塞 ", - Value = " ", - Enum = " ", - Keyword = " ", - Snippet = " ", - Color = " ", - File = " ", - Reference = " ", - Folder = " ", - EnumMember = " ", - Constant = " ", - Struct = "פּ ", - Event = " ", - Operator = " ", - TypeParameter = " ", - Table = "", - Object = " ", - Tag = "", - Array = "[]", - Boolean = " ", - Number = " ", - Null = "ﳠ", - String = " ", - Calendar = "", - Watch = " ", - Package = "", + local icons = { + Namespace = "", + Text = " ", + Method = " ", + Function = " ", + Constructor = " ", + Field = "ﰠ ", + Variable = " ", + Class = "ﴯ ", + Interface = " ", + Module = " ", + Property = "ﰠ ", + Unit = "塞 ", + Value = " ", + Enum = " ", + Keyword = " ", + Snippet = " ", + Color = " ", + File = " ", + Reference = " ", + Folder = " ", + EnumMember = " ", + Constant = " ", + Struct = "פּ ", + Event = " ", + Operator = " ", + TypeParameter = " ", + Table = "", + Object = " ", + Tag = "", + Array = "[]", + Boolean = " ", + Number = " ", + Null = "ﳠ", + String = " ", + Calendar = "", + Watch = " ", + Package = "", } - vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) - return vim_item - 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, + vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) + return vim_item + 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" }, + { name = "crates" }, }, - [""] = 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" }, - { name = "crates" }, - }, } -- check for any override diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 885955f..70018cf 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,7 +1,7 @@ local present, lspconfig = pcall(require, "lspconfig") if not present then - return + return end local M = {} @@ -10,110 +10,110 @@ local utils = require "core.utils" -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) - -- if vim.g.vim_version > 7 then - -- -- nightly - -- client.server_capabilities.documentFormattingProvider = false - -- client.server_capabilities.documentRangeFormattingProvider = false - -- else - -- -- stable - -- client.resolved_capabilities.document_formatting = false - -- client.resolved_capabilities.document_range_formatting = false - -- end + -- if vim.g.vim_version > 7 then + -- -- nightly + -- client.server_capabilities.documentFormattingProvider = false + -- client.server_capabilities.documentRangeFormattingProvider = false + -- else + -- -- stable + -- client.resolved_capabilities.document_formatting = false + -- client.resolved_capabilities.document_range_formatting = false + -- end - utils.load_mappings("lspconfig", { buffer = bufnr }) + utils.load_mappings("lspconfig", { buffer = bufnr }) - if client.server_capabilities.signatureHelpProvider then - local function lspSymbol(name, icon) - local hl = "DiagnosticSign" .. name - vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl }) + if client.server_capabilities.signatureHelpProvider then + local function lspSymbol(name, icon) + local hl = "DiagnosticSign" .. name + vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl }) + end + + lspSymbol("Error", "") + lspSymbol("Info", "") + lspSymbol("Hint", "") + lspSymbol("Warn", "") + + vim.diagnostic.config { + virtual_text = { + prefix = "", + }, + signs = true, + underline = true, + update_in_insert = false, + } + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "single", + }) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "single", + focusable = false, + relative = "cursor", + }) + + -- suppress error messages from lang servers + vim.notify = function(msg, log_level) + if msg:match "exit code" then + return + end + if log_level == vim.log.levels.ERROR then + vim.api.nvim_err_writeln(msg) + else + vim.api.nvim_echo({ { msg } }, true, {}) + end + end + + -- Borders for LspInfo winodw + local win = require "lspconfig.ui.windows" + local _default_opts = win.default_opts + + win.default_opts = function(options) + local opts = _default_opts(options) + opts.border = "single" + return opts + end end - - lspSymbol("Error", "") - lspSymbol("Info", "") - lspSymbol("Hint", "") - lspSymbol("Warn", "") - - vim.diagnostic.config { - virtual_text = { - prefix = "", - }, - signs = true, - underline = true, - update_in_insert = false, - } - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "single", - }) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "single", - focusable = false, - relative = "cursor", - }) - - -- suppress error messages from lang servers - vim.notify = function(msg, log_level) - if msg:match "exit code" then - return - end - if log_level == vim.log.levels.ERROR then - vim.api.nvim_err_writeln(msg) - else - vim.api.nvim_echo({ { msg } }, true, {}) - end - end - - -- Borders for LspInfo winodw - local win = require "lspconfig.ui.windows" - local _default_opts = win.default_opts - - win.default_opts = function(options) - local opts = _default_opts(options) - opts.border = "single" - return opts - end - end end M.capabilities = vim.lsp.protocol.make_client_capabilities() M.capabilities.textDocument.completion.completionItem = { - documentationFormat = { "markdown", "plaintext" }, - snippetSupport = true, - preselectSupport = true, - insertReplaceSupport = true, - labelDetailsSupport = true, - deprecatedSupport = true, - commitCharactersSupport = true, - tagSupport = { valueSet = { 1 } }, - resolveSupport = { - properties = { - "documentation", - "detail", - "additionalTextEdits", + documentationFormat = { "markdown", "plaintext" }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, }, - }, } lspconfig.sumneko_lua.setup { - on_attach = M.on_attach, - capabilities = M.capabilities, + on_attach = M.on_attach, + capabilities = M.capabilities, - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand "$VIMRUNTIME/lua"] = true, - [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + 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, + }, }, - maxPreload = 100000, - preloadFileSize = 10000, - }, }, - }, } -- lspconfig.rust_analyzer.setup { diff --git a/lua/plugins/configs/mason.lua b/lua/plugins/configs/mason.lua index 02424cf..45d3fe2 100644 --- a/lua/plugins/configs/mason.lua +++ b/lua/plugins/configs/mason.lua @@ -1,32 +1,32 @@ local present, mason = pcall(require, "mason") if not present then - return + return end local options = { - ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim - ui = { - icons = { - package_pending = " ", - package_installed = " ", - package_uninstalled = "ﮊ ", + 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 = "", + }, }, - 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, + max_concurrent_installers = 10, } mason.setup(options) diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/configs/nvimtree.lua index 254ac47..6a4835c 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/configs/nvimtree.lua @@ -1,84 +1,84 @@ local present, nvimtree = pcall(require, "nvim-tree") if not present then - return + return end local options = { - filters = { - dotfiles = false, - exclude = { vim.fn.stdpath "config" .. "/lua/custom" }, - }, - disable_netrw = true, - hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = { "alpha" }, - hijack_cursor = true, - hijack_unnamed_buffer_when_opening = false, - update_cwd = true, - update_focused_file = { - enable = true, - update_cwd = false, - }, - view = { - adaptive_size = true, - side = "left", - width = 25, - hide_root_folder = true, - }, - git = { - enable = false, - ignore = true, - }, - filesystem_watchers = { - enable = true, - }, - actions = { - open_file = { - resize_window = true, + filters = { + dotfiles = false, + exclude = { vim.fn.stdpath "config" .. "/lua/custom" }, }, - }, - renderer = { - highlight_git = false, - highlight_opened_files = "none", - - indent_markers = { - enable = false, + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { "alpha" }, + hijack_cursor = true, + hijack_unnamed_buffer_when_opening = false, + update_cwd = true, + update_focused_file = { + enable = true, + update_cwd = false, }, - - icons = { - show = { - file = true, - folder = true, - folder_arrow = true, - git = false, - }, - - glyphs = { - default = "", - symlink = "", - folder = { - default = "", - empty = "", - empty_open = "", - open = "", - symlink = "", - symlink_open = "", - arrow_open = "", - arrow_closed = "", + view = { + adaptive_size = true, + side = "left", + width = 25, + hide_root_folder = true, + }, + git = { + enable = false, + ignore = true, + }, + filesystem_watchers = { + enable = true, + }, + actions = { + open_file = { + resize_window = true, + }, + }, + renderer = { + highlight_git = false, + highlight_opened_files = "none", + + indent_markers = { + enable = false, + }, + + icons = { + show = { + file = true, + folder = true, + folder_arrow = true, + git = false, + }, + + glyphs = { + default = "", + symlink = "", + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + symlink_open = "", + arrow_open = "", + arrow_closed = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, + }, }, - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★", - deleted = "", - ignored = "◌", - }, - }, }, - }, } -- check for any override diff --git a/lua/plugins/configs/nvterm.lua b/lua/plugins/configs/nvterm.lua index a7dc6e4..e43021a 100644 --- a/lua/plugins/configs/nvterm.lua +++ b/lua/plugins/configs/nvterm.lua @@ -1,30 +1,30 @@ local present, nvterm = pcall(require, "nvterm") if not present then - return + return end local options = { - terminals = { - list = {}, - type_opts = { - float = { - relative = "editor", - row = 0.3, - col = 0.25, - width = 0.5, - height = 0.4, - border = "single", - }, - horizontal = { location = "rightbelow", split_ratio = 0.4 }, - vertical = { location = "rightbelow", split_ratio = 0.5 }, + terminals = { + list = {}, + type_opts = { + float = { + relative = "editor", + row = 0.3, + col = 0.25, + width = 0.5, + height = 0.4, + border = "single", + }, + horizontal = { location = "rightbelow", split_ratio = 0.4 }, + vertical = { location = "rightbelow", split_ratio = 0.5 }, + }, }, - }, - behavior = { - close_on_exit = true, - auto_insert = true, - }, - enable_new_mappings = true, + behavior = { + close_on_exit = true, + auto_insert = true, + }, + enable_new_mappings = true, } nvterm.setup(options) diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index c653c85..d093cb6 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -1,72 +1,71 @@ local M = {} M.autopairs = function() - local present1, autopairs = pcall(require, "nvim-autopairs") - local present2, cmp = pcall(require, "cmp") + local present1, autopairs = pcall(require, "nvim-autopairs") + local present2, cmp = pcall(require, "cmp") - if not (present1 and present2) then - return - end + if not (present1 and present2) then + return + end - local options = { - fast_wrap = {}, - disable_filetype = { "TelescopePrompt", "vim" }, - } + local options = { + fast_wrap = {}, + disable_filetype = { "TelescopePrompt", "vim" }, + } - autopairs.setup(options) + autopairs.setup(options) - local cmp_autopairs = require "nvim-autopairs.completion.cmp" - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + 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") + local present, luasnip = pcall(require, "luasnip") - if not present then - return - end + if not present then + return + end - local options = { - history = true, - updateevents = "TextChanged,TextChangedI", - } + 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 "" } + 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, - }) + 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") + local present, gitsigns = pcall(require, "gitsigns") - if not present then - return - end + if not present then + return + end - local options = { - signs = { - add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, - change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, - delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, - topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, - changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, - }, - } - gitsigns.setup(options) + local options = { + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + } + gitsigns.setup(options) end -M.crates = function () +M.crates = function() local present, crates = pcall(require, "crates") if not present then @@ -89,73 +88,73 @@ M.crates = function () end M.blankline = function() - local present, blankline = pcall(require, "indent_blankline") + local present, blankline = pcall(require, "indent_blankline") - if not present then - return - end + 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, - } + 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) + blankline.setup(options) end M.colorizer = function() - local present, colorizer = pcall(require, "colorizer") + local present, colorizer = pcall(require, "colorizer") - if not present then - return - end + 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. - }, - } + 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]] + 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") + local present, nvim_comment = pcall(require, "Comment") - if not present then - return - end + if not present then + return + end - local options = {} - nvim_comment.setup(options) + 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 index c7c29c7..f69bc25 100644 --- a/lua/plugins/configs/rust-tools.lua +++ b/lua/plugins/configs/rust-tools.lua @@ -8,30 +8,30 @@ capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) local options = { - tools = { - inlay_hints = { - auto = true, - only_current_line = false, - -- whether to show parameter hints with the inlay hints or not - -- default: true - show_parameter_hints = true, + tools = { + inlay_hints = { + auto = true, + only_current_line = false, + -- whether to show parameter hints with the inlay hints or not + -- default: true + show_parameter_hints = true, + }, + on_initialized = function() + -- ih.set_all() + end, + }, + server = { + on_attach = + require("plugins.configs.lspconfig").on_attach }, - on_initialized = function() - -- ih.set_all() - end, - }, - server = { - on_attach = - require("plugins.configs.lspconfig").on_attach - }, - settings = { - ["rust-analyzer"] = { - checkOnSave = { - command = "check", - } - } - } + settings = { + ["rust-analyzer"] = { + checkOnSave = { + command = "check", + } + } + } } rust.setup(options) diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua index 56c426a..a51b983 100644 --- a/lua/plugins/configs/statusline.lua +++ b/lua/plugins/configs/statusline.lua @@ -1,40 +1,40 @@ require('lualine').setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = { - statusline = {}, - winbar = {}, + 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, + } }, - 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 = {} + 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 index 4160303..da61ed5 100644 --- a/lua/plugins/configs/telescope.lua +++ b/lua/plugins/configs/telescope.lua @@ -1,62 +1,62 @@ local present, telescope = pcall(require, "telescope") if not present then - return + 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", + 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 }, + }, }, - 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" }, + extensions_list = { "themes", "terms" }, } -- check for any override @@ -64,7 +64,7 @@ telescope.setup(options) -- load extensions pcall(function() - for _, ext in ipairs(options.extensions_list) do - telescope.load_extension(ext) - end + for _, ext in ipairs(options.extensions_list) do + telescope.load_extension(ext) + end end) diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/configs/whichkey.lua index 26a1040..e441192 100644 --- a/lua/plugins/configs/whichkey.lua +++ b/lua/plugins/configs/whichkey.lua @@ -1,37 +1,37 @@ local present, wk = pcall(require, "which-key") if not present then - return + 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 - }, + 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 - }, + 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 - }, + window = { + border = "none", -- none/single/double/shadow + }, - layout = { - spacing = 6, -- spacing between columns - }, + layout = { + spacing = 6, -- spacing between columns + }, - hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - i = { "j", "k" }, - v = { "j", "k" }, - }, + 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 index 7063c5e..b430238 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -2,184 +2,184 @@ vim.cmd "packadd packer.nvim" local plugins = { ["wbthomason/packer.nvim"] = { - cmd = require("core.lazy_load").packer_cmds, - config = function() - require "plugins" - end, + cmd = require("core.lazy_load").packer_cmds, + config = function() + require "plugins" + end, }, ["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, + 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, + ft = "gitcommit", + setup = function() + require("core.lazy_load").gitsigns() + end, + config = function() + require("plugins.configs.others").gitsigns() + end, }, - ['nvim-lua/plenary.nvim'] = {}, + ['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"] = { - after = "nvim-lspconfig", - config = function () - require("plugins.configs.rust-tools") - require("core.utils").load_mappings "rust" - end, - }, - - ["Saecki/crates.nvim"] = { - event = { "BufRead Cargo.toml" }, - config = function () - require("plugins.configs.others").crates() - 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, - }, - - -- file managing , picker etc - ["kyazdani42/nvim-tree.lua"] = { - ft = "alpha", - cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - config = function() - require "plugins.configs.nvimtree" - end, - setup = function() - require("core.utils").load_mappings "nvimtree" - end, - }, - - ["NvChad/nvterm"] = { - module = "nvterm", - config = function() - require "plugins.configs.nvterm" - end, - setup = function() - require("core.utils").load_mappings "nvterm" - 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" + ["nvim-telescope/telescope.nvim"] = { + cmd = "Telescope", + config = function() + require "plugins.configs.telescope" end, - config = function() - require("plugins.configs.others").colorizer() + 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"] = { + after = "nvim-lspconfig", + config = function() + require("plugins.configs.rust-tools") + require("core.utils").load_mappings "rust" + end, + }, + + ["Saecki/crates.nvim"] = { + event = { "BufRead Cargo.toml" }, + config = function() + require("plugins.configs.others").crates() + 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, + }, + + -- file managing , picker etc + ["kyazdani42/nvim-tree.lua"] = { + ft = "alpha", + cmd = { "NvimTreeToggle", "NvimTreeFocus" }, + config = function() + require "plugins.configs.nvimtree" + end, + setup = function() + require("core.utils").load_mappings "nvimtree" + end, + }, + + ["NvChad/nvterm"] = { + module = "nvterm", + config = function() + require "plugins.configs.nvterm" + end, + setup = function() + require("core.utils").load_mappings "nvterm" + 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() @@ -189,17 +189,17 @@ local plugins = { -- 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, + 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"] = {}, + ["lewis6991/impatient.nvim"] = {}, } require("core.packer").run(plugins)