diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-22 00:08:36 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-22 00:08:36 +0200 |
commit | b51f1ae28924a752258e7607fbc3210f9b18eaac (patch) | |
tree | 8c8c095528990b3f6eb499dbcca15e9720e636d1 /.config/nvim/lua/core | |
parent | da936b0ed9ac4c171d3c7908e41af1875a82b08b (diff) |
Updates based on Chris's lunarvim
Diffstat (limited to '.config/nvim/lua/core')
-rw-r--r-- | .config/nvim/lua/core/autopairs.lua | 51 | ||||
-rw-r--r-- | .config/nvim/lua/core/bufferline.lua | 28 | ||||
-rw-r--r-- | .config/nvim/lua/core/colorizer.lua | 17 | ||||
-rw-r--r-- | .config/nvim/lua/core/compe.lua | 96 | ||||
-rw-r--r-- | .config/nvim/lua/core/dap.lua | 41 | ||||
-rw-r--r-- | .config/nvim/lua/core/dashboard.lua | 98 | ||||
-rw-r--r-- | .config/nvim/lua/core/formatter.lua | 60 | ||||
-rw-r--r-- | .config/nvim/lua/core/galaxyline.lua | 315 | ||||
-rw-r--r-- | .config/nvim/lua/core/gitsigns.lua | 59 | ||||
-rw-r--r-- | .config/nvim/lua/core/hop.lua | 20 | ||||
-rw-r--r-- | .config/nvim/lua/core/linter.lua | 33 | ||||
-rw-r--r-- | .config/nvim/lua/core/nvimtree.lua | 88 | ||||
-rw-r--r-- | .config/nvim/lua/core/status_colors.lua | 19 | ||||
-rw-r--r-- | .config/nvim/lua/core/telescope.lua | 97 | ||||
-rw-r--r-- | .config/nvim/lua/core/terminal.lua | 68 | ||||
-rw-r--r-- | .config/nvim/lua/core/treesitter.lua | 187 | ||||
-rw-r--r-- | .config/nvim/lua/core/which-key.lua | 201 | ||||
-rw-r--r-- | .config/nvim/lua/core/zen.lua | 34 |
18 files changed, 1512 insertions, 0 deletions
diff --git a/.config/nvim/lua/core/autopairs.lua b/.config/nvim/lua/core/autopairs.lua new file mode 100644 index 0000000..f0111db --- /dev/null +++ b/.config/nvim/lua/core/autopairs.lua @@ -0,0 +1,51 @@ +-- if not package.loaded['nvim-autopairs'] then +-- return +-- end +local status_ok, _ = pcall(require, "nvim-autopairs") +if not status_ok then + return +end +local npairs = require "nvim-autopairs" +local Rule = require "nvim-autopairs.rule" + +-- skip it, if you use another global object +_G.MUtils = {} + +vim.g.completion_confirm_key = "" +MUtils.completion_confirm = function() + if vim.fn.pumvisible() ~= 0 then + if vim.fn.complete_info()["selected"] ~= -1 then + return vim.fn["compe#confirm"](npairs.esc "<cr>") + else + return npairs.esc "<cr>" + end + else + return npairs.autopairs_cr() + end +end + +if package.loaded["compe"] then + require("nvim-autopairs.completion.compe").setup { + map_cr = true, -- map <CR> on insert mode + map_complete = true, -- it will auto insert `(` after select function or method item + } +end + +npairs.setup { + check_ts = true, + ts_config = { + lua = { "string" }, -- it will not add pair on that treesitter node + javascript = { "template_string" }, + java = false, -- don't check treesitter on java + }, +} + +require("nvim-treesitter.configs").setup { autopairs = { enable = true } } + +local ts_conds = require "nvim-autopairs.ts-conds" + +-- press % => %% is only inside comment or string +npairs.add_rules { + Rule("%", "%", "lua"):with_pair(ts_conds.is_ts_node { "string", "comment" }), + Rule("$", "$", "lua"):with_pair(ts_conds.is_not_ts_node { "function" }), +} diff --git a/.config/nvim/lua/core/bufferline.lua b/.config/nvim/lua/core/bufferline.lua new file mode 100644 index 0000000..d4e4b4f --- /dev/null +++ b/.config/nvim/lua/core/bufferline.lua @@ -0,0 +1,28 @@ +vim.api.nvim_set_keymap("n", "<S-x>", ":BufferClose<CR>", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "<S-l>", ":BufferNext<CR>", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "<S-h>", ":BufferPrevious<CR>", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", { noremap = true, silent = true }) + +O.plugin.which_key.mappings["b"] = { + name = "Buffers", + j = { "<cmd>BufferPick<cr>", "jump to buffer" }, + f = { "<cmd>Telescope buffers<cr>", "Find buffer" }, + w = { "<cmd>BufferWipeout<cr>", "wipeout buffer" }, + e = { + "<cmd>BufferCloseAllButCurrent<cr>", + "close all but current buffer", + }, + h = { "<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left" }, + l = { + "<cmd>BufferCloseBuffersRight<cr>", + "close all BufferLines to the right", + }, + D = { + "<cmd>BufferOrderByDirectory<cr>", + "sort BufferLines automatically by directory", + }, + L = { + "<cmd>BufferOrderByLanguage<cr>", + "sort BufferLines automatically by language", + }, +} diff --git a/.config/nvim/lua/core/colorizer.lua b/.config/nvim/lua/core/colorizer.lua new file mode 100644 index 0000000..c6a2a27 --- /dev/null +++ b/.config/nvim/lua/core/colorizer.lua @@ -0,0 +1,17 @@ +local M = {} + +M.config = function() + O.plugin.hop = { + active = false, + } +end + +M.setup = function() + local status_ok, colorizer = pcall(require, "colorizer") + if not status_ok then + return + end + colorizer.setup(O.plugin.hop) +end + +return M diff --git a/.config/nvim/lua/core/compe.lua b/.config/nvim/lua/core/compe.lua new file mode 100644 index 0000000..c8152ad --- /dev/null +++ b/.config/nvim/lua/core/compe.lua @@ -0,0 +1,96 @@ +local M = {} +M.config = function() + O.completion = { + enabled = true, + autocomplete = true, + debug = false, + min_length = 1, + preselect = "enable", + throttle_time = 80, + source_timeout = 200, + incomplete_delay = 400, + max_abbr_width = 100, + max_kind_width = 100, + max_menu_width = 100, + documentation = true, + + source = { + path = { kind = " (Path)" }, + buffer = { kind = " (Buffer)" }, + calc = { kind = " (Calc)" }, + vsnip = { kind = " (Snippet)" }, + nvim_lsp = { kind = " (LSP)" }, + nvim_lua = false, + spell = { kind = " (Spell)" }, + tags = false, + vim_dadbod_completion = false, + snippets_nvim = false, + ultisnips = false, + treesitter = false, + emoji = { kind = " ﲃ (Emoji)", filetypes = { "markdown", "text" } }, + -- for emoji press : (idk if that in compe tho) + }, + } +end + +M.setup = function() + vim.g.vsnip_snippet_dir = O.vsnip_dir + + local status_ok, compe = pcall(require, "compe") + if not status_ok then + return + end + + compe.setup(O.completion) + + local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) + end + + local check_back_space = function() + local col = vim.fn.col "." - 1 + if col == 0 or vim.fn.getline("."):sub(col, col):match "%s" then + return true + else + return false + end + end + + -- Use (s-)tab to: + --- move to prev/next item in completion menuone + --- jump to prev/next snippet's placeholder + _G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "<C-n>" + elseif vim.fn.call("vsnip#available", { 1 }) == 1 then + return t "<Plug>(vsnip-expand-or-jump)" + elseif check_back_space() then + return t "<Tab>" + else + return vim.fn["compe#complete"]() + end + end + + _G.s_tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "<C-p>" + elseif vim.fn.call("vsnip#jumpable", { -1 }) == 1 then + return t "<Plug>(vsnip-jump-prev)" + else + return t "<S-Tab>" + end + end + + vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true }) + vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true }) + vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) + vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) + + vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true }) + vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true }) + vim.api.nvim_set_keymap("i", "<C-e>", "compe#close('<C-e>')", { noremap = true, silent = true, expr = true }) + vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({ 'delta': +4 })", { noremap = true, silent = true, expr = true }) + vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({ 'delta': -4 })", { noremap = true, silent = true, expr = true }) +end + +return M diff --git a/.config/nvim/lua/core/dap.lua b/.config/nvim/lua/core/dap.lua new file mode 100644 index 0000000..bc76e22 --- /dev/null +++ b/.config/nvim/lua/core/dap.lua @@ -0,0 +1,41 @@ +local M = {} +M.config = function() + O.plugin.dap = { + active = false, + breakpoint = { + text = "", + texthl = "LspDiagnosticsSignError", + linehl = "", + numhl = "", + }, + } +end + +M.setup = function() + local status_ok, dap = pcall(require, "dap") + if not status_ok then + return + end + + vim.fn.sign_define("DapBreakpoint", O.plugin.dap.breakpoint) + dap.defaults.fallback.terminal_win_cmd = "50vsplit new" + + O.user_which_key["d"] = { + name = "Debug", + t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" }, + b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" }, + c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" }, + C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" }, + d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" }, + g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" }, + i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" }, + o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" }, + u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" }, + p = { "<cmd>lua require'dap'.pause.toggle()<cr>", "Pause" }, + r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" }, + s = { "<cmd>lua require'dap'.continue()<cr>", "Start" }, + q = { "<cmd>lua require'dap'.stop()<cr>", "Quit" }, + } +end + +return M diff --git a/.config/nvim/lua/core/dashboard.lua b/.config/nvim/lua/core/dashboard.lua new file mode 100644 index 0000000..4c7ecc3 --- /dev/null +++ b/.config/nvim/lua/core/dashboard.lua @@ -0,0 +1,98 @@ +local M = {} +M.config = function() + O.plugin.dashboard = { + active = false, + search_handler = "telescope", + 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 = { " Recently Used Files" }, + command = "Telescope oldfiles", + }, + c = { + description = { " Find Word " }, + command = "Telescope live_grep", + }, + d = { + description = { " Settings " }, + command = ":e ~/.config/nvim/config.lua", + }, + }, + + } +end + +M.setup = function() + vim.g.dashboard_disable_at_vimenter = 0 + + vim.g.dashboard_custom_header = O.plugin.dashboard.custom_header + + vim.g.dashboard_default_executive = O.plugin.dashboard.search_handler + + vim.g.dashboard_custom_section = O.plugin.dashboard.custom_section + + O.plugin.which_key.mappings[";"] = { "<cmd>Dashboard<CR>", "Dashboard" } + + -- f = { + -- description = { " Neovim Config Files" }, + -- command = "Telescope find_files cwd=" .. CONFIG_PATH, + -- }, + -- e = {description = {' Marks '}, command = 'Telescope marks'} + + vim.cmd "let g:dashboard_session_directory = $HOME..'/.config/nvim/.sessions'" + vim.cmd "let packages = len(globpath('~/.local/share/nvim/site/pack/packer/start', '*', 0, 1))" + + vim.api.nvim_exec( + [[ + let g:dashboard_custom_footer = ['LuaJIT loaded '..packages..' plugins'] +]], + false + ) + + -- file_browser = {description = {' File Browser'}, command = 'Telescope find_files'}, + + -- vim.g.dashboard_session_directory = CACHE_PATH..'/session' + -- vim.g.dashboard_custom_footer = O.dashboard.footer + require("utils").define_augroups { + _dashboard = { + -- seems to be nobuflisted that makes my stuff disapear 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=" .. O.default_options.showtabline, + }, + { "FileType", "dashboard", "nnoremap <silent> <buffer> q :q<CR>" }, + }, + } +end + +return M diff --git a/.config/nvim/lua/core/formatter.lua b/.config/nvim/lua/core/formatter.lua new file mode 100644 index 0000000..04c078a --- /dev/null +++ b/.config/nvim/lua/core/formatter.lua @@ -0,0 +1,60 @@ +-- autoformat +if O.format_on_save then + require("utils").define_augroups { + autoformat = { + { + "BufWritePost", + "*", + ":silent FormatWrite", + }, + }, + } +end + +-- -- check if formatter has been defined for the language or not +-- local function formatter_exists(lang_formatter) +-- if lang_formatter == nil then +-- return false +-- end +-- if lang_formatter.exe == nil or lang_formatter.args == nil then +-- return false +-- end +-- return true +-- end + +-- returns default formatter for given language +-- local function formatter_return(lang_formatter) +-- return { +-- exe = lang_formatter.exe, +-- args = lang_formatter.args, +-- stdin = not (lang_formatter.stdin ~= nil), +-- } +-- end + +-- fill a table like this -> {rust: {exe:"sth",args:{"a","b"},stdin=true},go: {}...} +-- local formatter_filetypes = {} +-- for k, v in pairs(O.lang) do +-- if formatter_exists(v.formatter) then +-- local keys = v.filetypes +-- if keys == nil then +-- keys = { k } +-- end +-- for _, l in pairs(keys) do +-- formatter_filetypes[l] = { +-- function() +-- return formatter_return(v.formatter) +-- end, +-- } +-- end +-- end +-- end +local status_ok, _ = pcall(require, "formatter") +if not status_ok then + return +end + +if not O.format_on_save then + vim.cmd [[if exists('#autoformat#BufWritePost') + :autocmd! autoformat + endif]] +end diff --git a/.config/nvim/lua/core/galaxyline.lua b/.config/nvim/lua/core/galaxyline.lua new file mode 100644 index 0000000..1f9f781 --- /dev/null +++ b/.config/nvim/lua/core/galaxyline.lua @@ -0,0 +1,315 @@ +-- if not package.loaded['galaxyline'] then +-- return +-- end +local status_ok, gl = pcall(require, "galaxyline") +if not status_ok then + return +end + +-- NOTE: if someone defines colors but doesn't have them then this will break +local palette_status_ok, colors = pcall(require, O.colorscheme .. ".palette") +if not palette_status_ok then + colors = O.plugin.galaxyline.colors +end + +local condition = require "galaxyline.condition" +local gls = gl.section +gl.short_line_list = { "NvimTree", "vista", "dbui", "packer" } + +table.insert(gls.left, { + ViMode = { + provider = 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..' ' + end, + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +vim.fn.getbufvar(0, "ts") + +table.insert(gls.left, { + GitIcon = { + provider = function() + return " " + end, + condition = condition.check_git_workspace, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.orange, colors.alt_bg }, + }, +}) + +table.insert(gls.left, { + GitBranch = { + provider = "GitBranch", + condition = condition.check_git_workspace, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.left, { + DiffAdd = { + provider = "DiffAdd", + condition = condition.hide_in_width, + icon = " ", + highlight = { colors.green, colors.alt_bg }, + }, +}) + +table.insert(gls.left, { + DiffModified = { + provider = "DiffModified", + condition = condition.hide_in_width, + icon = " 柳", + highlight = { colors.blue, colors.alt_bg }, + }, +}) + +table.insert(gls.left, { + DiffRemove = { + provider = "DiffRemove", + condition = condition.hide_in_width, + icon = " ", + highlight = { colors.red, colors.alt_bg }, + }, +}) + +table.insert(gls.left, { + Filler = { + provider = function() + return " " + end, + highlight = { colors.grey, colors.alt_bg }, + }, +}) +-- get output from shell command +function os.capture(cmd, raw) + local f = assert(io.popen(cmd, "r")) + local s = assert(f:read "*a") + f:close() + if raw then + return s + end + s = string.gsub(s, "^%s+", "") + s = string.gsub(s, "%s+$", "") + s = string.gsub(s, "[\n\r]+", " ") + return s +end +-- cleanup virtual env +local function 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 +local PythonEnv = function() + if vim.bo.filetype == "python" then + local venv = os.getenv "CONDA_DEFAULT_ENV" + if venv ~= nil then + return " (" .. env_cleanup(venv) .. ")" + end + venv = os.getenv "VIRTUAL_ENV" + if venv ~= nil then + return " (" .. env_cleanup(venv) .. ")" + end + return "" + end + return "" +end +table.insert(gls.left, { + VirtualEnv = { + provider = PythonEnv, + event = "BufEnter", + highlight = { colors.green, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + DiagnosticError = { + provider = "DiagnosticError", + icon = " ", + highlight = { colors.red, colors.alt_bg }, + }, +}) +table.insert(gls.right, { + DiagnosticWarn = { + provider = "DiagnosticWarn", + icon = " ", + highlight = { colors.orange, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + DiagnosticInfo = { + provider = "DiagnosticInfo", + icon = " ", + highlight = { colors.yellow, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + DiagnosticHint = { + provider = "DiagnosticHint", + icon = " ", + highlight = { colors.blue, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + TreesitterIcon = { + provider = function() + if next(vim.treesitter.highlighter.active) ~= nil then + return " " + end + return "" + end, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.green, colors.alt_bg }, + }, +}) + +local get_lsp_client = function(msg) + msg = msg or "LSP Inactive" + local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") + local clients = vim.lsp.get_active_clients() + if next(clients) == nil then + return msg + end + local lsps = "" + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + -- print(client.name) + if lsps == "" then + -- print("first", lsps) + lsps = client.name + else + if not string.find(lsps, client.name) then + lsps = lsps .. ", " .. client.name + end + -- print("more", lsps) + end + end + end + if lsps == "" then + return msg + else + return lsps + end +end + +table.insert(gls.right, { + ShowLspClient = { + provider = get_lsp_client, + condition = function() + local tbl = { ["dashboard"] = true, [" "] = true } + if tbl[vim.bo.filetype] then + return false + end + return true + end, + icon = " ", + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + LineInfo = { + provider = "LineColumn", + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + PerCent = { + provider = "LinePercent", + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + Tabstop = { + provider = function() + return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " " + end, + condition = condition.hide_in_width, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + BufferType = { + provider = "FileTypeName", + condition = condition.hide_in_width, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + FileEncode = { + provider = "FileEncode", + condition = condition.hide_in_width, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.right, { + Space = { + provider = function() + return " " + end, + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.grey, colors.alt_bg }, + }, +}) + +table.insert(gls.short_line_left, { + BufferType = { + provider = "FileTypeName", + separator = " ", + separator_highlight = { "NONE", colors.alt_bg }, + highlight = { colors.alt_bg, colors.alt_bg }, + }, +}) + +table.insert(gls.short_line_left, { + SFileName = { + provider = "SFileName", + condition = condition.buffer_not_empty, + highlight = { colors.alt_bg, colors.alt_bg }, + }, +}) + +--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.alt_bg}}}) diff --git a/.config/nvim/lua/core/gitsigns.lua b/.config/nvim/lua/core/gitsigns.lua new file mode 100644 index 0000000..bc310ad --- /dev/null +++ b/.config/nvim/lua/core/gitsigns.lua @@ -0,0 +1,59 @@ +local M = {} +M.config = function() + O.plugin.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_index = { interval = 1000 }, + sign_priority = 6, + update_debounce = 200, + status_formatter = nil, -- Use default + use_decoration_api = false, + } +end + +M.setup = function() + local status_ok, gitsigns = pcall(require, "gitsigns") + if not status_ok then + return + end + gitsigns.setup(O.plugin.gitsigns) +end + +return M diff --git a/.config/nvim/lua/core/hop.lua b/.config/nvim/lua/core/hop.lua new file mode 100644 index 0000000..d3dd90d --- /dev/null +++ b/.config/nvim/lua/core/hop.lua @@ -0,0 +1,20 @@ +vim.api.nvim_set_keymap('n', 's', ":HopChar2<cr>", { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'S', ":HopWord<cr>", { noremap = true, silent = true }) + +local M = {} + +M.config = function() + O.plugin.hop = { + active = false, + } +end + +M.setup = function() + local status_ok, hop = pcall(require, "hop") + if not status_ok then + return + end + hop.setup(O.plugin.hop) +end + +return M diff --git a/.config/nvim/lua/core/linter.lua b/.config/nvim/lua/core/linter.lua new file mode 100644 index 0000000..94dff93 --- /dev/null +++ b/.config/nvim/lua/core/linter.lua @@ -0,0 +1,33 @@ +local M = {} + +M.setup = function() + if O.lint_on_save then + require("utils").define_augroups { + autolint = { + { + "BufWritePost", + "<buffer>", + ":silent lua require('lint').try_lint()", + }, + { + "BufEnter", + "<buffer>", + ":silent lua require('lint').try_lint()", + }, + }, + } + end +end + +local status_ok, _ = pcall(require, "lint") +if not status_ok then + return +end + +if not O.lint_on_save then + vim.cmd [[if exists('#autolint#BufWritePost') + :autocmd! autolint + endif]] +end + +return M diff --git a/.config/nvim/lua/core/nvimtree.lua b/.config/nvim/lua/core/nvimtree.lua new file mode 100644 index 0000000..a763c71 --- /dev/null +++ b/.config/nvim/lua/core/nvimtree.lua @@ -0,0 +1,88 @@ +local M = {} +-- +M.config = function() + O.plugin.nvimtree = { + side = "left", + show_icons = { + git = 1, + folders = 1, + files = 1, + folder_arrows = 1, + tree_width = 30, + }, + ignore = { ".git", "node_modules", ".cache" }, + auto_open = 1, + auto_close = 1, + quit_on_open = 0, + follow = 1, + hide_dotfiles = 1, + git_hl = 1, + root_folder_modifier = ":t", + tab_open = 0, + allow_resize = 1, + lsp_diagnostics = 1, + auto_ignore_ft = { "startify", "dashboard" }, + icons = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, + } +end +-- +M.setup = function() + local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") + if not status_ok then + return + end + local g = vim.g + + for opt, val in pairs(O.plugin.nvimtree) do + g["nvim_tree_" .. opt] = val + end + + local tree_cb = nvim_tree_config.nvim_tree_callback + + g.nvim_tree_bindings = { + { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + } +end +-- +-- +M.toggle_tree = function() + local view_status_ok, view = pcall(require, "nvim-tree.view") + if not view_status_ok then + return + end + if view.win_open() then + require("nvim-tree").close() + if package.loaded["bufferline.state"] then + require("bufferline.state").set_offset(0) + end + else + if package.loaded["bufferline.state"] then + -- require'bufferline.state'.set_offset(31, 'File Explorer') + require("bufferline.state").set_offset(31, "") + end + require("nvim-tree").toggle() + end +end +-- +return M diff --git a/.config/nvim/lua/core/status_colors.lua b/.config/nvim/lua/core/status_colors.lua new file mode 100644 index 0000000..9a70ddd --- /dev/null +++ b/.config/nvim/lua/core/status_colors.lua @@ -0,0 +1,19 @@ +O.plugin.galaxyline = { + active = true, + colors = { + alt_bg = "#0A0A0A", + 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", + }, +} diff --git a/.config/nvim/lua/core/telescope.lua b/.config/nvim/lua/core/telescope.lua new file mode 100644 index 0000000..48157bc --- /dev/null +++ b/.config/nvim/lua/core/telescope.lua @@ -0,0 +1,97 @@ +local M = {} +M.config = function() + local status_ok, actions = pcall(require, "telescope.actions") + if not status_ok then + return + end + + O.plugin.telescope = { + active = false, + defaults = { + find_command = { + "rg", + "--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 = { + width = 0.75, + prompt_position = "top", + preview_cutoff = 120, + horizontal = { mirror = false }, + vertical = { mirror = false }, + }, + file_sorter = require("telescope.sorters").get_fzy_sorter, + file_ignore_patterns = {}, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = {"shorten"}, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + use_less = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + + + -- Developer configurations: Not meant for general override + -- buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + mappings = { + i = { + -- ["<C-n>"] = actions.cycle_history_next, + -- ["<C-p>"] = actions.cycle_history_prev, + ["<C-c>"] = actions.close, + ["<C-j>"] = actions.move_selection_next, + ["<C-k>"] = actions.move_selection_previous, + ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, + ["<CR>"] = actions.select_default + actions.center, + -- To disable a keymap, put [map] = false + -- So, to not map "<C-n>", just put + -- ["<c-t>"] = trouble.open_with_trouble, + -- ["<c-x>"] = false, + -- ["<esc>"] = actions.close, + -- Otherwise, just set the mapping to the function that you want it to be. + -- ["<C-i>"] = actions.select_horizontal, + -- Add up multiple actions + -- You can perform as many actions in a row as you like + -- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action, + }, + n = { + ["<C-j>"] = actions.move_selection_next, + ["<C-k>"] = actions.move_selection_previous, + ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, + -- ["<c-t>"] = trouble.open_with_trouble, + -- ["<C-i>"] = my_cool_custom_action, + }, + }, + }, + extensions = { + fzy_native = { + override_generic_sorter = false, + override_file_sorter = true, + }, + }, + } +end + +M.setup = function() + local status_ok, telescope = pcall(require, "telescope") + if not status_ok then + return + end + telescope.setup(O.plugin.telescope) + vim.api.nvim_set_keymap("n", "<Leader>f", ":Telescope find_files<CR>", { noremap = true, silent = true }) +end + +return M diff --git a/.config/nvim/lua/core/terminal.lua b/.config/nvim/lua/core/terminal.lua new file mode 100644 index 0000000..0f93045 --- /dev/null +++ b/.config/nvim/lua/core/terminal.lua @@ -0,0 +1,68 @@ +local M = {} +M.config = function() + O.plugin["terminal"] = { + -- size can be a number or function which is passed the current terminal + size = 5, + -- 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 = true, + -- 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 = 3, + highlights = { + border = "Normal", + background = "Normal", + }, + }, + } +end + +M.setup = function() + local status_ok, terminal = pcall(require, "toggleterm") + if not status_ok then + print(terminal) + return + end + vim.api.nvim_set_keymap( + "n", + "<leader>gg", + "<cmd>lua require('core.terminal')._lazygit_toggle()<CR>", + { noremap = true, silent = true } + ) + O.plugin.which_key.mappings["gg"] = "LazyGit" + terminal.setup(O.plugin.terminal) +end + +local function is_installed(exe) + return vim.fn.executable(exe) == 1 +end + +M._lazygit_toggle = function() + if is_installed "lazygit" ~= true then + print "Please install lazygit. Check documentation for more information" + return + end + local Terminal = require("toggleterm.terminal").Terminal + local lazygit = Terminal:new { cmd = "lazygit", hidden = true } + lazygit:toggle() +end + +return M diff --git a/.config/nvim/lua/core/treesitter.lua b/.config/nvim/lua/core/treesitter.lua new file mode 100644 index 0000000..2b7a2d5 --- /dev/null +++ b/.config/nvim/lua/core/treesitter.lua @@ -0,0 +1,187 @@ +local M = {} +M.config = function() + O.treesitter = { + 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 = false, + config = { css = "// %s" }, + }, + -- indent = {enable = true, disable = {"python", "html", "javascript"}}, + -- TODO seems to be broken + indent = { enable = { "javascriptreact" } }, + 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 + }, + } + + -- -- TODO refactor treesitter + -- -- @usage pass a table with your desired languages + -- treesitter = { + -- ensure_installed = "all", + -- ignore_install = { "haskell" }, + -- highlight = { enabled = true }, + -- -- The below are for treesitter-textobjects plugin + -- textobj_prefixes = { + -- goto_next = "]", -- Go to next + -- goto_previous = "[", -- Go to previous + -- inner = "i", -- Select inside + -- outer = "a", -- Selct around + -- swap = "<leader>a", -- Swap with next + -- }, + -- textobj_suffixes = { + -- -- Start and End respectively for the goto keys + -- -- for other keys it only uses the first + -- ["function"] = { "f", "F" }, + -- ["class"] = { "m", "M" }, + -- ["parameter"] = { "a", "A" }, + -- ["block"] = { "k", "K" }, + -- ["conditional"] = { "i", "I" }, + -- ["call"] = { "c", "C" }, + -- ["loop"] = { "l", "L" }, + -- ["statement"] = { "s", "S" }, + -- ["comment"] = { "/", "?" }, + -- }, + -- -- The below is for treesitter hint textobjects plugin + -- hint_labels = { "h", "j", "f", "d", "n", "v", "s", "l", "a" }, + -- }, +end + +M.setup = function() + -- TODO: refacor this whole file and treesitter in general + -- if not package.loaded['nvim-treesitter'] then return end + -- + -- Custom parsers + -- local parser_config = require("nvim-treesitter.parsers").get_parser_configs() + -- parser_config.make = { + -- install_info = { + -- url = "https://github.com/alemuller/tree-sitter-make", -- local path or git repo + -- files = {"src/parser.c"}, + -- requires_generate_from_grammar = true + -- } + -- } + -- parser_config.just = { + -- install_info = { + -- url = "~/dev/tree-sitter-just", -- local path or git repo + -- files = {"src/parser.c"} + -- } + -- -- filetype = "just", -- if filetype does not agrees with parser name + -- -- used_by = {"bar", "baz"} -- additional filetypes that use this parser + -- } + -- Custom text objects + -- local textobj_prefixes = O.treesitter.textobj_prefixes + -- local textobj_suffixes = O.treesitter.textobj_suffixes + -- local textobj_sel_keymaps = {} + -- local textobj_swap_keymaps = {} + -- local textobj_move_keymaps = { + -- enable = O.plugin.ts_textobjects, + -- set_jumps = true, -- whether to set jumps in the jumplist + -- goto_next_start = {}, + -- goto_next_end = {}, + -- goto_previous_start = {}, + -- goto_previous_end = {}, + -- } + -- for obj, suffix in pairs(textobj_suffixes) do + -- if textobj_prefixes["goto_next"] ~= nil then + -- textobj_move_keymaps["goto_next_start"][textobj_prefixes["goto_next"] .. suffix[1]] = "@" .. obj .. ".outer" + -- textobj_move_keymaps["goto_next_end"][textobj_prefixes["goto_next"] .. suffix[2]] = "@" .. obj .. ".outer" + -- end + -- if textobj_prefixes["goto_previous"] ~= nil then + -- textobj_move_keymaps["goto_previous_start"][textobj_prefixes["goto_previous"] .. suffix[2]] = "@" .. obj .. ".outer" + -- textobj_move_keymaps["goto_previous_end"][textobj_prefixes["goto_previous"] .. suffix[1]] = "@" .. obj .. ".outer" + -- end + -- + -- if textobj_prefixes["inner"] ~= nil then + -- textobj_sel_keymaps[textobj_prefixes["inner"] .. suffix[1]] = "@" .. obj .. ".inner" + -- end + -- if textobj_prefixes["outer"] ~= nil then + -- textobj_sel_keymaps[textobj_prefixes["outer"] .. suffix[1]] = "@" .. obj .. ".outer" + -- end + -- + -- if textobj_prefixes["swap"] ~= nil then + -- textobj_swap_keymaps[textobj_prefixes["swap"] .. suffix[1]] = "@" .. obj .. ".outer" + -- end + -- end + -- vim.g.ts_hint_textobject_keys = O.treesitter.hint_labels -- Requires https://github.com/mfussenegger/nvim-ts-hint-textobject/pull/2 + -- + -- -- Add which key menu entries + -- local status, wk = pcall(require, "which-key") + -- if status then + -- local normal = { + -- mode = "n", -- Normal mode + -- } + -- local operators = { + -- mode = "o", -- Operator mode + -- } + -- wk.register(textobj_sel_keymaps, operators) + -- wk.register({ + -- ["m"] = "Hint Objects", + -- ["."] = "Textsubject", + -- [";"] = "Textsubject-big", + -- }, operators) + -- wk.register(textobj_swap_keymaps, normal) + -- wk.register({ + -- [textobj_prefixes["swap"]] = "Swap", + -- -- [textobj_prefixes["goto_next"]] = "Jump [", + -- -- [textobj_prefixes["goto_previous"]] = "Jump ]" + -- }, normal) + -- wk.register(textobj_move_keymaps["goto_next_start"], normal) + -- wk.register(textobj_move_keymaps["goto_next_end"], normal) + -- wk.register(textobj_move_keymaps["goto_previous_start"], normal) + -- wk.register(textobj_move_keymaps["goto_previous_end"], normal) + -- end + + local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs") + if not status_ok then + return + end + + treesitter_configs.setup(O.treesitter) +end + +return M diff --git a/.config/nvim/lua/core/which-key.lua b/.config/nvim/lua/core/which-key.lua new file mode 100644 index 0000000..dabf832 --- /dev/null +++ b/.config/nvim/lua/core/which-key.lua @@ -0,0 +1,201 @@ +local M = {} +M.config = function() + O.plugin.which_key = { + active = false, + 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 = { + ["/"] = { ":CommentToggle<CR>", "Comment" }, + }, + mappings = { + ["w"] = { "<cmd>w!<CR>", "Save" }, + ["q"] = { "<cmd>q!<CR>", "Quit" }, + ["k"] = { "<cmd>CommentToggle<CR>", "Comment" }, + ["c"] = { "<cmd>BufferClose!<CR>", "Close Buffer" }, + ["e"] = { "<cmd>lua require'core.nvimtree'.toggle_tree()<CR>", "Explorer" }, + ["f"] = { "<cmd>Telescope find_files<CR>", "Find File" }, + ["n"] = { '<cmd>let @/=""<CR>', "No Highlight" }, + ["h"] = { "<cmd>vsplit<CR>", "Vertical Split" }, + ["v"] = { '<cmd>split<CR>', "Horizontal Split" }, + p = { + name = "Packer", + c = { "<cmd>PackerCompile<cr>", "Compile" }, + i = { "<cmd>PackerInstall<cr>", "Install" }, + r = { "<cmd>lua require('utils').reload_config()<cr>", "Reload" }, + s = { "<cmd>PackerSync<cr>", "Sync" }, + 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)", + }, + }, + + l = { + name = "LSP", + a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" }, + d = { + "<cmd>Telescope lsp_document_diagnostics<cr>", + "Document Diagnostics", + }, + w = { + "<cmd>Telescope lsp_workspace_diagnostics<cr>", + "Workspace Diagnostics", + }, + f = { "<cmd>silent FormatWrite<cr>", "Format" }, + i = { "<cmd>LspInfo<cr>", "Info" }, + j = { + "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<cr>", + "Next Diagnostic", + }, + k = { + "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<cr>", + "Prev Diagnostic", + }, + l = { "<cmd>silent lua require('lint').try_lint()<cr>", "Lint" }, + q = { "<cmd>Telescope quickfix<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", + }, + }, + + 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() + -- if not package.loaded['which-key'] then + -- return + -- end + local status_ok, which_key = pcall(require, "which-key") + if not status_ok then + return + end + + which_key.setup(O.plugin.which_key.setup) + + local opts = O.plugin.which_key.opts + local vopts = O.plugin.which_key.vopts + + local mappings = O.plugin.which_key.mappings + local vmappings = O.plugin.which_key.vmappings + + -- if O.plugin.ts_playground.active then + -- vim.api.nvim_set_keymap("n", "<leader>Th", ":TSHighlightCapturesUnderCursor<CR>", { noremap = true, silent = true }) + -- mappings[""] = "Highlight Capture" + -- end + + if O.plugin.zen.active then + vim.api.nvim_set_keymap("n", "<leader>z", ":ZenMode<CR>", { noremap = true, silent = true }) + mappings["z"] = "Zen" + end + + local wk = require "which-key" + + wk.register(mappings, opts) + wk.register(vmappings, vopts) + wk.register(O.user_which_key, opts) +end + +return M diff --git a/.config/nvim/lua/core/zen.lua b/.config/nvim/lua/core/zen.lua new file mode 100644 index 0000000..99a5d76 --- /dev/null +++ b/.config/nvim/lua/core/zen.lua @@ -0,0 +1,34 @@ +local M = {} +M.config = function() + O.plugin["zen"] = { + window = { + backdrop = 1, + height = 0.85, -- height of the Zen window + options = { + signcolumn = "no", -- disable signcolumn + number = false, -- disable number column + relativenumber = false, -- disable relative numbers + -- cursorline = false, -- disable cursorline + -- cursorcolumn = false, -- disable cursor column + -- foldcolumn = "0", -- disable fold column + -- list = false, -- disable whitespace characters + }, + }, + plugins = { + gitsigns = { enabled = false }, -- disables git signs + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + } +end + +M.setup = function() + local status_ok, zen_mode = pcall(require, "zen-mode") + if not status_ok then + return + end + zen_mode.setup(O.plugin.zen) +end + +return M |