-- general lvim.log.level = "warn" lvim.colorscheme = "tokyonight" vim.g.tokyonight_style = "night" vim.opt.undodir = vim.fn.stdpath "cache" .. "/undo" vim.opt.undofile = true vim.opt.titlestring = " %t" vim.opt.termguicolors = true vim.opt.timeoutlen = 500 lvim.builtin.alpha.active = true lvim.builtin.alpha.mode = "dashboard" lvim.builtin.terminal.active = true lvim.builtin.nvimtree.active = false lvim.builtin.treesitter.highlight.enabled = true lvim.lsp.automatic_servers_installation = false vim.g.NERDTreeHijackNetrw = 0 vim.g.lf_replace_netrw = 1 vim.opt.foldmethod = "expr" vim.opt.foldlevelstart = 99 vim.opt.foldexpr = "nvim_treesitter#foldexpr()" lvim.format_on_save = false lvim.line_wrap_cursor_movement = false -- Vimwiki Settings vim.g.vimwiki_ext2syntax = { ['.Rmd'] = 'markdown', ['.rmd'] = 'markdown', ['.md'] = 'markdown', ['.markdown'] = 'markdown', ['.mdown'] = 'markdown' } vim.g.vimwiki_list = { { ['path'] = '~/Documents/vimwiki', ['syntax'] = 'markdown', ['ext'] = '.md' } } -- Completion settings lvim.builtin.cmp.completion.keyword_length = 3 lvim.builtin.cmp.sources = { { name = "nvim_lsp" }, { name = "path" }, { name = "luasnip" }, { name = "cmp_tabnine" }, { name = "nvim_lua" }, { name = "buffer" }, { name = "calc" }, { name = "emoji" }, { name = "treesitter" }, { name = "crates" }, { name = "tmux" }, } local formatters = require "lvim.lsp.null-ls.formatters" formatters.setup { { command = "black", filetypes = { "python" } }, } -- Autocommands (https://neovim.io/doc/user/autocmd.html) vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, { pattern = "*", command="if &nu && mode() != \"i\" | set rnu | endif" }) vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, { pattern = "*", command="if &nu | set nornu | endif" }) vim.api.nvim_create_autocmd("FileType", { pattern = "zsh", callback = function() require("nvim-treesitter.highlight").attach(0, "bash") end }) vim.api.nvim_create_autocmd("ColorScheme", { pattern = "*", command = "hi FloatermBorder guibg=none" }) vim.api.nvim_create_autocmd("BufWritePost", { pattern = { "bm-files", "bm-dirs" }, command = "!shortcuts" }) vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, command = "set filetype=xdefaults" }) vim.api.nvim_create_autocmd("BufWritePost", { pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, command = "!xrdb %" }) vim.api.nvim_create_autocmd("BufWritePost", { pattern = "~/.local/src/dwmblocks/config.h", command = "!cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }" }) vim.api.nvim_create_autocmd({ "BufDelete", "VimLeave" }, { pattern = "*.tex", command = "!texclear \"%:p\"" }) -- Evil Lualine local colors = require "lvim.core.lualine.colors" 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) > 80 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, } lvim.builtin.lualine.options = { component_separators = '', section_separators = '', theme = { normal = { c = { fg = colors.fg, bg = colors.bg } }, inactive = { c = { fg = colors.fg, bg = colors.bg } }, }, } lvim.builtin.lualine.sections = { lualine_a = {}, lualine_b = {}, lualine_y = {}, lualine_z = {}, lualine_c = {}, lualine_x = {}, } lvim.builtin.lualine.inactive_sections = { lualine_a = {}, lualine_b = {}, lualine_y = {}, lualine_z = {}, lualine_c = {}, lualine_x = {}, } local function ins_left(component) table.insert(lvim.builtin.lualine.sections.lualine_c, component) end local function ins_right(component) table.insert(lvim.builtin.lualine.sections.lualine_x, component) end local function mode_color() local color = { n = colors.red, i = colors.green, v = colors.magenta, [''] = colors.magenta, V = colors.magenta, c = colors.blue, no = colors.red, s = colors.orange, S = colors.orange, [''] = colors.orange, ic = colors.yellow, R = colors.violet, Rv = colors.violet, cv = colors.red, ce = colors.red, r = colors.cyan, rm = colors.cyan, ['r?'] = colors.cyan, ['!'] = colors.red, t = colors.red, } return { fg = color[vim.fn.mode()] } end ins_left { function() return '▊' end, color = function () return mode_color() end, padding = { right = 1 }, } ins_left { function() local msg = 'No Active Lsp' 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 for _, client in ipairs(clients) do local filetypes = client.config.filetypes if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then return client.name end end return msg end, icon = ' LSP:', color = { fg = colors.white, gui = 'bold' }, } ins_left { 'diagnostics', sources = { 'nvim_diagnostic' }, symbols = { error = ' ', warn = ' ', info = ' ' }, diagnostics_color = { color_error = { fg = colors.red }, color_warn = { fg = colors.yellow }, color_info = { fg = colors.cyan }, }, } ins_left { function() return '%=' end, } ins_left { 'filename', cond = conditions.buffer_not_empty, color = { fg = colors.magenta, gui = 'bold' }, } ins_left { 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, color = { fg = colors.yellow, gui = 'bold' } } ins_left { '%04l:%04c', } ins_right { 'o:encoding', fmt = string.upper, cond = conditions.hide_in_width, color = { fg = colors.green, gui = 'bold' }, } ins_right { 'fileformat', fmt = string.upper, icons_enabled = false, color = { fg = colors.green, gui = 'bold' }, } ins_right { 'branch', icon = '', color = { fg = colors.violet, gui = 'bold' }, } ins_right { 'diff', symbols = { added = ' ', modified = '柳 ', removed = ' ' }, diff_color = { added = { fg = colors.green }, modified = { fg = colors.orange }, removed = { fg = colors.red }, }, cond = conditions.hide_in_width, } ins_right { function() return '▊' end, color = function () return mode_color() end, padding = { left = 1 }, } -- Plugins lvim.plugins = { { "folke/tokyonight.nvim" }, { "nacro90/numb.nvim", event = "BufRead", config = function() require("numb").setup { show_numbers = true, show_cursorline = true, } end, }, { "sindrets/diffview.nvim", event = "BufRead", }, { "folke/todo-comments.nvim", event = "BufRead", config = function() require("todo-comments").setup {} end, }, { "felipec/vim-sanegx", event = "BufRead", }, { "ptzz/lf.vim", requires = "voldikss/vim-floaterm", }, { "vimwiki/vimwiki" }, { "norcalli/nvim-colorizer.lua", config = function() require("colorizer").setup({ '*' }, { RGB = true, -- #RGB hex codes RRGGBB = true, -- #RRGGBB hex codes RRGGBBAA = true, -- #RRGGBBAA hex codes rgb_fn = true, -- CSS rgb() and rgba() functions hsl_fn = true, -- CSS hsl() and hsla() functions css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn }) end, }, { "fladson/vim-kitty" }, { "tpope/vim-surround" }, { "tpope/vim-repeat" }, { "svermeulen/vim-easyclip" }, } -- Functions for keymappings function Custom_Close() local num_bufs = #vim.tbl_filter( function(buf) return vim.api.nvim_buf_is_valid(buf) and vim.api.nvim_buf_get_option(buf, 'buflisted') end, vim.api.nvim_list_bufs() ) if num_bufs <= 1 then vim.cmd("quit") end vim.api.nvim_buf_delete(0, {}) end -- keymappings [view all the defaults by pressing Lk] lvim.leader = "space" lvim.keys.insert_mode = { [""] = ":wa", [""] = ":lua Custom_Close()", [""] = "", } lvim.keys.normal_mode = { [""] = ":w", [""] = ":lua Custom_Close()", } lvim.keys.term_mode = { } lvim.keys.visual_mode = { [""] = ":w", [""] = ":lua Custom_Close()", ["<"] = ""] = ">gv", } lvim.keys.visual_block_mode = { [""] = ":w", [""] = ":lua Custom_Close()", ["K"] = ":move '<-2gv-gv", ["J"] = ":move '>+1gv-gv", } lvim.builtin.which_key.mappings = { [";"] = { "Alpha", "Dashboard" }, ["/"] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, ["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" }, ["h"] = { "nohlsearch", "No Highlight" }, ["e"] = { "Lf", "List Files" }, b = { name = "Buffers", j = { "BufferLinePick", "Jump" }, f = { "Telescope buffers", "Find" }, b = { "BufferLineCyclePrev", "Previous" }, c = { "w!!compiler \"%:p\"", "Compile" }, -- w = { "BufferWipeout", "Wipeout" }, -- TODO: implement this for bufferline e = { "BufferLinePickClose", "Pick which buffer to close", }, h = { "BufferLineCloseLeft", "Close all to the left" }, l = { "BufferLineCloseRight", "Close all to the right", }, D = { "BufferLineSortByDirectory", "Sort by directory", }, L = { "BufferLineSortByExtension", "Sort by language", }, }, p = { name = "Packer", c = { "PackerCompile", "Compile" }, i = { "PackerInstall", "Install" }, r = { "lua require('lvim.plugin-loader').recompile()", "Re-compile" }, s = { "PackerSync", "Sync" }, S = { "PackerStatus", "Status" }, u = { "PackerUpdate", "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 = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, l = { "lua require 'gitsigns'.blame_line()", "Blame" }, p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, u = { "lua require 'gitsigns'.undo_stage_hunk()", "Undo Stage Hunk", }, o = { "Telescope git_status", "Open changed file" }, b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope git_commits", "Checkout commit" }, C = { "Telescope git_bcommits", "Checkout commit(for current file)", }, d = { "Gitsigns diffthis HEAD", "Git Diff", }, }, l = { name = "LSP", a = { "lua vim.lsp.buf.code_action()", "Code Action" }, d = { "Telescope diagnostics bufnr=0 theme=get_ivy", "Buffer Diagnostics" }, w = { "Telescope diagnostics", "Diagnostics" }, f = { require("lvim.lsp.utils").format, "Format" }, i = { "LspInfo", "Info" }, I = { "LspInstallInfo", "Installer Info" }, j = { vim.diagnostic.goto_next, "Next Diagnostic", }, k = { vim.diagnostic.goto_prev, "Prev Diagnostic", }, l = { vim.lsp.codelens.run, "CodeLens Action" }, p = { name = "Peek", d = { "lua require('lvim.lsp.peek').Peek('definition')", "Definition" }, t = { "lua require('lvim.lsp.peek').Peek('typeDefinition')", "Type Definition" }, i = { "lua require('lvim.lsp.peek').Peek('implementation')", "Implementation" }, }, q = { vim.diagnostic.setloclist, "Quickfix" }, r = { vim.lsp.buf.rename, "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols", }, e = { "Telescope quickfix", "Telescope Quickfix" }, }, L = { name = "LunarVim", c = { "edit " .. get_config_dir() .. "/config.lua", "Edit config.lua", }, f = { "lua require('lvim.core.telescope.custom-finders').find_lunarvim_files()", "Find LunarVim files", }, g = { "lua require('lvim.core.telescope.custom-finders').grep_lunarvim_files()", "Grep LunarVim files", }, k = { "Telescope keymaps", "View LunarVim's keymappings" }, i = { "lua require('lvim.core.info').toggle_popup(vim.bo.filetype)", "Toggle LunarVim Info", }, I = { "lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog()", "View LunarVim's changelog", }, l = { name = "+logs", d = { "lua require('lvim.core.terminal').toggle_log_view(require('lvim.core.log').get_path())", "view default log", }, D = { "lua vim.fn.execute('edit ' .. require('lvim.core.log').get_path())", "Open the default logfile", }, l = { "lua require('lvim.core.terminal').toggle_log_view(vim.lsp.get_log_path())", "view lsp log", }, L = { "lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())", "Open the LSP logfile" }, n = { "lua require('lvim.core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))", "view neovim log", }, N = { "edit $NVIM_LOG_FILE", "Open the Neovim logfile" }, p = { "lua require('lvim.core.terminal').toggle_log_view(get_cache_dir() .. '/packer.nvim.log')", "view packer log", }, P = { "edit $LUNARVIM_CACHE_DIR/packer.nvim.log", "Open the Packer logfile" }, }, n = { "Telescope notify", "View Notifications" }, r = { "LvimReload", "Reload LunarVim's configuration" }, u = { "LvimUpdate", "Update LunarVim" }, }, s = { name = "Search", b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope colorscheme", "Colorscheme" }, f = { "Telescope find_files", "Find File" }, h = { "Telescope help_tags", "Find Help" }, H = { "Telescope highlights", "Find highlight groups" }, M = { "Telescope man_pages", "Man Pages" }, r = { "Telescope oldfiles", "Open Recent File" }, R = { "Telescope registers", "Registers" }, t = { "Telescope live_grep", "Text" }, k = { "Telescope keymaps", "Keymaps" }, C = { "Telescope commands", "Commands" }, p = { "lua require('telescope.builtin.internal').colorscheme({enable_preview = true})", "Colorscheme with Preview", }, }, T = { name = "Treesitter", i = { ":TSConfigInfo", "Info" }, }, w = { name = "VimWiki" }, z = { name = "Folding" } }