summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/core')
-rw-r--r--.config/nvim/lua/core/autocmds.lua145
-rw-r--r--.config/nvim/lua/core/autopairs.lua79
-rw-r--r--.config/nvim/lua/core/bufferline.lua21
-rw-r--r--.config/nvim/lua/core/builtins/init.lua26
-rw-r--r--.config/nvim/lua/core/cmp.lua309
-rw-r--r--.config/nvim/lua/core/commands.lua28
-rw-r--r--.config/nvim/lua/core/comment.lua71
-rw-r--r--.config/nvim/lua/core/dashboard.lua112
-rw-r--r--.config/nvim/lua/core/gitsigns.lua61
-rw-r--r--.config/nvim/lua/core/info.lua206
-rw-r--r--.config/nvim/lua/core/log.lua127
-rw-r--r--.config/nvim/lua/core/lualine/colors.lua19
-rw-r--r--.config/nvim/lua/core/lualine/components.lua179
-rw-r--r--.config/nvim/lua/core/lualine/conditions.lua17
-rw-r--r--.config/nvim/lua/core/lualine/init.lua47
-rw-r--r--.config/nvim/lua/core/lualine/styles.lua185
-rw-r--r--.config/nvim/lua/core/lualine/utils.lua27
-rw-r--r--.config/nvim/lua/core/nvimtree.lua175
-rw-r--r--.config/nvim/lua/core/project.lua51
-rw-r--r--.config/nvim/lua/core/telescope.lua159
-rw-r--r--.config/nvim/lua/core/terminal.lua118
-rw-r--r--.config/nvim/lua/core/treesitter.lua94
-rw-r--r--.config/nvim/lua/core/which-key.lua283
23 files changed, 0 insertions, 2539 deletions
diff --git a/.config/nvim/lua/core/autocmds.lua b/.config/nvim/lua/core/autocmds.lua
deleted file mode 100644
index 046b7c0..0000000
--- a/.config/nvim/lua/core/autocmds.lua
+++ /dev/null
@@ -1,145 +0,0 @@
-local M = {}
-local Log = require "core.log"
-
---- Load the default set of autogroups and autocommands.
-function M.load_augroups()
- local user_config_file = require("config"):get_user_config_path()
-
- return {
- _general_settings = {
- { "FileType", "qf,help,man", "nnoremap <silent> <buffer> q :close<CR>" },
- {
- "TextYankPost",
- "*",
- "lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})",
- },
- {
- "BufWinEnter",
- "dashboard",
- "setlocal cursorline signcolumn=yes cursorcolumn number",
- },
- { "BufWritePost", user_config_file, "lua require('config'):reload()" },
- { "FileType", "qf", "set nobuflisted" },
- -- { "VimLeavePre", "*", "set title set titleold=" },
- },
- _formatoptions = {
- {
- "BufWinEnter,BufRead,BufNewFile",
- "*",
- "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
- },
- },
- _filetypechanges = {
- { "BufWinEnter", ".tf", "setlocal filetype=terraform" },
- { "BufRead", "*.tf", "setlocal filetype=terraform" },
- { "BufNewFile", "*.tf", "setlocal filetype=terraform" },
- { "BufWinEnter", ".zsh", "setlocal filetype=sh" },
- { "BufRead", "*.zsh", "setlocal filetype=sh" },
- { "BufNewFile", "*.zsh", "setlocal filetype=sh" },
- },
- _git = {
- { "FileType", "gitcommit", "setlocal wrap" },
- { "FileType", "gitcommit", "setlocal spell" },
- },
- _markdown = {
- { "FileType", "markdown", "setlocal wrap" },
- { "FileType", "markdown", "setlocal spell" },
- },
- _buffer_bindings = {
- { "FileType", "floaterm", "nnoremap <silent> <buffer> q :q<CR>" },
- },
- _auto_resize = {
- -- will cause split windows to be resized evenly if main window is resized
- { "VimResized", "*", "tabdo wincmd =" },
- },
- _general_lsp = {
- {
- "FileType",
- "lspinfo,lsp-installer,null-ls-info",
- "nnoremap <silent> <buffer> q :close<CR>",
- },
- },
- custom_groups = {},
- }
-end
-
-local get_format_on_save_opts = function()
- local defaults = require("config.defaults").format_on_save
- -- accept a basic boolean `format_on_save=true`
- if type(options.format_on_save) ~= "table" then
- return defaults
- end
-
- return {
- pattern = options.format_on_save.pattern or defaults.pattern,
- timeout = options.format_on_save.timeout or defaults.timeout,
- }
-end
-
-function M.enable_format_on_save(opts)
- local fmd_cmd = string.format(
- ":silent lua vim.lsp.buf.formatting_sync({}, %s)",
- opts.timeout_ms
- )
- M.define_augroups {
- format_on_save = { { "BufWritePre", opts.pattern, fmd_cmd } },
- }
- Log:debug "enabled format-on-save"
-end
-
-function M.disable_format_on_save()
- M.remove_augroup "format_on_save"
- Log:debug "disabled format-on-save"
-end
-
-function M.configure_format_on_save()
- if options.format_on_save then
- if vim.fn.exists "#format_on_save#BufWritePre" == 1 then
- M.remove_augroup "format_on_save"
- Log:debug "reloading format-on-save configuration"
- end
- local opts = get_format_on_save_opts()
- M.enable_format_on_save(opts)
- else
- M.disable_format_on_save()
- end
-end
-
-function M.toggle_format_on_save()
- if vim.fn.exists "#format_on_save#BufWritePre" == 0 then
- local opts = get_format_on_save_opts()
- M.enable_format_on_save(opts)
- else
- M.disable_format_on_save()
- end
-end
-
-function M.remove_augroup(name)
- if vim.fn.exists("#" .. name) == 1 then
- vim.cmd("au! " .. name)
- end
-end
-
-function M.define_augroups(definitions) -- {{{1
- -- Create autocommand groups based on the passed definitions
- --
- -- The key will be the name of the group, and each definition
- -- within the group should have:
- -- 1. Trigger
- -- 2. Pattern
- -- 3. Text
- -- just like how they would normally be defined from Vim itself
- for group_name, definition in pairs(definitions) do
- vim.cmd("augroup " .. group_name)
- vim.cmd "autocmd!"
-
- for _, def in pairs(definition) do
- local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ")
- vim.cmd(command)
- end
-
- vim.cmd "augroup END"
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/autopairs.lua b/.config/nvim/lua/core/autopairs.lua
deleted file mode 100644
index 0759fd6..0000000
--- a/.config/nvim/lua/core/autopairs.lua
+++ /dev/null
@@ -1,79 +0,0 @@
-local M = {}
-
-function M.config()
- options.builtin.autopairs = {
- active = true,
- on_config_done = nil,
- ---@usage -- modifies the function or method delimiter by filetypes
- map_char = {
- all = "(",
- tex = "{",
- },
- enable_check_bracket_line = false,
- ---@usage check treesitter
- check_ts = true,
- ts_config = {
- lua = { "string" },
- javascript = { "template_string" },
- java = false,
- },
- }
-end
-
-M.setup = function()
- local autopairs = require "nvim-autopairs"
- local Rule = require "nvim-autopairs.rule"
- local cond = require "nvim-autopairs.conds"
-
- autopairs.setup {
- check_ts = options.builtin.autopairs.check_ts,
- enable_check_bracket_line = options.builtin.autopairs.enable_check_bracket_line,
- ts_config = options.builtin.autopairs.ts_config,
- }
-
- -- vim.g.completion_confirm_key = ""
-
- autopairs.add_rule(Rule("$$", "$$", "tex"))
- autopairs.add_rules {
- Rule("$", "$", { "tex", "latex" }) -- don't add a pair if the next character is %
- :with_pair(cond.not_after_regex_check "%%") -- don't add a pair if the previous character is xxx
- :with_pair(cond.not_before_regex_check("xxx", 3)) -- don't move right when repeat character
- :with_move(cond.none()) -- don't delete if the next character is xx
- :with_del(cond.not_after_regex_check "xx") -- disable add newline when press <cr>
- :with_cr(cond.none()),
- }
- autopairs.add_rules {
- Rule("$$", "$$", "tex"):with_pair(function(opts)
- print(vim.inspect(opts))
- if opts.line == "aa $$" then
- -- don't add pair on that line
- return false
- end
- end),
- }
-
- local cmp_status_ok, cmp = pcall(require, "cmp")
- if cmp_status_ok then
- -- If you want insert `(` after select function or method item
- local cmp_autopairs = require "nvim-autopairs.completion.cmp"
- local map_char = options.builtin.autopairs.map_char
- cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = map_char })
- end
-
- require("nvim-treesitter.configs").setup { autopairs = { enable = true } }
-
- local ts_conds = require "nvim-autopairs.ts-conds"
-
- -- TODO: can these rules be safely added from "config.lua" ?
- -- press % => %% is only inside comment or string
- autopairs.add_rules {
- Rule("%", "%", "lua"):with_pair(ts_conds.is_ts_node { "string", "comment" }),
- Rule("$", "$", "lua"):with_pair(ts_conds.is_not_ts_node { "function" }),
- }
-
- if options.builtin.autopairs.on_config_done then
- options.builtin.autopairs.on_config_done(autopairs)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/bufferline.lua b/.config/nvim/lua/core/bufferline.lua
deleted file mode 100644
index ebd7a64..0000000
--- a/.config/nvim/lua/core/bufferline.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-local M = {}
-
-M.config = function()
- options.builtin.bufferline = {
- active = true,
- on_config_done = nil,
- keymap = {
- normal_mode = {},
- },
- }
-end
-
-M.setup = function()
- require("keymappings").load(options.builtin.bufferline.keymap)
-
- if options.builtin.bufferline.on_config_done then
- options.builtin.bufferline.on_config_done()
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/builtins/init.lua b/.config/nvim/lua/core/builtins/init.lua
deleted file mode 100644
index 10ce680..0000000
--- a/.config/nvim/lua/core/builtins/init.lua
+++ /dev/null
@@ -1,26 +0,0 @@
-local M = {}
-
-local builtins = {
- "core.which-key",
- "core.gitsigns",
- "core.cmp",
- "core.dashboard",
- "core.terminal",
- "core.telescope",
- "core.treesitter",
- "core.nvimtree",
- "core.project",
- "core.bufferline",
- "core.autopairs",
- "core.comment",
- "core.lualine",
-}
-
-function M.config(config)
- for _, builtin_path in ipairs(builtins) do
- local builtin = require(builtin_path)
- builtin.config(config)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/cmp.lua b/.config/nvim/lua/core/cmp.lua
deleted file mode 100644
index fe4119f..0000000
--- a/.config/nvim/lua/core/cmp.lua
+++ /dev/null
@@ -1,309 +0,0 @@
-local M = {}
-M.methods = {}
-
----checks if the character preceding the cursor is a space character
----@return boolean true if it is a space character, false otherwise
-local check_backspace = function()
- local col = vim.fn.col "." - 1
- return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
-end
-M.methods.check_backspace = check_backspace
-
-local function T(str)
- return vim.api.nvim_replace_termcodes(str, true, true, true)
-end
-
----wraps vim.fn.feedkeys while replacing key codes with escape codes
----Ex: feedkeys("<CR>", "n") becomes feedkeys("^M", "n")
----@param key string
----@param mode string
-local function feedkeys(key, mode)
- vim.fn.feedkeys(T(key), mode)
-end
-M.methods.feedkeys = feedkeys
-
----checks if emmet_ls is available and active in the buffer
----@return boolean true if available, false otherwise
-local is_emmet_active = function()
- local clients = vim.lsp.buf_get_clients()
-
- for _, client in pairs(clients) do
- if client.name == "emmet_ls" then
- return true
- end
- end
- return false
-end
-M.methods.is_emmet_active = is_emmet_active
-
----when inside a snippet, seeks to the nearest luasnip field if possible, and checks if it is jumpable
----@param dir number 1 for forward, -1 for backward; defaults to 1
----@return boolean true if a jumpable luasnip field is found while inside a snippet
-local function jumpable(dir)
- local luasnip_ok, luasnip = pcall(require, "luasnip")
- if not luasnip_ok then
- return
- end
-
- local win_get_cursor = vim.api.nvim_win_get_cursor
- local get_current_buf = vim.api.nvim_get_current_buf
-
- local function inside_snippet()
- -- for outdated versions of luasnip
- if not luasnip.session.current_nodes then
- return false
- end
-
- local node = luasnip.session.current_nodes[get_current_buf()]
- if not node then
- return false
- end
-
- local snip_begin_pos, snip_end_pos = node.parent.snippet.mark:pos_begin_end()
- local pos = win_get_cursor(0)
- pos[1] = pos[1] - 1 -- LuaSnip is 0-based not 1-based like nvim for rows
- return pos[1] >= snip_begin_pos[1] and pos[1] <= snip_end_pos[1]
- end
-
- ---sets the current buffer's luasnip to the one nearest the cursor
- ---@return boolean true if a node is found, false otherwise
- local function seek_luasnip_cursor_node()
- -- for outdated versions of luasnip
- if not luasnip.session.current_nodes then
- return false
- end
-
- local pos = win_get_cursor(0)
- pos[1] = pos[1] - 1
- local node = luasnip.session.current_nodes[get_current_buf()]
- if not node then
- return false
- end
-
- local snippet = node.parent.snippet
- local exit_node = snippet.insert_nodes[0]
-
- -- exit early if we're past the exit node
- if exit_node then
- local exit_pos_end = exit_node.mark:pos_end()
- if
- (pos[1] > exit_pos_end[1])
- or (pos[1] == exit_pos_end[1] and pos[2] > exit_pos_end[2])
- then
- snippet:remove_from_jumplist()
- luasnip.session.current_nodes[get_current_buf()] = nil
-
- return false
- end
- end
-
- node = snippet.inner_first:jump_into(1, true)
- while node ~= nil and node.next ~= nil and node ~= snippet do
- local n_next = node.next
- local next_pos = n_next and n_next.mark:pos_begin()
- local candidate = n_next ~= snippet and next_pos and (pos[1] < next_pos[1])
- or (pos[1] == next_pos[1] and pos[2] < next_pos[2])
-
- -- Past unmarked exit node, exit early
- if n_next == nil or n_next == snippet.next then
- snippet:remove_from_jumplist()
- luasnip.session.current_nodes[get_current_buf()] = nil
-
- return false
- end
-
- if candidate then
- luasnip.session.current_nodes[get_current_buf()] = node
- return true
- end
-
- local ok
- ok, node = pcall(node.jump_from, node, 1, true) -- no_move until last stop
- if not ok then
- snippet:remove_from_jumplist()
- luasnip.session.current_nodes[get_current_buf()] = nil
-
- return false
- end
- end
-
- -- No candidate, but have an exit node
- if exit_node then
- -- to jump to the exit node, seek to snippet
- luasnip.session.current_nodes[get_current_buf()] = snippet
- return true
- end
-
- -- No exit node, exit from snippet
- snippet:remove_from_jumplist()
- luasnip.session.current_nodes[get_current_buf()] = nil
- return false
- end
-
- if dir == -1 then
- return inside_snippet() and luasnip.jumpable(-1)
- else
- return inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable()
- end
-end
-M.methods.jumpable = jumpable
-
-M.config = function()
- local status_cmp_ok, cmp = pcall(require, "cmp")
- if not status_cmp_ok then
- return
- end
- local status_luasnip_ok, luasnip = pcall(require, "luasnip")
- if not status_luasnip_ok then
- return
- end
-
- options.builtin.cmp = {
- confirm_opts = {
- behavior = cmp.ConfirmBehavior.Replace,
- select = false,
- },
- completion = {
- ---@usage The minimum length of a word to complete on.
- keyword_length = 1,
- },
- experimental = {
- ghost_text = true,
- native_menu = false,
- },
- formatting = {
- fields = { "kind", "abbr", "menu" },
- kind_icons = {
- Class = " ",
- Color = " ",
- Constant = "ﲀ ",
- Constructor = " ",
- Enum = "練",
- EnumMember = " ",
- Event = " ",
- Field = " ",
- File = "",
- Folder = " ",
- Function = " ",
- Interface = "ﰮ ",
- Keyword = " ",
- Method = " ",
- Module = " ",
- Operator = "",
- Property = " ",
- Reference = " ",
- Snippet = " ",
- Struct = " ",
- Text = " ",
- TypeParameter = " ",
- Unit = "塞",
- Value = " ",
- Variable = " ",
- },
- source_names = {
- nvim_lsp = "(LSP)",
- path = "(Path)",
- calc = "(Calc)",
- cmp_tabnine = "(Tabnine)",
- vsnip = "(Snippet)",
- luasnip = "(Snippet)",
- buffer = "(Buffer)",
- },
- duplicates = {
- buffer = 1,
- path = 1,
- nvim_lsp = 0,
- luasnip = 1,
- },
- duplicates_default = 0,
- format = function(entry, vim_item)
- vim_item.kind = options.builtin.cmp.formatting.kind_icons[vim_item.kind]
- vim_item.menu = options.builtin.cmp.formatting.source_names[entry.source.name]
- vim_item.dup = options.builtin.cmp.formatting.duplicates[entry.source.name]
- or options.builtin.cmp.formatting.duplicates_default
- return vim_item
- end,
- },
- snippet = {
- expand = function(args)
- require("luasnip").lsp_expand(args.body)
- end,
- },
- documentation = {
- border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
- },
- sources = {
- { name = "nvim_lsp" },
- { name = "path" },
- { name = "luasnip" },
- { name = "cmp_tabnine" },
- { name = "nvim_lua" },
- { name = "buffer", keyword_length = 5 },
- { name = "calc" },
- { name = "treesitter" },
- { name = "crates" },
- },
- mapping = {
- ["<C-k>"] = cmp.mapping.select_prev_item(),
- ["<C-j>"] = cmp.mapping.select_next_item(),
- ["<C-d>"] = cmp.mapping.scroll_docs(-4),
- ["<C-f>"] = cmp.mapping.scroll_docs(4),
- -- TODO: potentially fix emmet nonsense
- ["<Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_next_item()
- elseif luasnip.expandable() then
- luasnip.expand()
- elseif jumpable() then
- luasnip.jump(1)
- elseif check_backspace() then
- fallback()
- elseif is_emmet_active() then
- return vim.fn["cmp#complete"]()
- else
- fallback()
- end
- end, {
- "i",
- "s",
- }),
- ["<S-Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_prev_item()
- elseif jumpable(-1) then
- luasnip.jump(-1)
- else
- fallback()
- end
- end, {
- "i",
- "s",
- }),
-
- ["<C-Space>"] = cmp.mapping.complete(),
- ["<C-e>"] = cmp.mapping.abort(),
- ["<CR>"] = cmp.mapping(function(fallback)
- if cmp.visible() and cmp.confirm(options.builtin.cmp.confirm_opts) then
- if jumpable() then
- luasnip.jump(1)
- end
- return
- end
-
- if jumpable() then
- if not luasnip.jump(1) then
- fallback()
- end
- else
- fallback()
- end
- end),
- },
- }
-end
-
-M.setup = function()
- require("cmp").setup(options.builtin.cmp)
-end
-
-return M
diff --git a/.config/nvim/lua/core/commands.lua b/.config/nvim/lua/core/commands.lua
deleted file mode 100644
index bb22dea..0000000
--- a/.config/nvim/lua/core/commands.lua
+++ /dev/null
@@ -1,28 +0,0 @@
-local M = {}
-
-M.defaults = {
- [[
- function! QuickFixToggle()
- if empty(filter(getwininfo(), 'v:val.quickfix'))
- copen
- else
- cclose
- endif
- endfunction
- ]],
- -- :NvimInfo
- [[ command! NvimInfo lua require('core.info').toggle_popup(vim.bo.filetype) ]],
- [[ command! NvimCacheReset lua require('utils.hooks').reset_cache() ]],
- [[ command! NvimUpdate lua require('bootstrap').update() ]],
- [[ command! NvimSyncCorePlugins lua require('plugin-loader'):sync_core_plugins() ]],
- [[ command! NvimReload lua require('config'):reload() ]],
- [[ command! NvimToggleFormatOnSave lua require('core.autocmds').toggle_format_on_save() ]],
-}
-
-M.load = function(commands)
- for _, command in ipairs(commands) do
- vim.cmd(command)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/comment.lua b/.config/nvim/lua/core/comment.lua
deleted file mode 100644
index f8d62c2..0000000
--- a/.config/nvim/lua/core/comment.lua
+++ /dev/null
@@ -1,71 +0,0 @@
-local M = {}
-
-function M.config()
- local pre_hook = nil
- if options.builtin.treesitter.context_commentstring.enable then
- pre_hook = function(_ctx)
- return require("ts_context_commentstring.internal").calculate_commentstring()
- end
- end
- options.builtin.comment = {
- active = true,
- on_config_done = nil,
- ---Add a space b/w comment and the line
- ---@type boolean
- padding = true,
-
- ---Lines to be ignored while comment/uncomment.
- ---Could be a regex string or a function that returns a regex string.
- ---Example: Use '^$' to ignore empty lines
- ---@type string|function
- ignore = "^$",
-
- ---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode
- ---@type table
- mappings = {
- ---operator-pending mapping
- ---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}`
- basic = true,
- ---extended mapping
- ---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
- extra = false,
- },
-
- ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode
- ---@type table
- toggler = {
- ---line-comment toggle
- line = "gcc",
- ---block-comment toggle
- block = "gbc",
- },
-
- ---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode
- ---@type table
- opleader = {
- ---line-comment opfunc mapping
- line = "gc",
- ---block-comment opfunc mapping
- block = "gb",
- },
-
- ---Pre-hook, called before commenting the line
- ---@type function|nil
- pre_hook = pre_hook,
-
- ---Post-hook, called after commenting is done
- ---@type function|nil
- post_hook = nil,
- }
-end
-
-function M.setup()
- local nvim_comment = require "Comment"
-
- nvim_comment.setup(options.builtin.comment)
- if options.builtin.comment.on_config_done then
- options.builtin.comment.on_config_done(nvim_comment)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/dashboard.lua b/.config/nvim/lua/core/dashboard.lua
deleted file mode 100644
index 20edd22..0000000
--- a/.config/nvim/lua/core/dashboard.lua
+++ /dev/null
@@ -1,112 +0,0 @@
-local M = {}
-local utils = require "utils"
-
-M.config = function(config)
- options.builtin.dashboard = {
- active = false,
- on_config_done = nil,
- search_handler = "telescope",
- disable_at_vim_enter = 0,
- session_directory = utils.join_paths(get_cache_dir(), "sessions"),
- custom_header = {
- " ##############..... ############## ",
- " ##############......############## ",
- " ##########..........########## ",
- " ##########........########## ",
- " ##########.......########## ",
- " ##########.....##########.. ",
- " ##########....##########..... ",
- " ..##########..##########......... ",
- " ....##########.#########............. ",
- " ..################JJJ............ ",
- " ################............. ",
- " ##############.JJJ.JJJJJJJJJJ ",
- " ############...JJ...JJ..JJ JJ ",
- " ##########....JJ...JJ..JJ JJ ",
- " ########......JJJ..JJJ JJJ JJJ ",
- " ###### ......... ",
- " ..... ",
- " . ",
- },
-
- custom_section = {
- a = {
- description = { " Find File " },
- command = "Telescope find_files",
- },
- b = {
- description = { " New File " },
- command = ":ene!",
- },
- c = {
- description = { " Recent Projects " },
- command = "Telescope projects",
- },
- d = {
- description = { " Recently Used Files" },
- command = "Telescope oldfiles",
- },
- e = {
- description = { " Find Word " },
- command = "Telescope live_grep",
- },
- f = {
- description = { " Configuration " },
- command = ":e " .. config.user_config_file,
- },
- },
- }
-end
-
-M.setup = function()
- vim.g.dashboard_disable_at_vimenter = options.builtin.dashboard.disable_at_vim_enter
-
- vim.g.dashboard_custom_header = options.builtin.dashboard.custom_header
-
- vim.g.dashboard_default_executive = options.builtin.dashboard.search_handler
-
- vim.g.dashboard_custom_section = options.builtin.dashboard.custom_section
-
- options.builtin.which_key.mappings[";"] = { "<cmd>Dashboard<CR>", "Dashboard" }
-
- vim.g.dashboard_session_directory = options.builtin.dashboard.session_directory
-
- local num_plugins_loaded = #vim.fn.globpath(
- get_data_dir() .. "/site/pack/packer/start",
- "*",
- 0,
- 1
- )
-
- local footer = {
- "nvim loaded " .. num_plugins_loaded .. " plugins ",
- "",
- }
-
- local text = require "interface.text"
- vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, footer, 0.49) -- Use 0.49 as  counts for 2 characters
-
- require("core.autocmds").define_augroups {
- _dashboard = {
- -- seems to be nobuflisted that makes my stuff disappear will do more testing
- {
- "FileType",
- "dashboard",
- "setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= ",
- },
- {
- "FileType",
- "dashboard",
- "set showtabline=0 | autocmd BufLeave <buffer> set showtabline="
- .. vim.opt.showtabline._value,
- },
- { "FileType", "dashboard", "nnoremap <silent> <buffer> q :q<CR>" },
- },
- }
-
- if options.builtin.dashboard.on_config_done then
- options.builtin.dashboard.on_config_done()
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/gitsigns.lua b/.config/nvim/lua/core/gitsigns.lua
deleted file mode 100644
index 97f5314..0000000
--- a/.config/nvim/lua/core/gitsigns.lua
+++ /dev/null
@@ -1,61 +0,0 @@
-local M = {}
-local Log = require "core.log"
-
-M.config = function()
- options.builtin.gitsigns = {
- 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",
- },
- },
- numhl = false,
- linehl = false,
- keymaps = {
- -- Default keymap options
- noremap = true,
- buffer = true,
- },
- watch_gitdir = { interval = 1000 },
- sign_priority = 6,
- update_debounce = 200,
- status_formatter = nil, -- Use default
- }
-end
-
-M.setup = function()
- local status_ok, gitsigns = pcall(require, "gitsigns")
- if not status_ok then
- Log:get_default().error "Failed to load gitsigns"
- return
- end
- gitsigns.setup(options.builtin.gitsigns)
-end
-
-return M
diff --git a/.config/nvim/lua/core/info.lua b/.config/nvim/lua/core/info.lua
deleted file mode 100644
index 646cf71..0000000
--- a/.config/nvim/lua/core/info.lua
+++ /dev/null
@@ -1,206 +0,0 @@
-local M = {
- banner = {
- "",
- [[ _ ___ ]],
- [[| | / (_)___ ___ ]],
- [[| | / / / __ `__ \]],
- [[| |/ / / / / / / /]],
- [[|___/_/_/ /_/ /_/ ]],
- },
-}
-
-local fmt = string.format
-local text = require "interface.text"
-local lsp_utils = require "lsp.utils"
-
-local function str_list(list)
- return fmt("[ %s ]", table.concat(list, ", "))
-end
-
-local function make_formatters_info(ft)
- local null_formatters = require "lsp.null-ls.formatters"
- local registered_formatters = null_formatters.list_registered_providers(ft)
- local supported_formatters = null_formatters.list_available(ft)
- local section = {
- "Formatters info",
- fmt(
- "* Active: %s%s",
- table.concat(registered_formatters, "  , "),
- vim.tbl_count(registered_formatters) > 0 and "  " or ""
- ),
- fmt("* Supported: %s", str_list(supported_formatters)),
- }
-
- return section
-end
-
-local function make_code_actions_info(ft)
- local null_actions = require "lsp.null-ls.code_actions"
- local registered_actions = null_actions.list_registered_providers(ft)
- local supported_actions = null_actions.list_available(ft)
- local section = {
- "Code actions info",
- fmt(
- "* Active: %s%s",
- table.concat(registered_actions, "  , "),
- vim.tbl_count(registered_actions) > 0 and "  " or ""
- ),
- fmt("* Supported: %s", str_list(supported_actions)),
- }
-
- return section
-end
-
-local function make_linters_info(ft)
- local null_linters = require "lsp.null-ls.linters"
- local supported_linters = null_linters.list_available(ft)
- local registered_linters = null_linters.list_registered_providers(ft)
- local section = {
- "Linters info",
- fmt(
- "* Active: %s%s",
- table.concat(registered_linters, "  , "),
- vim.tbl_count(registered_linters) > 0 and "  " or ""
- ),
- fmt("* Supported: %s", str_list(supported_linters)),
- }
-
- return section
-end
-
-local function tbl_set_highlight(terms, highlight_group)
- for _, v in pairs(terms) do
- vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. "[ ,│']\")")
- end
-end
-
-local function make_client_info(client)
- local client_enabled_caps = lsp_utils.get_client_capabilities(client.id)
- local name = client.name
- local id = client.id
- local filetypes = lsp_utils.get_supported_filetypes(name)
- local document_formatting = client.resolved_capabilities.document_formatting
- local attached_buffers_list = table.concat(
- vim.lsp.get_buffers_by_client_id(client.id),
- ", "
- )
- local client_info = {
- fmt("* Name: %s", name),
- fmt("* Id: [%s]", tostring(id)),
- fmt("* filetype(s): [%s]", table.concat(filetypes, ", ")),
- fmt("* Attached buffers: [%s]", tostring(attached_buffers_list)),
- fmt("* Supports formatting: %s", tostring(document_formatting)),
- }
- if not vim.tbl_isempty(client_enabled_caps) then
- local caps_text = "* Capabilities list: "
- local caps_text_len = caps_text:len()
- local enabled_caps = text.format_table(client_enabled_caps, 3, " | ")
- enabled_caps = text.shift_right(enabled_caps, caps_text_len)
- enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1))
- vim.list_extend(client_info, enabled_caps)
- end
-
- return client_info
-end
-
-function M.toggle_popup(ft)
- local clients = lsp_utils.get_active_clients_by_ft(ft)
- local client_names = {}
- local bufnr = vim.api.nvim_get_current_buf()
- local ts_active_buffers = vim.tbl_keys(vim.treesitter.highlighter.active)
- local is_treesitter_active = function()
- local status = "inactive"
- if vim.tbl_contains(ts_active_buffers, bufnr) then
- status = "active"
- end
- return status
- end
- local header = {
- fmt("Detected filetype: %s", ft),
- fmt("Current buffer number: [%s]", bufnr),
- }
-
- local ts_info = {
- "Treesitter info",
- fmt("* current buffer: %s", is_treesitter_active()),
- fmt("* list: [%s]", table.concat(ts_active_buffers, ", ")),
- }
-
- local lsp_info = {
- "Language Server Protocol (LSP) info",
- fmt "* Active server(s):",
- }
-
- for _, client in pairs(clients) do
- vim.list_extend(lsp_info, make_client_info(client))
- table.insert(client_names, client.name)
- end
-
- local formatters_info = make_formatters_info(ft)
-
- local linters_info = make_linters_info(ft)
-
- local code_actions_info = make_code_actions_info(ft)
-
- local content_provider = function(popup)
- local content = {}
-
- for _, section in ipairs {
- M.banner,
- { "" },
- { "" },
- header,
- { "" },
- ts_info,
- { "" },
- lsp_info,
- { "" },
- formatters_info,
- { "" },
- linters_info,
- } do
- vim.list_extend(content, section)
- end
-
- return text.align_left(popup, content, 0.5)
- end
-
- local function set_syntax_hl()
- vim.cmd [[highlight NvimInfoIdentifier gui=bold]]
- vim.cmd [[highlight link NvimInfoHeader Type]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Treesitter info")]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Language Server Protocol (LSP) info")]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Formatters info")]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Linters info")]]
- vim.cmd [[let m=matchadd("NvimInfoHeader", "Code actions info")]]
- vim.cmd('let m=matchadd("NvimInfoIdentifier", " ' .. ft .. '$")')
- vim.cmd 'let m=matchadd("string", "true")'
- vim.cmd 'let m=matchadd("string", "active")'
- vim.cmd 'let m=matchadd("boolean", "inactive")'
- vim.cmd 'let m=matchadd("string", "")'
- vim.cmd 'let m=matchadd("error", "false")'
- -- tbl_set_highlight(registered_providers, "NvimInfoIdentifier")
- tbl_set_highlight(
- require("lsp.null-ls.formatters").list_available(ft),
- "NvimInfoIdentifier"
- )
- tbl_set_highlight(
- require("lsp.null-ls.linters").list_available(ft),
- "NvimInfoIdentifier"
- )
- tbl_set_highlight(
- require("lsp.null-ls.code_actions").list_available(ft),
- "NvimInfoIdentifier"
- )
- end
-
- local Popup = require("interface.popup"):new {
- win_opts = { number = false },
- buf_opts = { modifiable = false, filetype = "lspinfo" },
- }
- Popup:display(content_provider)
- set_syntax_hl()
-
- return Popup
-end
-return M
diff --git a/.config/nvim/lua/core/log.lua b/.config/nvim/lua/core/log.lua
deleted file mode 100644
index 815aeb1..0000000
--- a/.config/nvim/lua/core/log.lua
+++ /dev/null
@@ -1,127 +0,0 @@
-local Log = {}
-
-local logfile = string.format("%s/%s.log", get_cache_dir(), "nvim")
-
-Log.levels = {
- TRACE = 1,
- DEBUG = 2,
- INFO = 3,
- WARN = 4,
- ERROR = 5,
-}
-
-vim.tbl_add_reverse_lookup(Log.levels)
-
-function Log:init()
- local status_ok, structlog = pcall(require, "structlog")
- if not status_ok then
- return nil
- end
-
- local log_level = Log.levels[(options.log.level):upper() or "WARN"]
- local nvim_log = {
- nvim = {
- sinks = {
- structlog.sinks.Console(log_level, {
- async = false,
- processors = {
- structlog.processors.Namer(),
- structlog.processors.StackWriter(
- { "line", "file" },
- { max_parents = 0, stack_level = 2 }
- ),
- structlog.processors.Timestamper "%H:%M:%S",
- },
- formatter = structlog.formatters.FormatColorizer( --
- "%s [%-5s] %s: %-30s",
- { "timestamp", "level", "logger_name", "msg" },
- { level = structlog.formatters.FormatColorizer.color_level() }
- ),
- }),
- structlog.sinks.File(Log.levels.TRACE, logfile, {
- processors = {
- structlog.processors.Namer(),
- structlog.processors.StackWriter(
- { "line", "file" },
- { max_parents = 3, stack_level = 2 }
- ),
- structlog.processors.Timestamper "%H:%M:%S",
- },
- formatter = structlog.formatters.Format( --
- "%s [%-5s] %s: %-30s",
- { "timestamp", "level", "logger_name", "msg" }
- ),
- }),
- },
- },
- }
-
- structlog.configure(nvim_log)
-
- local logger = structlog.get_logger "nvim"
-
- return logger
-end
-
---- Adds a log entry using Plenary.log
----@fparam msg any
----@param level string [same as vim.log.log_levels]
-function Log:add_entry(level, msg, event)
- if self.__handle then
- self.__handle:log(level, vim.inspect(msg), event)
- return
- end
-
- local logger = self:init()
- if not logger then
- return
- end
-
- self.__handle = logger
- self.__handle:log(level, vim.inspect(msg), event)
-end
-
----Retrieves the path of the logfile
----@return string path of the logfile
-function Log:get_path()
- return logfile
-end
-
----Add a log entry at TRACE level
----@param msg any
----@param event any
-function Log:trace(msg, event)
- self:add_entry(self.levels.TRACE, msg, event)
-end
-
----Add a log entry at DEBUG level
----@param msg any
----@param event any
-function Log:debug(msg, event)
- self:add_entry(self.levels.DEBUG, msg, event)
-end
-
----Add a log entry at INFO level
----@param msg any
----@param event any
-function Log:info(msg, event)
- self:add_entry(self.levels.INFO, msg, event)
-end
-
----Add a log entry at WARN level
----@param msg any
----@param event any
-function Log:warn(msg, event)
- self:add_entry(self.levels.WARN, msg, event)
-end
-
----Add a log entry at ERROR level
----@param msg any
----@param event any
-function Log:error(msg, event)
- self:add_entry(self.levels.ERROR, msg, event)
-end
-
-setmetatable({}, Log)
-
-return Log
diff --git a/.config/nvim/lua/core/lualine/colors.lua b/.config/nvim/lua/core/lualine/colors.lua
deleted file mode 100644
index f922d3f..0000000
--- a/.config/nvim/lua/core/lualine/colors.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local colors = {
- bg = "#171717",
- fg = "#D0D0D0",
- grey = "#D0D0D0",
- blue = "#569CD6",
- green = "#608B4E",
- yellow = "#DCDCAA",
- orange = "#FF8800",
- purple = "#C586C0",
- magenta = "#D16D9E",
- cyan = "#4EC9B0",
- red = "#D16969",
- error_red = "#F44747",
- warning_orange = "#FF8800",
- info_yellow = "#FFCC66",
- hint_blue = "#9CDCFE",
-}
-
-return colors
diff --git a/.config/nvim/lua/core/lualine/components.lua b/.config/nvim/lua/core/lualine/components.lua
deleted file mode 100644
index 42ec112..0000000
--- a/.config/nvim/lua/core/lualine/components.lua
+++ /dev/null
@@ -1,179 +0,0 @@
-local conditions = require "core.lualine.conditions"
-local colors = require "core.lualine.colors"
-
-local function diff_source()
- local gitsigns = vim.b.gitsigns_status_dict
- if gitsigns then
- return {
- added = gitsigns.added,
- modified = gitsigns.changed,
- removed = gitsigns.removed,
- }
- end
-end
-
-return {
- mode = {
- function()
- local alias = {
- n = "NORMAL",
- i = "INSERT",
- c = "COMMAND",
- V = "VISUAL",
- [""] = "VISUAL",
- v = "VISUAL",
- R = "REPLACE",
- }
- local alias_mode = alias[vim.fn.mode()]
- if alias_mode == nil then
- alias_mode = vim.fn.mode()
- end
- return alias_mode .. " "
- -- return " "
- end,
- padding = { left = 0, right = 0 },
- cond = nil,
- color = { fg = colors.fg, bg = colors.bg },
- },
- branch = {
- "b:gitsigns_head",
- icon = " ",
- color = { gui = "bold", fg = colors.fg, bg = colors.bg },
- cond = conditions.hide_in_width,
- },
- filename = {
- "filename",
- color = { fg = colors.fg, bg = colors.bg },
- cond = nil,
- },
- diff = {
- "diff",
- source = diff_source,
- symbols = { added = "  ", modified = "柳", removed = " " },
- diff_color = {
- added = { fg = colors.green },
- modified = { fg = colors.yellow },
- removed = { fg = colors.red },
- },
- color = {},
- cond = nil,
- },
- python_env = {
- function()
- local utils = require "core.lualine.utils"
- if vim.bo.filetype == "python" then
- local venv = os.getenv "CONDA_DEFAULT_ENV"
- if venv then
- return string.format("  (%s)", utils.env_cleanup(venv))
- end
- venv = os.getenv "VIRTUAL_ENV"
- if venv then
- return string.format("  (%s)", utils.env_cleanup(venv))
- end
- return ""
- end
- return ""
- end,
- color = { fg = colors.green },
- cond = conditions.hide_in_width,
- },
- diagnostics = {
- "diagnostics",
- sources = { "nvim_lsp" },
- symbols = { error = " ", warn = " ", info = " ", hint = " " },
- color = {},
- cond = conditions.hide_in_width,
- },
- treesitter = {
- function()
- local b = vim.api.nvim_get_current_buf()
- if next(vim.treesitter.highlighter.active[b]) then
- return "  "
- end
- return ""
- end,
- color = { fg = colors.green },
- cond = conditions.hide_in_width,
- },
- lsp = {
- function(msg)
- msg = msg or "LS Inactive"
- local buf_clients = vim.lsp.buf_get_clients()
- if next(buf_clients) == nil then
- if type(msg) == "boolean" or #msg == 0 then
- return "LS Inactive"
- end
- return msg
- end
- local buf_ft = vim.bo.filetype
- local buf_client_names = {}
-
- -- add client
- for _, client in pairs(buf_clients) do
- if client.name ~= "null-ls" then
- table.insert(buf_client_names, client.name)
- end
- end
-
- -- add formatter
- local formatters = require "lsp.null-ls.formatters"
- local supported_formatters = formatters.list_registered_providers(buf_ft)
- vim.list_extend(buf_client_names, supported_formatters)
-
- -- add linter
- local linters = require "lsp.null-ls.linters"
- local supported_linters = linters.list_registered_providers(buf_ft)
- vim.list_extend(buf_client_names, supported_linters)
-
- return "[" .. table.concat(buf_client_names, ", ") .. "]"
- end,
- color = { fg = colors.fg, bg = colors.bg },
- cond = conditions.hide_in_width,
- },
- location = { "location", cond = conditions.hide_in_width, color = {} },
- progress = { "progress", cond = conditions.hide_in_width, color = {} },
- spaces = {
- function()
- if not vim.api.nvim_buf_get_option(0, "expandtab") then
- return "Tab size: " .. vim.api.nvim_buf_get_option(0, "tabstop") .. " "
- end
- local size = vim.api.nvim_buf_get_option(0, "shiftwidth")
- if size == 0 then
- size = vim.api.nvim_buf_get_option(0, "tabstop")
- end
- return "Spaces: " .. size .. " "
- end,
- color = {},
- cond = conditions.hide_in_width,
- },
- encoding = {
- "o:encoding",
- fmt = string.upper,
- color = { fg = colors.fg, bg = colors.bg },
- cond = conditions.hide_in_width,
- },
- filetype = { "filetype", cond = conditions.hide_in_width, color = {} },
- scrollbar = {
- function()
- local current_line = vim.fn.line "."
- local total_lines = vim.fn.line "$"
- local chars = {
- "__",
- "▁▁",
- "▂▂",
- "▃▃",
- "▄▄",
- "▅▅",
- "▆▆",
- "▇▇",
- "██",
- }
- local line_ratio = current_line / total_lines
- local index = math.ceil(line_ratio * #chars)
- return chars[index]
- end,
- padding = { left = 0, right = 0 },
- cond = nil,
- color = { fg = colors.yellow, bg = colors.bg },
- },
-}
diff --git a/.config/nvim/lua/core/lualine/conditions.lua b/.config/nvim/lua/core/lualine/conditions.lua
deleted file mode 100644
index 6e120b2..0000000
--- a/.config/nvim/lua/core/lualine/conditions.lua
+++ /dev/null
@@ -1,17 +0,0 @@
-local window_width_limit = 70
-
-local conditions = {
- buffer_not_empty = function()
- return vim.fn.empty(vim.fn.expand "%:t") ~= 1
- end,
- hide_in_width = function()
- return vim.fn.winwidth(0) > window_width_limit
- end,
- -- check_git_workspace = function()
- -- local filepath = vim.fn.expand "%:p:h"
- -- local gitdir = vim.fn.finddir(".git", filepath .. ";")
- -- return gitdir and #gitdir > 0 and #gitdir < #filepath
- -- end,
-}
-
-return conditions
diff --git a/.config/nvim/lua/core/lualine/init.lua b/.config/nvim/lua/core/lualine/init.lua
deleted file mode 100644
index 7d67559..0000000
--- a/.config/nvim/lua/core/lualine/init.lua
+++ /dev/null
@@ -1,47 +0,0 @@
-local M = {}
-M.config = function()
- options.builtin.lualine = {
- active = true,
- style = "options",
- options = {
- icons_enabled = nil,
- component_separators = nil,
- section_separators = nil,
- theme = nil,
- disabled_filetypes = nil,
- },
- sections = {
- lualine_a = nil,
- lualine_b = nil,
- lualine_c = nil,
- lualine_x = nil,
- lualine_y = nil,
- lualine_z = nil,
- },
- inactive_sections = {
- lualine_a = nil,
- lualine_b = nil,
- lualine_c = nil,
- lualine_x = nil,
- lualine_y = nil,
- lualine_z = nil,
- },
- tabline = nil,
- extensions = nil,
- on_config_done = nil,
- }
-end
-
-M.setup = function()
- require("core.lualine.styles").update()
- require("core.lualine.utils").validate_theme()
-
- local lualine = require "lualine"
- lualine.setup(options.builtin.lualine)
-
- if options.builtin.lualine.on_config_done then
- options.builtin.lualine.on_config_done(lualine)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/lualine/styles.lua b/.config/nvim/lua/core/lualine/styles.lua
deleted file mode 100644
index 8caf349..0000000
--- a/.config/nvim/lua/core/lualine/styles.lua
+++ /dev/null
@@ -1,185 +0,0 @@
-local M = {}
-local components = require "core.lualine.components"
-
-local styles = {
- lvim = nil,
- default = nil,
- none = nil,
- dark = nil,
-}
-
-styles.dark = {
- style = "dark",
- options = {
- icons_enabled = true,
- component_separators = { left = "", right = "" },
- section_separators = { left = "", right = "" },
- disabled_filetypes = { "dashboard", "NvimTree", "Outline" },
- },
- sections = {
- lualine_a = {
- components.mode,
- },
- lualine_b = {
- components.branch,
- components.filename,
- },
- lualine_c = {
- components.diff,
- components.python_env,
- },
- lualine_x = {
- components.diagnostics,
- components.treesitter,
- components.lsp,
- components.filetype,
- },
- lualine_y = {},
- lualine_z = {
- components.location,
- components.progress,
- components.encoding,
- },
- },
- inactive_sections = {
- lualine_a = {
- "filename",
- },
- lualine_b = {},
- lualine_c = {},
- lualine_x = {},
- lualine_y = {},
- lualine_z = {},
- },
- tabline = {},
- extensions = { "nvim-tree" },
-}
-
-styles.none = {
- style = "none",
- options = {
- icons_enabled = true,
- component_separators = { left = "", right = "" },
- section_separators = { left = "", right = "" },
- disabled_filetypes = {},
- },
- sections = {
- lualine_a = {},
- lualine_b = {},
- lualine_c = {},
- lualine_x = {},
- lualine_y = {},
- lualine_z = {},
- },
- inactive_sections = {
- lualine_a = {},
- lualine_b = {},
- lualine_c = {},
- lualine_x = {},
- lualine_y = {},
- lualine_z = {},
- },
- tabline = {},
- extensions = {},
-}
-
-styles.default = {
- style = "default",
- options = {
- icons_enabled = true,
- component_separators = { "", "" },
- section_separators = { "", "" },
- disabled_filetypes = {},
- },
- sections = {
- lualine_a = { "mode" },
- lualine_b = { "branch" },
- 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 = {},
- extensions = {},
-}
-
-styles.lvim = {
- style = "lvim",
- options = {
- icons_enabled = true,
- component_separators = { left = "", right = "" },
- section_separators = { left = "", right = "" },
- disabled_filetypes = { "dashboard" },
- },
- sections = {
- lualine_a = {
- components.mode,
- },
- lualine_b = {
- components.branch,
- components.filename,
- },
- lualine_c = {
- components.diff,
- components.python_env,
- },
- lualine_x = {
- components.diagnostics,
- components.treesitter,
- components.lsp,
- components.filetype,
- },
- lualine_y = {},
- lualine_z = {
- components.scrollbar,
- },
- },
- inactive_sections = {
- lualine_a = {
- "filename",
- },
- lualine_b = {},
- lualine_c = {},
- lualine_x = {},
- lualine_y = {},
- lualine_z = {},
- },
- tabline = {},
- extensions = { "nvim-tree" },
-}
-
-function M.get_style(style)
- local style_keys = vim.tbl_keys(styles)
- if not vim.tbl_contains(style_keys, style) then
- local Log = require "core.log"
- Log:error(
- "Invalid lualine style",
- string.format('"%s"', style),
- "options are: ",
- string.format('"%s"', table.concat(style_keys, '", "'))
- )
- Log:debug '"lvim" style is applied.'
- style = "lvim"
- end
-
- return vim.deepcopy(styles[style])
-end
-
-function M.update()
- local style = M.get_style(options.builtin.lualine.style)
- if options.builtin.lualine.options.theme == nil then
- options.builtin.lualine.options.theme = options.colorscheme
- end
-
- options.builtin.lualine = vim.tbl_deep_extend("keep", options.builtin.lualine, style)
-end
-
-return M
diff --git a/.config/nvim/lua/core/lualine/utils.lua b/.config/nvim/lua/core/lualine/utils.lua
deleted file mode 100644
index 48756a7..0000000
--- a/.config/nvim/lua/core/lualine/utils.lua
+++ /dev/null
@@ -1,27 +0,0 @@
-local M = {}
-
-function M.validate_theme()
- local theme = options.builtin.lualine.options.theme
- if type(theme) == "table" then
- return
- end
-
- local lualine_loader = require "lualine.utils.loader"
- local ok = pcall(lualine_loader.load_theme, theme)
- if not ok then
- options.builtin.lualine.options.theme = "auto"
- end
-end
-
-function M.env_cleanup(venv)
- if string.find(venv, "/") then
- local final_venv = venv
- for w in venv:gmatch "([^/]+)" do
- final_venv = w
- end
- venv = final_venv
- end
- return venv
-end
-
-return M
diff --git a/.config/nvim/lua/core/nvimtree.lua b/.config/nvim/lua/core/nvimtree.lua
deleted file mode 100644
index b525351..0000000
--- a/.config/nvim/lua/core/nvimtree.lua
+++ /dev/null
@@ -1,175 +0,0 @@
-local M = {}
-local Log = require "core.log"
-
-function M.config()
- options.builtin.nvimtree = {
- active = true,
- on_config_done = nil,
- setup = {
- disable_netrw = true,
- hijack_netrw = true,
- open_on_setup = false,
- ignore_ft_on_setup = {
- "startify",
- "dashboard",
- "alpha",
- },
- update_to_buf_dir = {
- enable = true,
- auto_open = true,
- },
- auto_close = true,
- open_on_tab = false,
- hijack_cursor = false,
- update_cwd = false,
- diagnostics = {
- enable = true,
- icons = {
- hint = "",
- info = "",
- warning = "",
- error = "",
- },
- },
- update_focused_file = {
- enable = true,
- update_cwd = true,
- ignore_list = {},
- },
- system_open = {
- cmd = nil,
- args = {},
- },
- git = {
- enable = true,
- ignore = true,
- timeout = 200,
- },
- view = {
- width = 30,
- height = 30,
- side = "left",
- auto_resize = true,
- number = false,
- relativenumber = false,
- mappings = {
- custom_only = false,
- list = {},
- },
- },
- filters = {
- dotfiles = true,
- custom = { ".git", "node_modules", ".cache" },
- },
- },
- show_icons = {
- git = 1,
- folders = 1,
- files = 1,
- folder_arrows = 1,
- tree_width = 30,
- },
- quit_on_open = 0,
- git_hl = 1,
- disable_window_picker = 0,
- root_folder_modifier = ":t",
- icons = {
- default = "",
- symlink = "",
- git = {
- unstaged = "",
- staged = "S",
- unmerged = "",
- renamed = "➜",
- deleted = "",
- untracked = "U",
- ignored = "◌",
- },
- folder = {
- default = "",
- open = "",
- empty = "",
- empty_open = "",
- symlink = "",
- },
- },
- }
- options.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }
-end
-
-function M.setup()
- local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
- if not status_ok then
- Log:error "Failed to load nvim-tree.config"
- return
- end
- local g = vim.g
-
- for opt, val in pairs(options.builtin.nvimtree) do
- g["nvim_tree_" .. opt] = val
- end
-
- -- Implicitly update nvim-tree when project module is active
- if options.builtin.project.active then
- options.builtin.nvimtree.respect_buf_cwd = 1
- options.builtin.nvimtree.setup.update_cwd = true
- options.builtin.nvimtree.setup.disable_netrw = false
- options.builtin.nvimtree.setup.hijack_netrw = false
- vim.g.netrw_banner = false
- end
-
- local tree_cb = nvim_tree_config.nvim_tree_callback
-
- if not options.builtin.nvimtree.setup.view.mappings.list then
- options.builtin.nvimtree.setup.view.mappings.list = {
- { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
- { key = "h", cb = tree_cb "close_node" },
- { key = "v", cb = tree_cb "vsplit" },
- }
- end
-
- local tree_view = require "nvim-tree.view"
-
- -- Add nvim_tree open callback
- local open = tree_view.open
- tree_view.open = function()
- M.on_open()
- open()
- end
-
- vim.cmd "au WinClosed * lua require('core.nvimtree').on_close()"
-
- if options.builtin.nvimtree.on_config_done then
- options.builtin.nvimtree.on_config_done(nvim_tree_config)
- end
- require("nvim-tree").setup(options.builtin.nvimtree.setup)
-end
-
-function M.on_open()
- if
- package.loaded["bufferline.state"]
- and options.builtin.nvimtree.setup.view.side == "left"
- then
- require("bufferline.state").set_offset(
- options.builtin.nvimtree.setup.view.width + 1,
- ""
- )
- end
-end
-
-function M.on_close()
- local buf = tonumber(vim.fn.expand "<abuf>")
- local ft = vim.api.nvim_buf_get_option(buf, "filetype")
- if ft == "NvimTree" and package.loaded["bufferline.state"] then
- require("bufferline.state").set_offset(0)
- end
-end
-
-function M.change_tree_dir(dir)
- local lib_status_ok, lib = pcall(require, "nvim-tree.lib")
- if lib_status_ok then
- lib.change_dir(dir)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/project.lua b/.config/nvim/lua/core/project.lua
deleted file mode 100644
index b2d4f5f..0000000
--- a/.config/nvim/lua/core/project.lua
+++ /dev/null
@@ -1,51 +0,0 @@
-local M = {}
-
-function M.config()
- options.builtin.project = {
- ---@usage set to false to disable project.nvim.
- --- This is on by default since it's currently the expected behavior.
- active = true,
-
- on_config_done = nil,
-
- ---@usage set to true to disable setting the current-woriking directory
- --- Manual mode doesn't automatically change your root directory, so you have
- --- the option to manually do so using `:ProjectRoot` command.
- manual_mode = false,
-
- ---@usage Methods of detecting the root directory
- --- Allowed values: **"lsp"** uses the native neovim lsp
- --- **"pattern"** uses vim-rooter like glob pattern matching. Here
- --- order matters: if one is not detected, the other is used as fallback. You
- --- can also delete or rearangne the detection methods.
- detection_methods = { "lsp", "pattern" },
-
- ---@usage patterns used to detect root dir, when **"pattern"** is in detection_methods
- patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" },
-
- ---@ Show hidden files in telescope when searching for files in a project
- show_hidden = false,
-
- ---@usage When set to false, you will get a message when project.nvim changes your directory.
- -- When set to false, you will get a message when project.nvim changes your directory.
- silent_chdir = true,
-
- ---@usage list of lsp client names to ignore when using **lsp** detection. eg: { "efm", ... }
- ignore_lsp = {},
-
- ---@type string
- ---@usage path to store the project history for use in telescope
- datapath = get_cache_dir(),
- }
-end
-
-function M.setup()
- local project = require "project_nvim"
-
- project.setup(options.builtin.project)
- if options.builtin.project.on_config_done then
- options.builtin.project.on_config_done(project)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/telescope.lua b/.config/nvim/lua/core/telescope.lua
deleted file mode 100644
index 7ef2e58..0000000
--- a/.config/nvim/lua/core/telescope.lua
+++ /dev/null
@@ -1,159 +0,0 @@
-local M = {}
-
-function M.config()
- -- Define this minimal config so that it's available if telescope is not yet available.
- options.builtin.telescope = {
- ---@usage disable telescope completely [not recommeded]
- active = true,
- on_config_done = nil,
- }
-
- local status_ok, actions = pcall(require, "telescope.actions")
- if not status_ok then
- return
- end
-
- options.builtin.telescope = vim.tbl_extend("force", options.builtin.telescope, {
- defaults = {
- prompt_prefix = " ",
- selection_caret = " ",
- entry_prefix = " ",
- initial_mode = "insert",
- selection_strategy = "reset",
- sorting_strategy = "ascending",
- layout_strategy = "horizontal",
- layout_config = {
- width = 0.75,
- prompt_position = "top",
- preview_cutoff = 120,
- horizontal = { mirror = false },
- vertical = { mirror = false },
- },
- vimgrep_arguments = {
- "rg",
- "--color=never",
- "--no-heading",
- "--with-filename",
- "--line-number",
- "--column",
- "--smart-case",
- "--hidden",
- },
- mappings = {
- i = {
- ["<C-n>"] = actions.move_selection_next,
- ["<C-p>"] = actions.move_selection_previous,
- ["<C-c>"] = actions.close,
- ["<C-j>"] = actions.cycle_history_next,
- ["<C-k>"] = actions.cycle_history_prev,
- ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
- ["<CR>"] = actions.select_default + actions.center,
- },
- n = {
- ["<C-n>"] = actions.move_selection_next,
- ["<C-p>"] = actions.move_selection_previous,
- ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
- },
- },
- file_ignore_patterns = {},
- path_display = { shorten = 5 },
- winblend = 0,
- border = {},
- borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
- color_devicons = true,
- set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
- pickers = {
- find_files = {
- find_command = { "fd", "--type=file", "--hidden", "--smart-case" },
- },
- live_grep = {
- --@usage don't include the filename in the search results
- only_sort_text = true,
- },
- },
- },
- 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"
- },
- },
- })
-end
-
-function M.code_actions()
- local opts = {
- winblend = 15,
- layout_config = {
- prompt_position = "top",
- width = 80,
- height = 12,
- },
- borderchars = {
- prompt = { "─", "│", " ", "│", "╭", "╮", "│", "│" },
- results = { "─", "│", "─", "│", "├", "┤", "╯", "╰" },
- preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
- },
- border = {},
- previewer = false,
- shorten_path = false,
- }
- require("telescope.builtin").lsp_code_actions(
- require("telescope.themes").get_dropdown(opts)
- )
-end
-
-function M.setup()
- local previewers = require "telescope.previewers"
- local sorters = require "telescope.sorters"
- local actions = require "telescope.actions"
-
- options.builtin.telescope = vim.tbl_extend("keep", {
- file_previewer = previewers.vim_buffer_cat.new,
- grep_previewer = previewers.vim_buffer_vimgrep.new,
- qflist_previewer = previewers.vim_buffer_qflist.new,
- file_sorter = sorters.get_fuzzy_file,
- generic_sorter = sorters.get_generic_fuzzy_sorter,
- ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults.
- mappings = {
- i = {
- ["<C-n>"] = actions.move_selection_next,
- ["<C-p>"] = actions.move_selection_previous,
- ["<C-c>"] = actions.close,
- ["<C-j>"] = actions.cycle_history_next,
- ["<C-k>"] = actions.cycle_history_prev,
- ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
- ["<CR>"] = actions.select_default + actions.center,
- },
- n = {
- ["<C-n>"] = actions.move_selection_next,
- ["<C-p>"] = actions.move_selection_previous,
- ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
- },
- },
- }, options.builtin.telescope)
-
- local telescope = require "telescope"
-
- telescope.setup(options.builtin.telescope)
-
- if options.builtin.project.active then
- pcall(function()
- require("telescope").load_extension "projects"
- end)
- end
-
- if options.builtin.telescope.on_config_done then
- options.builtin.telescope.on_config_done(telescope)
- end
-
- if
- options.builtin.telescope.extensions and options.builtin.telescope.extensions.fzf
- then
- require("telescope").load_extension "fzf"
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/terminal.lua b/.config/nvim/lua/core/terminal.lua
deleted file mode 100644
index 1a7b0bc..0000000
--- a/.config/nvim/lua/core/terminal.lua
+++ /dev/null
@@ -1,118 +0,0 @@
-local M = {}
-local Log = require "core.log"
-
-M.config = function()
- options.builtin["terminal"] = {
- on_config_done = nil,
- -- size can be a number or function which is passed the current terminal
- size = 20,
- -- open_mapping = [[<c-\>]],
- open_mapping = [[<c-t>]],
- hide_numbers = true, -- hide the number column in toggleterm buffers
- shade_filetypes = {},
- shade_terminals = true,
- shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
- start_in_insert = true,
- insert_mappings = true, -- whether or not the open mapping applies in insert mode
- persist_size = false,
- -- direction = 'vertical' | 'horizontal' | 'window' | 'float',
- direction = "float",
- close_on_exit = true, -- close the terminal window when the process exits
- shell = vim.o.shell, -- change the default shell
- -- This field is only relevant if direction is set to 'float'
- float_opts = {
- -- The border key is *almost* the same as 'nvim_win_open'
- -- see :h nvim_win_open for details on borders however
- -- the 'curved' border is a custom border type
- -- not natively supported but implemented in this plugin.
- -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
- border = "curved",
- -- width = <value>,
- -- height = <value>,
- winblend = 0,
- highlights = {
- border = "Normal",
- background = "Normal",
- },
- },
- -- Add executables on the config.lua
- -- { exec, keymap, name}
- -- options.builtin.terminal.execs = {{}} to overwrite
- -- options.builtin.terminal.execs[#options.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"}
- execs = {
- { "lazygit", "gg", "LazyGit" },
- },
- }
-end
-
-M.setup = function()
- local terminal = require "toggleterm"
- for _, exec in pairs(options.builtin.terminal.execs) do
- require("core.terminal").add_exec(exec[1], exec[2], exec[3])
- end
- terminal.setup(options.builtin.terminal)
-
- if options.builtin.terminal.on_config_done then
- options.builtin.terminal.on_config_done(terminal)
- end
-end
-
-M.add_exec = function(exec, keymap, name)
- vim.api.nvim_set_keymap(
- "n",
- "<leader>" .. keymap,
- "<cmd>lua require('core.terminal')._exec_toggle('" .. exec .. "')<CR>",
- { noremap = true, silent = true }
- )
- options.builtin.which_key.mappings[keymap] = name
-end
-
-M._split = function(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t = {}
- for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
- table.insert(t, str)
- end
- return t
-end
-
-M._exec_toggle = function(exec)
- local binary = M._split(exec)[1]
- if vim.fn.executable(binary) ~= 1 then
- Log:error(
- "Unable to run executable "
- .. binary
- .. ". Please make sure it is installed properly."
- )
- return
- end
- local Terminal = require("toggleterm.terminal").Terminal
- local exec_term = Terminal:new { cmd = exec, hidden = true }
- exec_term:toggle()
-end
-
----Toggles a log viewer according to log.viewer.layout_config
----@param logfile string the fullpath to the logfile
-M.toggle_log_view = function(logfile)
- local log_viewer = options.log.viewer.cmd
- if vim.fn.executable(log_viewer) ~= 1 then
- log_viewer = "less +F"
- end
- log_viewer = log_viewer .. " " .. logfile
- local term_opts = vim.tbl_deep_extend("force", options.builtin.terminal, {
- cmd = log_viewer,
- open_mapping = options.log.viewer.layout_config.open_mapping,
- direction = options.log.viewer.layout_config.direction,
- -- TODO: this might not be working as expected
- size = options.log.viewer.layout_config.size,
- float_opts = options.log.viewer.layout_config.float_opts,
- })
-
- local Terminal = require("toggleterm.terminal").Terminal
- local log_view = Terminal:new(term_opts)
- log_view:toggle()
-end
-
-return M
diff --git a/.config/nvim/lua/core/treesitter.lua b/.config/nvim/lua/core/treesitter.lua
deleted file mode 100644
index b56c245..0000000
--- a/.config/nvim/lua/core/treesitter.lua
+++ /dev/null
@@ -1,94 +0,0 @@
-local M = {}
-local Log = require "core.log"
-
-M.config = function()
- options.builtin.treesitter = {
- on_config_done = nil,
- ensure_installed = {}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
- ignore_install = {},
- matchup = {
- enable = false, -- mandatory, false will disable the whole extension
- -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled
- },
- highlight = {
- enable = true, -- false will disable the whole extension
- additional_vim_regex_highlighting = true,
- disable = { "latex" },
- },
- context_commentstring = {
- enable = true,
- config = {
- -- Languages that have a single comment style
- typescript = "// %s",
- css = "/* %s */",
- scss = "/* %s */",
- html = "<!-- %s -->",
- svelte = "<!-- %s -->",
- vue = "<!-- %s -->",
- json = "",
- },
- },
- -- indent = {enable = true, disable = {"python", "html", "javascript"}},
- -- TODO seems to be broken
- indent = { enable = true, disable = { "yaml" } },
- autotag = { enable = false },
- textobjects = {
- swap = {
- enable = false,
- -- swap_next = textobj_swap_keymaps,
- },
- -- move = textobj_move_keymaps,
- select = {
- enable = false,
- -- keymaps = textobj_sel_keymaps,
- },
- },
- textsubjects = {
- enable = false,
- keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" },
- },
- playground = {
- enable = false,
- disable = {},
- updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
- persist_queries = false, -- 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 = "<cr>",
- show_help = "?",
- },
- },
- rainbow = {
- enable = false,
- extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
- max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int
- },
- }
-end
-
-M.setup = function()
- local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")
- if not status_ok then
- Log:get_default().error "Failed to load nvim-treesitter.configs"
- return
- end
-
- local opts = vim.deepcopy(options.builtin.treesitter)
-
- -- avoid running any installers in headless mode since it's harder to detect failures
- opts.ensure_installed = #vim.api.nvim_list_uis() == 0 and {} or opts.ensure_installed
- treesitter_configs.setup(opts)
-
- if options.builtin.treesitter.on_config_done then
- options.builtin.treesitter.on_config_done(treesitter_configs)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/core/which-key.lua b/.config/nvim/lua/core/which-key.lua
deleted file mode 100644
index 333ce6d..0000000
--- a/.config/nvim/lua/core/which-key.lua
+++ /dev/null
@@ -1,283 +0,0 @@
-local M = {}
-
-M.config = function()
- options.builtin.which_key = {
- ---@usage disable which-key completely [not recommeded]
- active = true,
- on_config_done = nil,
- setup = {
- plugins = {
- marks = true, -- shows a list of your marks on ' and `
- registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
- -- the presets plugin, adds help for a bunch of default keybindings in Neovim
- -- No actual key bindings are created
- presets = {
- operators = false, -- adds help for operators like d, y, ...
- motions = false, -- adds help for motions
- text_objects = false, -- help for text objects triggered after entering an operator
- windows = true, -- default bindings on <c-w>
- nav = true, -- misc bindings to work with windows
- z = true, -- bindings for folds, spelling and others prefixed with z
- g = true, -- bindings for prefixed with g
- },
- spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints
- },
- 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
- },
- window = {
- border = "single", -- none, single, double, shadow
- position = "bottom", -- bottom, top
- margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
- padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
- },
- layout = {
- height = { min = 4, max = 25 }, -- min and max height of the columns
- width = { min = 20, max = 50 }, -- min and max width of the columns
- spacing = 3, -- spacing between columns
- },
- hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
- show_help = true, -- show help message on the command line when the popup is visible
- },
-
- opts = {
- mode = "n", -- NORMAL mode
- prefix = "<leader>",
- buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
- silent = true, -- use `silent` when creating keymaps
- noremap = true, -- use `noremap` when creating keymaps
- nowait = true, -- use `nowait` when creating keymaps
- },
- vopts = {
- mode = "v", -- VISUAL mode
- prefix = "<leader>",
- buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
- silent = true, -- use `silent` when creating keymaps
- noremap = true, -- use `noremap` when creating keymaps
- nowait = true, -- use `nowait` when creating keymaps
- },
- -- NOTE: Prefer using : over <cmd> as the latter avoids going back in normal-mode.
- -- see https://neovim.io/doc/user/map.html#:map-cmd
- vmappings = {
- ["k"] = {
- "<ESC><CMD>lua require('Comment.api').gc(vim.fn.visualmode())<CR>",
- "Comment",
- },
- },
- mappings = {
- ["w"] = { "<cmd>w!<CR>", "Save" },
- ["q"] = { "<cmd>q!<CR>", "Quit" },
- ["k"] = { "<cmd>lua require('Comment').toggle()<CR>", "Comment" },
- ["c"] = { "<cmd>BufferClose!<CR>", "Close Buffer" },
- ["f"] = { "<cmd>Telescope find_files<CR>", "Find File" },
- ["n"] = { "<cmd>nohlsearch<CR>", "No Highlight" },
- b = {
- name = "Buffers",
- j = { "<cmd>BufferPick<cr>", "Jump" },
- f = { "<cmd>Telescope buffers<cr>", "Find" },
- b = { "<cmd>b#<cr>", "Previous" },
- w = { "<cmd>BufferWipeout<cr>", "Wipeout" },
- e = {
- "<cmd>BufferCloseAllButCurrent<cr>",
- "Close all but current",
- },
- h = { "<cmd>BufferCloseBuffersLeft<cr>", "Close all to the left" },
- l = {
- "<cmd>BufferCloseBuffersRight<cr>",
- "Close all to the right",
- },
- D = {
- "<cmd>BufferOrderByDirectory<cr>",
- "Sort by directory",
- },
- L = {
- "<cmd>BufferOrderByLanguage<cr>",
- "Sort by language",
- },
- },
- p = {
- name = "Packer",
- c = { "<cmd>PackerCompile<cr>", "Compile" },
- i = { "<cmd>PackerInstall<cr>", "Install" },
- r = { "<cmd>lua require('plugin-loader').recompile()<cr>", "Re-compile" },
- s = { "<cmd>PackerSync<cr>", "Sync" },
- S = { "<cmd>PackerStatus<cr>", "Status" },
- u = { "<cmd>PackerUpdate<cr>", "Update" },
- },
-
- -- " Available Debug Adapters:
- -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/
- -- " Adapter configuration and installation instructions:
- -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
- -- " Debug Adapter protocol:
- -- " https://microsoft.github.io/debug-adapter-protocol/
- -- " Debugging
- g = {
- name = "Git",
- j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" },
- k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" },
- l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
- p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
- r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
- R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
- s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
- u = {
- "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
- "Undo Stage Hunk",
- },
- o = { "<cmd>Telescope git_status<cr>", "Open changed file" },
- b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
- c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" },
- C = {
- "<cmd>Telescope git_bcommits<cr>",
- "Checkout commit(for current file)",
- },
- d = {
- "<cmd>Gitsigns diffthis HEAD<cr>",
- "Git Diff",
- },
- },
-
- l = {
- name = "LSP",
- a = {
- "<cmd>lua require('core.telescope').code_actions()<cr>",
- "Code Action",
- },
- d = {
- "<cmd>Telescope lsp_document_diagnostics<cr>",
- "Document Diagnostics",
- },
- w = {
- "<cmd>Telescope lsp_workspace_diagnostics<cr>",
- "Workspace Diagnostics",
- },
- f = { "<cmd>lua vim.lsp.buf.formatting()<cr>", "Format" },
- i = { "<cmd>LspInfo<cr>", "Info" },
- I = { "<cmd>LspInstallInfo<cr>", "Installer Info" },
- j = {
- "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lsp.popup_border}})<cr>",
- "Next Diagnostic",
- },
- k = {
- "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lsp.popup_border}})<cr>",
- "Prev Diagnostic",
- },
- l = { "<cmd>lua vim.lsp.codelens.run()<cr>", "CodeLens Action" },
- p = {
- name = "Peek",
- d = { "<cmd>lua require('lsp.peek').Peek('definition')<cr>", "Definition" },
- t = {
- "<cmd>lua require('lsp.peek').Peek('typeDefinition')<cr>",
- "Type Definition",
- },
- i = {
- "<cmd>lua require('lsp.peek').Peek('implementation')<cr>",
- "Implementation",
- },
- },
- q = { "<cmd>lua vim.lsp.diagnostic.set_loclist()<cr>", "Quickfix" },
- r = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" },
- s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },
- S = {
- "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>",
- "Workspace Symbols",
- },
- },
- L = {
- name = "+NeoVim",
- c = {
- "<cmd>edit " .. get_config_dir() .. "/config.lua<cr>",
- "Edit config.lua",
- },
- k = { "<cmd>Telescope keymaps<cr>", "View NeoVim's keymappings" },
- i = {
- "<cmd>lua require('core.info').toggle_popup(vim.bo.filetype)<cr>",
- "Toggle NeoVim Info",
- },
- I = {
- "<cmd>lua require('core.telescope.custom-finders').view_lunarvim_changelog()<cr>",
- "View NeoVim's changelog",
- },
- l = {
- name = "+logs",
- d = {
- "<cmd>lua require('core.terminal').toggle_log_view(require('core.log').get_path())<cr>",
- "view default log",
- },
- D = {
- "<cmd>lua vim.fn.execute('edit ' .. require('core.log').get_path())<cr>",
- "Open the default logfile",
- },
- l = {
- "<cmd>lua require('core.terminal').toggle_log_view(vim.lsp.get_log_path())<cr>",
- "view lsp log",
- },
- L = {
- "<cmd>lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())<cr>",
- "Open the LSP logfile",
- },
- n = {
- "<cmd>lua require('core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))<cr>",
- "view neovim log",
- },
- N = { "<cmd>edit $NVIM_LOG_FILE<cr>", "Open the Neovim logfile" },
- p = {
- "<cmd>lua require('core.terminal').toggle_log_view('packer.nvim')<cr>",
- "view packer log",
- },
- P = {
- "<cmd>exe 'edit '.stdpath('cache').'/packer.nvim.log'<cr>",
- "Open the Packer logfile",
- },
- },
- r = { "<cmd>NvimReload<cr>", "Reload Neovim's configuration" },
- u = { "<cmd>NvimUpdate<cr>", "Update NeoVim" },
- },
- s = {
- name = "Search",
- b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
- c = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" },
- f = { "<cmd>Telescope find_files<cr>", "Find File" },
- h = { "<cmd>Telescope help_tags<cr>", "Find Help" },
- M = { "<cmd>Telescope man_pages<cr>", "Man Pages" },
- r = { "<cmd>Telescope oldfiles<cr>", "Open Recent File" },
- R = { "<cmd>Telescope registers<cr>", "Registers" },
- t = { "<cmd>Telescope live_grep<cr>", "Text" },
- k = { "<cmd>Telescope keymaps<cr>", "Keymaps" },
- C = { "<cmd>Telescope commands<cr>", "Commands" },
- p = {
- "<cmd>lua require('telescope.builtin.internal').colorscheme({enable_preview = true})<cr>",
- "Colorscheme with Preview",
- },
- },
- T = {
- name = "Treesitter",
- i = { ":TSConfigInfo<cr>", "Info" },
- },
- },
- }
-end
-
-M.setup = function()
- local which_key = require "which-key"
-
- which_key.setup(options.builtin.which_key.setup)
-
- local opts = options.builtin.which_key.opts
- local vopts = options.builtin.which_key.vopts
-
- local mappings = options.builtin.which_key.mappings
- local vmappings = options.builtin.which_key.vmappings
-
- which_key.register(mappings, opts)
- which_key.register(vmappings, vopts)
-
- if options.builtin.which_key.on_config_done then
- options.builtin.which_key.on_config_done(which_key)
- end
-end
-
-return M