diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua index 8f9f871..4f38b16 100644 --- a/after/plugin/colors.lua +++ b/after/plugin/colors.lua @@ -191,13 +191,17 @@ vim.cmd[[colorscheme no-clown-fiesta]] -- My own color overrides local hl = vim.api.nvim_set_hl -hl(0, 'TSConstant', { fg = palette.yellow }) -hl(0, 'EndOfBuffer', { fg = palette.medium_gray }) -hl(0, 'ErrorMsg', { fg = palette.yellow }) -hl(0, 'LineNr', { fg = palette.medium_gray }) -hl(0, 'MasonNormal', { bg = palette.gray }) -hl(0, 'NvimTreeCursorLine', { fg = palette.yellow }) -hl(0, 'NvimTreeEndOfBuffer', { fg = palette.medium_gray }) +hl(0, 'TSConstant', { fg = palette.yellow }) +hl(0, 'EndOfBuffer', { fg = palette.medium_gray }) +hl(0, 'ErrorMsg', { fg = palette.yellow }) +hl(0, 'LineNr', { fg = palette.medium_gray }) +hl(0, 'MasonNormal', { bg = palette.gray }) +hl(0, 'NvimTreeCursorLine', { fg = palette.yellow }) +hl(0, 'NvimTreeEndOfBuffer', { fg = palette.medium_gray }) hl(0, 'NvimTreeIndentMarker', { fg = palette.medium_gray }) -hl(0, 'NvimTreeFolderIcon', { fg = palette.yellow }) +hl(0, 'NvimTreeFolderIcon', { fg = palette.yellow }) +hl(0, 'WhichKeyFloat', { bg = nil }) +hl(0, 'WhichKeyDesc', { link = "function" }) +hl(0, 'WhichKey', { fg = palette.medium_gray_blue }) +hl(0, 'WhichKeyGroup', { fg = palette.gray_blue, bold = true }) diff --git a/after/plugin/dashboard.lua b/after/plugin/dashboard.lua index e69de29..711ee35 100644 --- a/after/plugin/dashboard.lua +++ b/after/plugin/dashboard.lua @@ -0,0 +1,58 @@ +local alpha = require("alpha") +local dashboard = require("alpha.themes.dashboard") + +math.randomseed(os.time()) + +local function pick_color() + local colors = {"String", "Identifier", "Keyword", "Number"} + return colors[math.random(#colors)] +end + +local function footer() + local total_plugins = #vim.tbl_keys(packer_plugins) + local version = vim.version() + local nvim_version_info = " NVIM v" .. version.major .. "." .. version.minor .. "." .. version.patch + + return nvim_version_info .. " 󰏖 " .. total_plugins .. " plugins" +end + +-- Set header +dashboard.section.header.val = { + " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣭⣿⣶⣿⣦⣼⣆ ", + " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", + " ⠈ ⠈⢿⣿⣟⠦⠄⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", + " ⣸⣿⣿⢧⠄⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", + " ⢠⣿⣿⣿⠈ ⠡⠌⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", + " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿ ", + " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷⠄ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", + "⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", + "⠙⠃ ⣼⣿⡟⠌ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿⠐⣿⣿⡇ ⠛⠻⢷⣄", + " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ⠁", + " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⣤⣾⡿⠃ ", + "⢀⣀⠀⣠⣀⣠⣾⣿⣿⡿⠛⠋⠉⠉⠉ ⠉⠉⠉⠉⠛⠻⣿⣿⣷⣄⣀⢿⡽⢻⣦", + "⠻⠶⠾⠿⠿⠿⠋⠉ N E O V I M ⠉⠻⠿⠿⠿⠿⠿⠋", +} + +-- Set menu +dashboard.section.buttons.val = { + dashboard.button( "e", " New file" , ":ene startinsert "), + dashboard.button( "q", "󰩈 Quit NVIM", ":qa"), +} + +vim.api.nvim_create_autocmd("VimEnter", { + once = true, + callback = function() + math.randomseed(os.time()) + local fg_color = tostring(math.random(0, 12)) + local hi_setter = "hi AlphaHeader ctermfg=" + vim.cmd(hi_setter .. fg_color) + end +}) + +dashboard.section.footer.val = footer() + +dashboard.section.header.opts.hl = "Include" +dashboard.section.footer.opts.hl = "String" + +alpha.setup(dashboard.opts) + diff --git a/after/plugin/fugative.lua b/after/plugin/fugative.lua index 435d82a..12b6d67 100644 --- a/after/plugin/fugative.lua +++ b/after/plugin/fugative.lua @@ -1,2 +1,4 @@ -vim.keymap.set("n", "gs", vim.cmd.Git) +local wk = require("which-key") +wk.register({g = { name = "git" }, prefix = ""}) +vim.keymap.set("n", "gs", vim.cmd.Git, { desc = "Git status" }) diff --git a/after/plugin/lf.lua b/after/plugin/lf.lua index 7ff58e9..58a2922 100644 --- a/after/plugin/lf.lua +++ b/after/plugin/lf.lua @@ -1,4 +1,4 @@ -vim.keymap.set("n", "e", function () - vim.cmd("Lf") -end) +-- vim.keymap.set("n", "e", function () +-- vim.cmd("Lf") +-- end) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 7419405..541b066 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -9,17 +9,23 @@ lsp_zero.on_attach(function(client, bufnr) lsp_zero.default_keymaps({buffer = bufnr}) end) +-- LUA lspconfig.lua_ls.setup({ settings = { Lua = { diagnostics = { -- Making sure that lua recognizes the global variable 'vim' - globals = { 'vim' }, + globals = { 'vim', 'xplr' }, }, }, }, }) +-- RUST +-- Must run `rustup default stable` and then `rustup component add rust-analyzer` +-- upon first install +lspconfig.rust_analyzer.setup({}) + lspconfig.clangd.setup({ capabilities = lsp_capabilities, }) @@ -53,3 +59,11 @@ cmp.setup({ } }) +-- DIAGNOSTICS + +-- Show all diagnostics on current line in floating window +vim.api.nvim_set_keymap( + 'n', 'gl', ':lua vim.diagnostic.open_float()', + { noremap = true, silent = true } +) + diff --git a/after/plugin/markdownpreview.lua b/after/plugin/markdownpreview.lua index 26edc76..a6f9c75 100644 --- a/after/plugin/markdownpreview.lua +++ b/after/plugin/markdownpreview.lua @@ -1,6 +1,7 @@ -vim.cmd([[ +vim.keymap.set("n", "mp", "MarkdownPreview", + { desc = "Markdown prewview" }) -nmap mp MarkdownPreview +vim.cmd([[ " set to 1, nvim will open the preview window after entering the markdown buffer " default: 0 diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index a28bf87..76b1ba8 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,14 +1,29 @@ local builtin = require("telescope.builtin") -vim.keymap.set("n", "pf", builtin.find_files, {}) -vim.keymap.set("n", "ps", function() - builtin.grep_string({ search = vim.fn.input("Grep > ") }) -end) -vim.keymap.set("n", "ht", builtin.colorscheme, {}) - require("telescope").setup{ defaults = { file_ignore_patterns = { ".git\\", ".pyc", ".mypy_cache\\", "node_modules\\", ".svg" } } } +local wk = require("which-key") + +-- p +wk.register({p = { name = "project" }, prefix = ""}) +vim.keymap.set("n", "pf", builtin.find_files, {desc = "Project find"}) +vim.keymap.set("n", "ps", function () + builtin.grep_string({ search = vim.fn.input("Grep > ") }) + end , {desc = "Project search"}) + +-- f +wk.register({f = { name = "find" }, prefix = ""}) +vim.keymap.set("n", "fr", builtin.oldfiles, { desc = "Find recent" }) + +-- h +wk.register({h = { name = "help" }, prefix = ""}) +vim.keymap.set("n", "ht", builtin.colorscheme, { desc = "Load theme" }) +vim.keymap.set("n", "hf", builtin.commands , { desc = "Describe function" }) +vim.keymap.set("n", "hk", builtin.keymaps , { desc = "Describe key" }) +vim.keymap.set("n", "hv", builtin.vim_options, { desc = "Describe key" }) +vim.keymap.set("n", "hh", builtin.help_tags , { desc = "Search local wiki" }) + diff --git a/after/plugin/whichkey.lua b/after/plugin/whichkey.lua new file mode 100644 index 0000000..f1fd478 --- /dev/null +++ b/after/plugin/whichkey.lua @@ -0,0 +1,16 @@ +require("which-key").setup({ + window = { + border = "single", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size. + padding = { 0, 2, 0, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent + zindex = 1000, -- positive value to position WhichKey above other floating windows. + }, + 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 + align = "left", -- align columns left, center or right + }, +}) diff --git a/after/plugin/yazi.lua b/after/plugin/yazi.lua new file mode 100644 index 0000000..2fdf5ca --- /dev/null +++ b/after/plugin/yazi.lua @@ -0,0 +1,4 @@ +vim.keymap.set("n", "e", function () + vim.cmd("Yazi") +end) + diff --git a/init.lua b/init.lua old mode 100755 new mode 100644 diff --git a/lua/andrew/packer.lua b/lua/andrew/packer.lua index be78e50..82aa4e1 100644 --- a/lua/andrew/packer.lua +++ b/lua/andrew/packer.lua @@ -12,25 +12,28 @@ end local packer_bootstrap = ensure_packer() return require("packer").startup(function(use) + use "goolord/alpha-nvim" + use "wbthomason/packer.nvim" - -- -- Dashboard - -- use { - -- 'glepnir/dashboard-nvim', - -- event = 'VimEnter', - -- requires = {'nvim-tree/nvim-web-devicons'}, - -- config = function() - -- require('dashboard').setup { - -- -- config - -- } - -- end, - -- } + use "DreamMaoMao/yazi.nvim" + + use "whonore/Coqtail" + + use { + "folke/which-key.nvim", + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end + } -- File manager in nvim use { "ptzz/lf.vim", requires = { {"voldikss/vim-floaterm"} }, } + vim.cmd("let g:lf_map_keys = 0") -- Need to put here or else doesn't work -- Zen mode use "folke/zen-mode.nvim" @@ -97,6 +100,12 @@ return require("packer").startup(function(use) } } + -- Better diagnostics + use { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + } + -- Linting use "jose-elias-alvarez/null-ls.nvim" @@ -116,10 +125,10 @@ return require("packer").startup(function(use) }) -- Jupyter notebook integration - use { - "glacambre/firenvim", - run = function() vim.fn["firenvim#install"](0) end - } + -- use { + -- "glacambre/firenvim", + -- run = function() vim.fn["firenvim#install"](0) end + -- } if packer_bootstrap then require('packer').sync() diff --git a/lua/andrew/remap.lua b/lua/andrew/remap.lua index 3f386b9..c620ac3 100644 --- a/lua/andrew/remap.lua +++ b/lua/andrew/remap.lua @@ -13,7 +13,6 @@ vim.keymap.set("n", "N", "Nzzzv") -- easier escape back to normal mode vim.keymap.set("i", "", "") --- lol vim.keymap.set("n", "Q", "") -- universal find and replace @@ -35,7 +34,27 @@ vim.keymap.set("n", "y", "\"+y") vim.keymap.set("n", "d", "\"_d") vim.keymap.set("v", "d", "\"_d") +vim.keymap.set("n", "tc", + function () + local col = "78" + print(vim.o.cc) + if vim.o.cc == col then + vim.o.cc = "" + else + vim.o.cc = col + end + end, + {desc = "Toggle color column"}) + -- case insensitive search vim.keymap.set("n", "/", "/\\c") vim.keymap.set("n", "?", "?\\c") +vim.keymap.set("n", "hF", + function() + local result = vim.treesitter.get_captures_at_cursor(0) + print(vim.inspect(result)) + end, + { noremap = true, silent = false, desc = "Describe face" } +) + diff --git a/lua/andrew/set.lua b/lua/andrew/set.lua index f8c3f48..32b7a34 100644 --- a/lua/andrew/set.lua +++ b/lua/andrew/set.lua @@ -1,5 +1,3 @@ --- vim.opt.guicursor = "" - vim.opt.nu = true vim.opt.relativenumber = true @@ -9,9 +7,27 @@ vim.opt.shiftwidth = 4 vim.opt.expandtab = true vim.opt.smartindent = true +vim.opt.linebreak = true +local autocmd = vim.api.nvim_create_autocmd +autocmd("bufenter", { + pattern = "*", + callback = function() + if vim.bo.ft ~= "terminal" then + vim.opt.laststatus = 2 + else + vim.opt.laststatus = 0 + end + end, +}) + +-- Only search with case if capital letter is typed +vim.opt.ignorecase = true +vim.opt.smartcase = true vim.opt.wrap = true +vim.opt.splitbelow = true + vim.opt.scrolloff = 8 vim.opt.signcolumn = "auto"