diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 2173f806f..ce35d6629 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,58 +1,19 @@ -require('plugins') -require('keybinds') -require('options') - -require('bufferline').setup({ - options = { - show_buffer_close_icons = false, - show_close_icon = false, - always_show_bufferline = false, - } -}) -require('mason').setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) -require("mason-lspconfig").setup({ - ensure_installed = { "sumneko_lua", "bashls", "clangd" }, - automatic_installation = false -}) -require('tokyonight').setup({ - transparent = true, - terminal_colors = true, - dim_inactive = true, - lualine_bold = true, -}) - - --- set autocmds defined in autocmd.lua -for _, entry in ipairs(require('autocmds')) do - local event = entry[1] - local opts = entry[2] - if type(opts.group) == "string" and opts.group ~= "" then - local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group }) - if not exists then - vim.api.nvim_create_augroup(opts.group, {}) - end - end - vim.api.nvim_create_autocmd(event, opts) -end - --- automatically set up language servers --- local lspconfig = require('lspconfig') --- local mason_registry = require('mason-registry') --- lspconfig.util.default_config = vim.tbl_extend( --- "force", --- lspconfig.util.default_config, --- { --- on_attach = on_attach --- } --- ) --- for _, server in ipairs(require('mason-registry').get_installed_packages()) do --- lspconfig[server.name].setup {} --- end +require 'user.plugins' +require 'user.keybinds' +require 'user.options' +require 'user.autocmds' +require 'user.theme' +require 'user.cmp' +require 'user.plugins.alpha' +require 'user.plugins.autopairs' +require 'user.plugins.bufferline' +require 'user.plugins.comment' +require 'user.plugins.gitsigns' +require 'user.plugins.impatient' +require 'user.plugins.indentline' +require 'user.plugins.lualine' +require 'user.plugins.nvim-tree' +require 'user.plugins.project' +require 'user.plugins.telescope' +require 'user.plugins.toggleterm' +require 'user.plugins.treesitter' diff --git a/.config/nvim/lua/funcs.lua b/.config/nvim/lua/funcs.lua new file mode 100644 index 000000000..e8163840b --- /dev/null +++ b/.config/nvim/lua/funcs.lua @@ -0,0 +1,77 @@ +local M = {} + +-- Common kill function for bdelete and bwipeout +-- credits: based on bbye and nvim-bufdel, stolen from LunarVim +---@param kill_command? string defaults to "bd" +---@param bufnr? number defaults to the current buffer +---@param force? boolean defaults to false +function M.buf_kill(kill_command, bufnr, force) + kill_command = kill_command or "bd" + + local bo = vim.bo + local api = vim.api + local fmt = string.format + local fnamemodify = vim.fn.fnamemodify + + if bufnr == 0 or bufnr == nil then + bufnr = api.nvim_get_current_buf() + end + + local bufname = api.nvim_buf_get_name(bufnr) + + if not force then + local warning + if bo[bufnr].modified then + warning = fmt([[No write since last change for (%s)]], fnamemodify(bufname, ":t")) + elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then + warning = fmt([[Terminal %s will be killed]], bufname) + end + if warning then + vim.ui.input({ + prompt = string.format([[%s. Close it anyway? [y]es or [n]o (default: no): ]], warning), + }, function(choice) + if choice:match "ye?s?" then force = true end + end) + if not force then return end + end + end + + -- Get list of windows IDs with the buffer to close + local windows = vim.tbl_filter(function(win) + return api.nvim_win_get_buf(win) == bufnr + end, api.nvim_list_wins()) + + if #windows == 0 then return end + + if force then + kill_command = kill_command .. "!" + end + + -- Get list of active buffers + local buffers = vim.tbl_filter(function(buf) + return api.nvim_buf_is_valid(buf) and bo[buf].buflisted + end, api.nvim_list_bufs()) + + -- If there is only one buffer (which has to be the current one), vim will + -- create a new buffer on :bd. + -- For more than one buffer, pick the previous buffer (wrapping around if necessary) + if #buffers > 1 then + for i, v in ipairs(buffers) do + if v == bufnr then + local prev_buf_idx = i == 1 and (#buffers - 1) or (i - 1) + local prev_buffer = buffers[prev_buf_idx] + for _, win in ipairs(windows) do + api.nvim_win_set_buf(win, prev_buffer) + end + end + end + end + + -- Check if buffer still exists, to ensure the target buffer wasn't killed + -- due to options like bufhidden=wipe. + if api.nvim_buf_is_valid(bufnr) and bo[bufnr].buflisted then + vim.cmd(string.format("%s %d", kill_command, bufnr)) + end +end + +return M diff --git a/.config/nvim/lua/icons.lua b/.config/nvim/lua/icons.lua new file mode 100644 index 000000000..d0f0cf696 --- /dev/null +++ b/.config/nvim/lua/icons.lua @@ -0,0 +1,154 @@ +return { + kind = { + Array = "", + Boolean = "蘒", + Class = "", + Color = "", + Constant = "", + Constructor = "", + Enum = "", + EnumMember = "", + Event = "", + Field = "", + File = "", + Folder = "", + Function = "", + Interface = "", + Key = "", + Keyword = "", + Method = "", + Module = "", + Namespace = "", + Null = "ﳠ", + Number = "", + Object = "", + Operator = "", + Package = "", + Property = "", + Reference = "", + Snippet = "", + String = "", + Struct = "", + Text = "", + TypeParameter = "", + Unit = "", + Value = "", + Variable = "", + }, + git = { + LineAdded = "", + LineModified = "", + LineRemoved = "", + FileDeleted = "", + FileIgnored = "◌", + FileRenamed = "➜", + FileStaged = "S", + FileUnmerged = "", + FileUnstaged = "", + FileUntracked = "U", + Diff = "", + Repo = "", + Octoface = "", + Branch = "", + }, + ui = { + ArrowCircleDown = "", + ArrowCircleLeft = "", + ArrowCircleRight = "", + ArrowCircleUp = "", + BoldArrowDown = "", + BoldArrowLeft = "", + BoldArrowRight = "", + BoldArrowUp = "", + BoldClose = "", + BoldDividerLeft = "", + BoldDividerRight = "", + BoldLineLeft = "▎", + BookMark = "", + BoxChecked = "", + Bug = "", + Stacks = " ", + Scopes = "", + Watches = "", + DebugConsole = " ", + Calendar = "", + Check = "", + ChevronRight = ">", + ChevronShortDown = "", + ChevronShortLeft = "", + ChevronShortRight = "", + ChevronShortUp = "", + Circle = "", + Close = "", + CloudDownload = "", + Code = "", + Comment = "", + Dashboard = "", + DividerLeft = "", + DividerRight = "", + DoubleChevronRight = "»", + Ellipsis = "…", + EmptyFolder = "", + EmptyFolderOpen = "", + File = "", + FileSymlink = "", + Files = "", + FindFile = "", + FindText = "", + Fire = "", + Folder = "", + FolderOpen = "", + FolderSymlink = "", + Forward = "", + Gear = "", + History = "", + Lightbulb = "", + LineLeft = "▏", + LineMiddle = "│", + List = "", + Lock = "", + NewFile = "", + Note = "", + Package = "", + Pencil = "", + Plus = "", + Project = "", + Search = "", + SignIn = "", + SignOut = "", + Tab = "", + Table = "", + Target = "", + Telescope = "", + Text = "", + Tree = "", + Triangle = "契", + TriangleShortArrowDown = "", + TriangleShortArrowLeft = "", + TriangleShortArrowRight = "", + TriangleShortArrowUp = "", + }, + diagnostics = { + BoldError = "", + Error = "", + BoldWarning = "", + Warning = "", + BoldInformation = "", + Information = "", + BoldQuestion = "", + Question = "", + BoldHint = "", + Hint = "", + Debug = "", + Trace = "✎", + }, + misc = { + Robot = "ﮧ", + Squirrel = "", + Tag = "", + Watch = "", + Smiley = "ﲃ", + Package = "", + CircuitBoard = "", + }, +} diff --git a/.config/nvim/lua/keybinds.lua b/.config/nvim/lua/keybinds.lua deleted file mode 100644 index 515b57348..000000000 --- a/.config/nvim/lua/keybinds.lua +++ /dev/null @@ -1,21 +0,0 @@ -local M = {} -vim.g.mapleader = "space" - -function M.wk_setup() -end - -function M.kb_setup(maps) - local options = { noremap = true } - for mode, binds in ipairs(maps) do - for _, bind in ipairs(binds) do - local key = bind[1] - local cmd = bind[2] - if entry[3] then - opts = rim.tbl_extend("force", options, bind[3]) - end - vim.api.nvim_set_keymap(mode, key, cmd, opts) - end - end -end - -return M diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua deleted file mode 100644 index 789eb7a30..000000000 --- a/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,97 +0,0 @@ -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) - vim.cmd [[packadd packer.nvim]] - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - -local status_ok, packer = pcall(require, "packer") -if not status_ok then - return -end - -packer.init { - display = { - open_fn = function() - return require("packer.util").float { border = "rounded" } - end, - }, -} - -return packer.startup(function(use) - -- General Functionality - use 'wbthomason/packer.nvim' - use 'nvim-lua/plenary.nvim' - use 'windwp/nvim-autopairs' - use 'numToStr/Comment.nvim' - use 'JoosepAlviste/nvim-ts-context-commentstring' - use 'kyazdani42/nvim-web-devicons' - use 'kyazdani42/nvim-tree.lua' - use 'akinsho/bufferline.nvim' - use 'moll/vim-bbye' - use 'nvim-lualine/lualine.nvim' - use 'akinsho/toggleterm.nvim' - use 'ahmedkhalf/project.nvim' - use 'lewis6991/impatient.nvim' - use 'lukas-reineke/indent-blankline.nvim' - use 'goolord/alpha-nvim' - use 'RRethy/vim-illuminate' - use 'nvim-telescope/telescope.nvim' - use 'nvim-treesitter/nvim-treesitter' - use 'lewis6991/gitsigns.nvim' - -- Color Schemes - use 'folke/tokyonight.nvim' - -- Completion - use 'hrsh7th/nvim-cmp' - use 'hrsh7th/cmp-buffer' - use 'hrsh7th/cmp-path' - use 'saadparwaiz1/cmp_luasnip' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/cmp-nvim-lua' --- Snippets - use 'L3MON4D3/LuaSnip' - use 'rafamadriz/friendly-snippets' --- LSP/DAP - use 'williamboman/mason.nvim' - use 'mfussenegger/nvim-dap' - use 'jose-elias-alvarez/null-ls.nvim' - use 'neovim/nvim-lspconfig' - use 'williamboman/mason-lspconfig.nvim' - - - - use 'fladson/vim-kitty' - use 'folke/lua-dev.nvim' - use 'tpope/vim-surround' - use 'tpope/vim-repeat' - use 'norcalli/nvim-colorizer.lua' - use 'vimwiki/vimwiki' - use { - 'folke/which-key.nvim', - config = function() - require('which-key').setup() - require('keybinds').wk_setup() - end - } - use { - } - use { - 'felipec/vim-sanegx', - event = 'BufRead', - } - use { - 'sindrets/diffview.nvim', - event = 'BufRead' - } - use { - } - if packer_bootstrap then - require('packer').sync() - end -end) diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/user/autocmds.lua similarity index 50% rename from .config/nvim/lua/autocmds.lua rename to .config/nvim/lua/user/autocmds.lua index a25f4300f..ce5684abf 100644 --- a/.config/nvim/lua/autocmds.lua +++ b/.config/nvim/lua/user/autocmds.lua @@ -1,12 +1,12 @@ -return { - { +autocmds = { + { -- Handles the automatic line numeration changes { "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, { pattern = "*", - command="if &nu && mode() != \"i\" | set rnu | endif" + command="if &nu && mode() != \"i\" | set rnu | endif" } }, - { + { -- Handles the automatic line numeration changes { "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, { pattern = "*", @@ -22,13 +22,6 @@ return { end } }, - { - "ColorScheme", - { - pattern = "*", - command = "hi FloatermBorder guibg=none" - } - }, { "BufWritePost", { @@ -64,7 +57,31 @@ return { command = "!texclear \"%:p\"" } }, - { + { -- Use 'q' to quit from common plugins + 'FileType', + { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" }, + callback = function() + vim.cmd [[ + nnoremap q :close + set nobuflisted + ]] + end + } + }, + { -- Remove statusline and tabline when in Alpha + 'User', + { + pattern = { "AlphaReady" }, + callback = function() + vim.cmd [[ + set showtabline=0 | autocmd BufUnload set showtabline=2 + set laststatus=0 | autocmd BufUnload set laststatus=3 + ]] + end, + } + }, + { -- Automatically apply changes to plugins.lua 'BufWritePost', { group = 'packer_user_config', @@ -73,3 +90,17 @@ return { } } } + +vim.api.nvim_create_augroup('packer_user_config', {clear = true}) + +for _, entry in ipairs(autocmds) do + local event = entry[1] + local opts = entry[2] + if type(opts.group) == "string" and opts.group ~= "" then + local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group }) + if not exists then + vim.api.nvim_create_augroup(opts.group, {}) + end + end + vim.api.nvim_create_autocmd(event, opts) +end diff --git a/.config/nvim/lua/user/cmp.lua b/.config/nvim/lua/user/cmp.lua new file mode 100644 index 000000000..66b4da2ee --- /dev/null +++ b/.config/nvim/lua/user/cmp.lua @@ -0,0 +1,101 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end + +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") +end + +local kind_icons = require('icons').kind +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }), + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + vim_item.kind = kind_icons[vim_item.kind] + vim_item.menu = ({ + nvim_lsp = "", + nvim_lua = "", + luasnip = "", + buffer = "", + path = "", + emoji = "", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, +}) diff --git a/.config/nvim/lua/user/keybinds.lua b/.config/nvim/lua/user/keybinds.lua new file mode 100644 index 000000000..6e013f096 --- /dev/null +++ b/.config/nvim/lua/user/keybinds.lua @@ -0,0 +1,77 @@ +local opts = { silent = true, noremap=true } + +vim.g.mapleader = "space" + +maps = { + n = { -- normal mode + -- Better window navigation + {"", "h", opts}, + {"", "j", opts}, + {"", "k", opts}, + {"", "l", opts}, + -- Resize with arrows + {"", ":resize -2", opts}, + {"", ":resize +2", opts}, + {"", ":vertical resize -2", opts}, + {"", ":vertical resize +2", opts}, + -- Navigate buffers + {"", ":bnext", opts}, + {"", ":bprevious", opts}, + -- Clear highlights + {"h", "nohlsearch", opts}, + -- Close buffers + {"", "Bdelete!", opts}, + -- NvimTree + {"e", ":NvimTreeToggle", opts}, + -- Telescope + {"ff", ":Telescope find_files", opts}, + {"ft", ":Telescope live_grep", opts}, + {"fp", ":Telescope projects", opts}, + {"fb", ":Telescope buffers", opts}, + -- Git + {"gg", "lua _LAZYGIT_TOGGLE()", opts}, + -- Comment + {"/", "lua require('Comment.api').toggle_current_linewise()", opts}, + -- DAP + {"db", "lua require'dap'.toggle_breakpoint()", opts}, + {"dc", "lua require'dap'.continue()", opts}, + {"di", "lua require'dap'.step_into()", opts}, + {"do", "lua require'dap'.step_over()", opts}, + {"dO", "lua require'dap'.step_out()", opts}, + {"dr", "lua require'dap'.repl.toggle()", opts}, + {"dl", "lua require'dap'.run_last()", opts}, + {"du", "lua require'dapui'.toggle()", opts}, + {"dt", "lua require'dap'.terminate()", opts}, + -- Illuminate + {'', 'lua require"illuminate".next_reference{wrap=true}', opts}, + {'', 'lua require"illuminate".next_reference{reverse=true,wrap=true}', opts}, + }, + i = { -- insert mode + }, + v = { -- visual mode + -- Better paste + {"p", '"_dP'}, + -- Stay in indent mode + {"<", "", ">gv"}, + }, + x = { -- visual block mode + -- Comment + {"/", 'lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())', opts}, + }, + t = { -- terminal mode + }, + c = { -- command mode + } +} + +for mode, binds in ipairs(maps) do + for _, bind in ipairs(binds) do + local key = bind[1] + local cmd = bind[2] + if entry[3] then + local opt = entry[3] + end + vim.api.nvim_set_keymap(mode, key, cmd, opt) + end +end diff --git a/.config/nvim/lua/user/lsp/TODO b/.config/nvim/lua/user/lsp/TODO new file mode 100644 index 000000000..6ee878667 --- /dev/null +++ b/.config/nvim/lua/user/lsp/TODO @@ -0,0 +1,15 @@ +TODO: mason, lsp and dap setup +require('mason').setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } +}) +require("mason-lspconfig").setup({ + ensure_installed = { "sumneko_lua", "bashls", "clangd" }, + automatic_installation = false +}) + diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/user/lsp/handlers.lua new file mode 100644 index 000000000..f8b097293 --- /dev/null +++ b/.config/nvim/lua/user/lsp/handlers.lua @@ -0,0 +1,92 @@ +local M = {} + +local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_cmp_ok then + return +end + +local icons = require "icons" + +M.capabilities = vim.lsp.protocol.make_client_capabilities() +M.capabilities.textDocument.completion.completionItem.snippetSupport = true +M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) + +M.setup = function() + local signs = { + { name = "DiagnosticSignError", text = icons.diagnostics.BoldError }, + { name = "DiagnosticSignWarn", text = icons.diagnostics.BoldWarning }, + { name = "DiagnosticSignHint", text = icons.diagnostics.BoldHint }, + { name = "DiagnosticSignInfo", text = icons.diagnostics.BoldInformation }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + virtual_text = false, -- disable virtual text + signs = { + active = signs, -- show signs + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + local keymap = vim.api.nvim_buf_set_keymap + keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) + keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) + keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) + keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) + keymap(bufnr, "n", "lf", "lua vim.lsp.buf.formatting()", opts) + keymap(bufnr, "n", "li", "LspInfo", opts) + keymap(bufnr, "n", "lI", "LspInstallInfo", opts) + keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) + keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) + keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) + keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) + keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) + keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.resolved_capabilities.document_formatting = false + end + + if client.name == "sumneko_lua" then + client.resolved_capabilities.document_formatting = false + end + + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +end + +return M diff --git a/.config/nvim/lua/user/lsp/null-ls.lua b/.config/nvim/lua/user/lsp/null-ls.lua new file mode 100644 index 000000000..3f24587b6 --- /dev/null +++ b/.config/nvim/lua/user/lsp/null-ls.lua @@ -0,0 +1,24 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting +local formatting = null_ls.builtins.formatting +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics +local diagnostics = null_ls.builtins.diagnostics + +-- https://github.com/prettier-solidity/prettier-plugin-solidity +null_ls.setup { + debug = false, + sources = { + formatting.prettier.with { + extra_filetypes = { "toml" }, + extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" }, + }, + formatting.black.with { extra_args = { "--fast" } }, + formatting.stylua, + formatting.google_java_format, + diagnostics.flake8, + }, +} diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/user/options.lua similarity index 94% rename from .config/nvim/lua/options.lua rename to .config/nvim/lua/user/options.lua index 79ca6c6af..ae333a10b 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/user/options.lua @@ -1,4 +1,3 @@ -vim.cmd[[colorscheme tokyonight]] vim.opt.undodir = vim.fn.stdpath "cache" .. "/undo" vim.opt.clipboard = "unnamedplus" vim.opt.conceallevel = 0 @@ -31,3 +30,4 @@ vim.opt.foldexpr = "nvim_treesitter#foldexpr()" vim.opt.number = true vim.opt.relativenumber = true +vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree'} diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua new file mode 100644 index 000000000..c25d2c5b8 --- /dev/null +++ b/.config/nvim/lua/user/plugins.lua @@ -0,0 +1,78 @@ +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +local packer_bootstrap = ensure_packer() + +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, +} + +return packer.startup(function(use) + -- General Functionality + use 'wbthomason/packer.nvim' + use 'nvim-lua/plenary.nvim' + use 'windwp/nvim-autopairs' + use 'numToStr/Comment.nvim' + use 'JoosepAlviste/nvim-ts-context-commentstring' + use 'kyazdani42/nvim-web-devicons' + use 'kyazdani42/nvim-tree.lua' + use 'akinsho/bufferline.nvim' + use 'moll/vim-bbye' + use 'nvim-lualine/lualine.nvim' + use 'akinsho/toggleterm.nvim' + use 'ahmedkhalf/project.nvim' + use 'lewis6991/impatient.nvim' + use 'lukas-reineke/indent-blankline.nvim' + use 'goolord/alpha-nvim' + use 'RRethy/vim-illuminate' + use 'nvim-telescope/telescope.nvim' + use 'nvim-treesitter/nvim-treesitter' + use 'lewis6991/gitsigns.nvim' + use 'folke/lua-dev.nvim' + use 'tpope/vim-surround' + use 'tpope/vim-repeat' + use 'norcalli/nvim-colorizer.lua' + use 'vimwiki/vimwiki' + use 'folke/which-key.nvim' + use 'felipec/vim-sanegx' + use 'sindrets/diffview.nvim' + -- Color Schemes + use 'folke/tokyonight.nvim' + -- Completion + use 'hrsh7th/nvim-cmp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-path' + use 'saadparwaiz1/cmp_luasnip' + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-nvim-lua' + -- Snippets + use 'L3MON4D3/LuaSnip' + use 'rafamadriz/friendly-snippets' + -- LSP/DAP + use 'williamboman/mason.nvim' + use 'mfussenegger/nvim-dap' + use 'jose-elias-alvarez/null-ls.nvim' + use 'neovim/nvim-lspconfig' + use 'williamboman/mason-lspconfig.nvim' + + if packer_bootstrap then + require('packer').sync() + end + end) diff --git a/.config/nvim/lua/user/plugins/alpha.lua b/.config/nvim/lua/user/plugins/alpha.lua new file mode 100644 index 000000000..13a215215 --- /dev/null +++ b/.config/nvim/lua/user/plugins/alpha.lua @@ -0,0 +1,57 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local dashboard = require 'alpha.themes.dashboard' +local icons = require 'icons' + +local banner = { + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣶⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀", + "⠀⣀⣴⣶⣶⣶⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀", + "⣰⣿⣿⠿⠛⠿⢿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀", + "⣿⣿⡇⠀⠀⠀⠀⠈⠛⢿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀", + "⠹⣿⣧⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⡿⠛⠉⠀⢀⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀", + "⠀⠙⢿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⣤⣶⣿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠉⠻⠷⡄⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠉⠀⢀⣠⣤⣤⣄⡀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣷⡀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⡀⠀⠀⠀⠀⣿⠟⠉⠉⠙⢿⣿⣿⣷", + "⠀⠀⠀⣀⣠⣤⣤⣤⣶⣶⣶⣤⣤⠀⣴⣿⣿⣿⡿⠟⠛⠛⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠉⠀⠀⠀⢀⣼⣿⣿⡿", + "⠀⠀⠀⠈⠉⠉⠉⠉⠉⠉⠛⠻⠏⣼⣿⣿⡿⣋⣀⣤⣤⣴⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣀⣠⣴⣾⣿⣿⡿⠁", + "⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡿⠋⠘⠿⠟⠛⠛⢻⣿⣿⣿⠋⠁⠈⠉⢿⣿⣿⣧⠀⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠉⠀⠀", + "⠙⣷⣤⣀⠀⠀⠀⢀⣀⣤⣶⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡟⠀⠀⠀⢠⣿⣿⣿⡟⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀", + "⠀⠈⠛⠿⢿⣿⣿⣿⠿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⡀⠀⢠⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣷⣶⣶⣶⣶⣦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣙⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⢶⣦⣤⣶⣾⣿⣿⡶⠈⠉⠛⠿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", + "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⣶⡿⠿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +} + +if vim.o.lines < 36 then + banner = vim.list_slice(banner, 16, 22) +end + +dashboard.section.header.val = banner + +dashboard.section.buttons.val = { + dashboard.button("f", icons.ui.FindFile .. " Find file", ":Telescope find_files "), + dashboard.button("e", icons.ui.NewFile .. " New file", ":ene startinsert "), + dashboard.button("p", icons.ui.Project .. " Find project", ":lua require('telescope').extensions.projects.projects()"), + dashboard.button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles "), + dashboard.button("t", icons.ui.FindText .. " Find text", ":Telescope live_grep "), + dashboard.button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua "), + dashboard.button("q", icons.ui.SignOut .. " Quit", ":qa"), +} + +dashboard.section.footer.val = "Behold: a Snail's Vim" + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +alpha.setup(dashboard.opts) diff --git a/.config/nvim/lua/user/plugins/autopairs.lua b/.config/nvim/lua/user/plugins/autopairs.lua new file mode 100644 index 000000000..39cfd9ce7 --- /dev/null +++ b/.config/nvim/lua/user/plugins/autopairs.lua @@ -0,0 +1,17 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup { + check_ts = true, -- treesitter integration + disable_filetype = { "TelescopePrompt" }, +} + +local cmp_autopairs = require "nvim-autopairs.completion.cmp" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done {}) diff --git a/.config/nvim/lua/user/plugins/bufferline.lua b/.config/nvim/lua/user/plugins/bufferline.lua new file mode 100644 index 000000000..8e8b5ca7c --- /dev/null +++ b/.config/nvim/lua/user/plugins/bufferline.lua @@ -0,0 +1,140 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +end + +local function is_ft(b, ft) + return vim.bo[b].filetype == ft +end + +local icons = require 'icons' + +local config = { + highlights = { + background = { + italic = true, + }, + buffer_selected = { + bold = true, + }, + }, + options = { + mode = "buffers", -- set to "tabs" to only show tabpages instead + numbers = "none", -- can be "none" | "ordinal" | "buffer_id" | "both" | function + close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "vert sbuffer %d", -- can be a string | function, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + indicator = { + icon = icons.ui.BoldLineLeft, -- this should be omitted if indicator style is not 'icon' + style = "icon", -- can also be 'underline'|'none', + }, + buffer_close_icon = icons.ui.Close, + modified_icon = icons.ui.Circle, + close_icon = icons.ui.BoldClose, + left_trunc_marker = icons.ui.ArrowCircleLeft, + right_trunc_marker = icons.ui.ArrowCircleRight, + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- remove extension from markdown files for example + if buf.name:match "%.md" then + return vim.fn.fnamemodify(buf.name, ":t:r") + end + end, + max_name_length = 18, + max_prefix_length = 15, -- prefix used when a buffer is de-duplicated + truncate_names = true, -- whether or not tab names should be truncated + tab_size = 18, + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = false, + diagnostics_indicator = diagnostics_indicator, + -- NOTE: this will be called a lot so don't do any heavy processing here + custom_filter = custom_filter, + offsets = { + { + filetype = "undotree", + text = "Undotree", + highlight = "PanelHeading", + padding = 1, + }, + { + filetype = "NvimTree", + text = "Explorer", + highlight = "PanelHeading", + padding = 1, + }, + { + filetype = "DiffviewFiles", + text = "Diff View", + highlight = "PanelHeading", + padding = 1, + }, + { + filetype = "flutterToolsOutline", + text = "Flutter Outline", + highlight = "PanelHeading", + }, + { + filetype = "packer", + text = "Packer", + highlight = "PanelHeading", + padding = 1, + }, + }, + color_icons = true, -- whether or not to add the filetype icon highlights + show_buffer_icons = true, -- disable filetype icons for buffers + show_buffer_close_icons = false, + show_close_icon = false, + show_tab_indicators = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", + enforce_regular_tabs = false, + always_show_bufferline = false, + hover = { + enabled = false, -- requires nvim 0.8+ + delay = 200, + reveal = { "close" }, + }, + sort_by = "id", + }, +} + +local function diagnostics_indicator(num, _, diagnostics, _) + local result = {} + local symbols = { + error = icons.diagnostics.Error, + warning = icons.diagnostics.Warning, + info = icons.diagnostics.Info, + } + for name, count in pairs(diagnostics) do + if symbols[name] and count > 0 then + table.insert(result, symbols[name] .. " " .. count) + end + end + result = table.concat(result, " ") + return #result > 0 and result or "" +end + +local function custom_filter(buf, buf_nums) + local logs = vim.tbl_filter(function(b) + return is_ft(b, "log") + end, buf_nums) + if vim.tbl_isempty(logs) then + return true + end + local tab_num = vim.fn.tabpagenr() + local last_tab = vim.fn.tabpagenr "$" + local is_log = is_ft(buf, "log") + if last_tab == 1 then + return true + end + -- only show log buffers in secondary tabs + return (tab_num == last_tab and is_log) or (tab_num ~= last_tab and not is_log) +end + +bufferline.setup(config) diff --git a/.config/nvim/lua/user/plugins/comment.lua b/.config/nvim/lua/user/plugins/comment.lua new file mode 100644 index 000000000..2fa4a564e --- /dev/null +++ b/.config/nvim/lua/user/plugins/comment.lua @@ -0,0 +1,22 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + return +end + +comment.setup { + pre_hook = function(ctx) + local U = require "Comment.utils" + + local location = nil + if ctx.ctype == U.ctype.block then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring { + key = ctx.ctype == U.ctype.line and "__default" or "__multiline", + location = location, + } + end, +} diff --git a/.config/nvim/lua/user/plugins/gitsigns.lua b/.config/nvim/lua/user/plugins/gitsigns.lua new file mode 100644 index 000000000..37cb837a4 --- /dev/null +++ b/.config/nvim/lua/user/plugins/gitsigns.lua @@ -0,0 +1,14 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + return +end + +gitsigns.setup { + 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" }, + }, +} diff --git a/.config/nvim/lua/user/plugins/impatient.lua b/.config/nvim/lua/user/plugins/impatient.lua new file mode 100644 index 000000000..84419e075 --- /dev/null +++ b/.config/nvim/lua/user/plugins/impatient.lua @@ -0,0 +1,6 @@ +local status_ok, impatient = pcall(require, "impatient") +if not status_ok then + return +end + +impatient.enable_profile() diff --git a/.config/nvim/lua/user/plugins/indentline.lua b/.config/nvim/lua/user/plugins/indentline.lua new file mode 100644 index 000000000..b7389d938 --- /dev/null +++ b/.config/nvim/lua/user/plugins/indentline.lua @@ -0,0 +1,18 @@ +local status_ok, indent_blankline = pcall(require, "indent_blankline") +if not status_ok then + return +end + +indent_blankline.setup { + char = "▏", + show_trailing_blankline_indent = false, + show_first_indent_level = true, + use_treesitter = true, + show_current_context = true, + buftype_exclude = { "terminal", "nofile" }, + filetype_exclude = { + "help", + "packer", + "NvimTree", + }, +} diff --git a/.config/nvim/lua/lualine.lua b/.config/nvim/lua/user/plugins/lualine.lua similarity index 100% rename from .config/nvim/lua/lualine.lua rename to .config/nvim/lua/user/plugins/lualine.lua diff --git a/.config/nvim/lua/user/plugins/nvim-tree.lua b/.config/nvim/lua/user/plugins/nvim-tree.lua new file mode 100644 index 000000000..73b7157bc --- /dev/null +++ b/.config/nvim/lua/user/plugins/nvim-tree.lua @@ -0,0 +1,68 @@ +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback +local icons = require 'icons' + +nvim_tree.setup { + update_focused_file = { + enable = true, + update_cwd = true, + }, + renderer = { + root_folder_modifier = ":t", + icons = { + glyphs = { + default = icons.ui.File, + symlink = icons.ui.FileSymlink, + folder = { + arrow_open = ChevronShortDown, + arrow_closed = ChevronShortRight, + default = icons.ui.Folder, + open = icons.ui.FolderOpen, + empty = icons.ui.EmptyFolder, + empty_open = icons.ui.EmptyFolderOpen, + symlink = icons.ui.FolderSymlink, + symlink_open = icons.ui.FolderSymlink, + }, + git = { + unstaged = icons.git.FileUnstaged, + staged = icons.git.FileStaged, + unmerged = icons.git.FileUnmerged, + renamed = icons.git.FileRenamed, + untracked = icons.git.FileUntracked, + deleted = icons.git.FileDeleted, + ignored = icons.git.FileIgnored, + }, + }, + }, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = icons.diagnostics.BoldHint, + info = icons.diagnostics.BoldInformation, + warning = icons.diagnostics.BoldWarning, + error = icons.diagnostics.BoldError, + }, + }, + view = { + width = 30, + side = "left", + mappings = { + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + }, +} diff --git a/.config/nvim/lua/user/plugins/project.lua b/.config/nvim/lua/user/plugins/project.lua new file mode 100644 index 000000000..fb8e59182 --- /dev/null +++ b/.config/nvim/lua/user/plugins/project.lua @@ -0,0 +1,19 @@ +local status_ok, project = pcall(require, "project_nvim") +if not status_ok then + return +end +project.setup({ + + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, + + -- patterns used to detect root dir, when **"pattern"** is in detection_methods + patterns = { ".git", "Makefile", "package.json" }, +}) + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('projects') diff --git a/.config/nvim/lua/user/plugins/telescope.lua b/.config/nvim/lua/user/plugins/telescope.lua new file mode 100644 index 000000000..6ac64d89e --- /dev/null +++ b/.config/nvim/lua/user/plugins/telescope.lua @@ -0,0 +1,26 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +local actions = require "telescope.actions" +local icons = require "icons" + +telescope.setup { + defaults = { + + prompt_prefix = icons.ui.Telescope, + selection_caret = icons.ui.Forward, + path_display = { "smart" }, + file_ignore_patterns = { ".git/", "node_modules" }, + + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }, +} diff --git a/.config/nvim/lua/user/plugins/toggleterm.lua b/.config/nvim/lua/user/plugins/toggleterm.lua new file mode 100644 index 000000000..a633c6120 --- /dev/null +++ b/.config/nvim/lua/user/plugins/toggleterm.lua @@ -0,0 +1,39 @@ +local status_ok, toggleterm = pcall(require, "toggleterm") +if not status_ok then + return +end + +toggleterm.setup({ + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + }, +}) + +function _G.set_terminal_keymaps() + local opts = {noremap = true} + -- vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +local Terminal = require("toggleterm.terminal").Terminal +local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) + +function _LAZYGIT_TOGGLE() + lazygit:toggle() +end diff --git a/.config/nvim/lua/user/plugins/treesitter.lua b/.config/nvim/lua/user/plugins/treesitter.lua new file mode 100644 index 000000000..a5762ebba --- /dev/null +++ b/.config/nvim/lua/user/plugins/treesitter.lua @@ -0,0 +1,17 @@ +local status_ok, configs = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +configs.setup({ + ensure_installed = "all", -- one of "all" or a list of languages + ignore_install = { "" }, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = { "css" }, -- list of language that will be disabled + }, + autopairs = { + enable = true, + }, + indent = { enable = true, disable = { "python", "css" } }, +}) diff --git a/.config/nvim/lua/user/theme.lua b/.config/nvim/lua/user/theme.lua new file mode 100644 index 000000000..fd273bcab --- /dev/null +++ b/.config/nvim/lua/user/theme.lua @@ -0,0 +1,12 @@ +local status_ok, tokyonight = pcall(require, 'tokyonight') +if not status_ok then + return +end + +tokyonight.setup({ + transparent = true, + terminal_colors = true, + dim_inactive = true, + lualine_bold = true, +}) +vim.cmd[[colorscheme tokyonight]] diff --git a/.config/nvim/lua/util.lua b/.config/nvim/lua/util.lua deleted file mode 100644 index 575083d4b..000000000 --- a/.config/nvim/lua/util.lua +++ /dev/null @@ -1,26 +0,0 @@ -local M = {} -vim.g.mapleader = "space" - -local function map(maps) - local options = { noremap = true } - for mode, binds in ipairs(maps) do - for _, bind in ipairs(binds) do - local key = bind[1] - local cmd = bind[2] - if entry[3] then - opts = rim.tbl_extend("force", options, bind[3]) - end - vim.api.nvim_set_keymap(mode, key, cmd, opts) - end - end -end - -function M.wk_setup() - -end - -function M.kb_setup() - -end - -return M diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index f002bf678..0cab66221 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -74,23 +74,76 @@ end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { + ["Comment.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + LuaSnip = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["alpha-nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/alpha-nvim", + url = "https://github.com/goolord/alpha-nvim" + }, ["bufferline.nvim"] = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/bufferline.nvim", url = "https://github.com/akinsho/bufferline.nvim" }, + ["cmp-buffer"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, ["diffview.nvim"] = { - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/luca/.local/share/nvim/site/pack/packer/opt/diffview.nvim", + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/diffview.nvim", url = "https://github.com/sindrets/diffview.nvim" }, + ["friendly-snippets"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, ["gitsigns.nvim"] = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", url = "https://github.com/lewis6991/gitsigns.nvim" }, + ["impatient.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/impatient.nvim", + url = "https://github.com/lewis6991/impatient.nvim" + }, + ["indent-blankline.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, ["lua-dev.nvim"] = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/lua-dev.nvim", @@ -111,11 +164,31 @@ _G.packer_plugins = { path = "/home/luca/.local/share/nvim/site/pack/packer/start/mason.nvim", url = "https://github.com/williamboman/mason.nvim" }, + ["null-ls.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["nvim-autopairs"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, ["nvim-colorizer.lua"] = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua", url = "https://github.com/norcalli/nvim-colorizer.lua" }, + ["nvim-dap"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-dap", + url = "https://github.com/mfussenegger/nvim-dap" + }, ["nvim-lspconfig"] = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", @@ -131,6 +204,11 @@ _G.packer_plugins = { path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-treesitter", url = "https://github.com/nvim-treesitter/nvim-treesitter" }, + ["nvim-ts-context-commentstring"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-ts-context-commentstring", + url = "https://github.com/JoosepAlviste/nvim-ts-context-commentstring" + }, ["nvim-web-devicons"] = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", @@ -146,16 +224,35 @@ _G.packer_plugins = { path = "/home/luca/.local/share/nvim/site/pack/packer/start/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" }, + ["project.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/project.nvim", + url = "https://github.com/ahmedkhalf/project.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["toggleterm.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/toggleterm.nvim", + url = "https://github.com/akinsho/toggleterm.nvim" + }, ["tokyonight.nvim"] = { - config = { "\27LJ\2\n\1\0\0\3\0\a\0\v6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\0016\0\4\0009\0\5\0'\2\6\0B\0\2\1K\0\1\0\27colorscheme tokyonight\bcmd\bvim\1\0\4\17lualine_bold\2\17dim_inactive\2\20terminal_colors\2\16transparent\2\nsetup\15tokyonight\frequire\0" }, loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/tokyonight.nvim", url = "https://github.com/folke/tokyonight.nvim" }, - ["vim-kitty"] = { + ["vim-bbye"] = { loaded = true, - path = "/home/luca/.local/share/nvim/site/pack/packer/start/vim-kitty", - url = "https://github.com/fladson/vim-kitty" + path = "/home/luca/.local/share/nvim/site/pack/packer/start/vim-bbye", + url = "https://github.com/moll/vim-bbye" + }, + ["vim-illuminate"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/vim-illuminate", + url = "https://github.com/RRethy/vim-illuminate" }, ["vim-repeat"] = { loaded = true, @@ -163,10 +260,8 @@ _G.packer_plugins = { url = "https://github.com/tpope/vim-repeat" }, ["vim-sanegx"] = { - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/luca/.local/share/nvim/site/pack/packer/opt/vim-sanegx", + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/vim-sanegx", url = "https://github.com/felipec/vim-sanegx" }, ["vim-surround"] = { @@ -178,21 +273,15 @@ _G.packer_plugins = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/vimwiki", url = "https://github.com/vimwiki/vimwiki" + }, + ["which-key.nvim"] = { + loaded = true, + path = "/home/luca/.local/share/nvim/site/pack/packer/start/which-key.nvim", + url = "https://github.com/folke/which-key.nvim" } } time([[Defining packer_plugins]], false) --- Config for: tokyonight.nvim -time([[Config for tokyonight.nvim]], true) -try_loadstring("\27LJ\2\n\1\0\0\3\0\a\0\v6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\0016\0\4\0009\0\5\0'\2\6\0B\0\2\1K\0\1\0\27colorscheme tokyonight\bcmd\bvim\1\0\4\17lualine_bold\2\17dim_inactive\2\20terminal_colors\2\16transparent\2\nsetup\15tokyonight\frequire\0", "config", "tokyonight.nvim") -time([[Config for tokyonight.nvim]], false) -vim.cmd [[augroup packer_load_aucmds]] -vim.cmd [[au!]] - -- Event lazy-loads -time([[Defining lazy-load event autocommands]], true) -vim.cmd [[au BufRead * ++once lua require("packer.load")({'vim-sanegx', 'diffview.nvim'}, { event = "BufRead *" }, _G.packer_plugins)]] -time([[Defining lazy-load event autocommands]], false) -vim.cmd("augroup END") _G._packer.inside_compile = false if _G._packer.needs_bufread == true then diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc index 5bdb639b8..d6f6cf746 100644 --- a/.config/shell/aliasrc +++ b/.config/shell/aliasrc @@ -49,7 +49,7 @@ alias \ ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \ weath="less -S ${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" \ remvirt="virt-manager -c 'qemu+ssh://luca@192.168.178.200/system'" \ - vim="lvim" \ + vim="nvim" \ wikidown='rclone sync cloud:files/luca/Notes ~/Documents/vimwiki' \ wikiup='rclone sync ~/Documents/vimwiki cloud:files/luca/Notes' \ cam="mpv --untimed --no-cache --no-osc --no-input-default-bindings --profile=low-latency --input-conf=/dev/null --title=webcam $(ls /dev/video[0,2,4,6,8] | tail -n 1)" \