refactored my nvim config into chris, and started adding lazy by folke (mostly there, needs keys and a bit of config still)

This commit is contained in:
Solomon Laing 2023-01-08 00:01:02 +10:30
parent 39df20ed1f
commit 62f9d0c757
74 changed files with 1828 additions and 83 deletions

View File

@ -1,41 +1,2 @@
-- require "user.bufferline" -- unused
-- require "user.noice" -- unused
-- require "user.winbar" -- top bar, unused
require "user.impatient" -- good leading
require "user.options" -- my options
require "user.keymaps" -- misc keymaps not part of whichkey
require "user.plugins" -- plugins configuration (packer)
require "user.colorscheme" -- my choice of colorscheme
require "user.lsp" -- lsp configuration
require "user.alpha" -- start/home page for nvim
require "user.autocmd" -- custom autocmds
require "user.autopairs" -- automatically add parirs for brackens quotes etc
require "user.cmp" -- completion configuration
require "user.colorizer" -- highlight colors hexcodes etc
require "user.comment" -- better commenting
require "user.dressing" -- better ui
require "user.dial" -- better incrementing/decrementing
require "user.fidget" -- display lsp server progress
require "user.functions" -- custom functions
require "user.gitsigns" -- gitsigns integration
require "user.harpoon" -- mark files in project and pull them too you
require "user.indentline" -- show indentation levels for code blocks
require "user.lualine" -- pretty and nice statusline plugin
require "user.navic" -- lsp integrated location in code finder/printer
require "user.notify" -- display notifications nicer
require "user.numb" -- peek before you move :10 etc.
require "user.nvim-tree" -- file tree, when needed.
require "user.symbols-outline" -- navigate code symbols
require "user.telescope" -- nice.
require "user.todo-comments" -- highlight TODO and other related comments
require "user.treesitter" -- magic
require "user.whichkey" -- keymaps
require "user.spectre" -- renaming but better
require "user.cybu" -- cycle through current buffers
require "user.dap" -- debugging
require "user.lspsaga" -- bit overkill, using for code action menu
require "user.neogen" -- annotation/doc generator
-- winbar plugin aint working with navic, this could, but I'm using lualine.
-- vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
--require "lazy" -- my config based on folkes LazyVim starter
require("chris") -- my config based on Christian Chiarullis work

View File

@ -11,7 +11,7 @@ local function button(sc, txt, key, key_opts)
return b
end
local icons = require"user.icons"
local icons = require"chris.icons"
dashboard.section.header.val = {
[[ , __ ___ __. _ __ ` , _ , _ ]],

View File

@ -33,7 +33,7 @@ local check_backspace = function()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
end
local icons = require "user.icons"
local icons = require "chris.icons"
local kind_icons = icons.kind

View File

@ -67,7 +67,7 @@ dapui.setup({
},
})
local icons = require("user.icons")
local icons = require("chris.icons")
vim.fn.sign_define("DapBreakpoint", { text = icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "" })

View File

@ -0,0 +1,38 @@
-- require "chris.bufferline" -- unused
-- require "chris.noice" -- unused
-- require "chris.winbar" -- top bar, unused
require "chris.impatient" -- good leading
require "chris.options" -- my options
require "chris.keymaps" -- misc keymaps not part of whichkey
require "chris.plugins" -- plugins configuration (packer)
require "chris.colorscheme" -- my choice of colorscheme
require "chris.lsp" -- lsp configuration
require "chris.alpha" -- start/home page for nvim
require "chris.autocmd" -- custom autocmds
require "chris.autopairs" -- automatically add parirs for brackens quotes etc
require "chris.cmp" -- completion configuration
require "chris.colorizer" -- highlight colors hexcodes etc
require "chris.comment" -- better commenting
require "chris.dressing" -- better ui
require "chris.dial" -- better incrementing/decrementing
require "chris.fidget" -- display lsp server progress
require "chris.functions" -- custom functions
require "chris.gitsigns" -- gitsigns integration
require "chris.harpoon" -- mark files in project and pull them too you
require "chris.indentline" -- show indentation levels for code blocks
require "chris.lualine" -- pretty and nice statusline plugin
require "chris.navic" -- lsp integrated location in code finder/printer
require "chris.notify" -- display notifications nicer
require "chris.numb" -- peek before you move :10 etc.
require "chris.nvim-tree" -- file tree, when needed.
require "chris.symbols-outline" -- navigate code symbols
require "chris.telescope" -- nice.
require "chris.todo-comments" -- highlight TODO and other related comments
require "chris.treesitter" -- magic
require "chris.whichkey" -- keymaps
require "chris.spectre" -- renaming but better
require "chris.cybu" -- cycle through current buffers
require "chris.dap" -- debugging
require "chris.lspsaga" -- bit overkill, using for code action menu
require "chris.neogen" -- annotation/doc generator

View File

@ -12,7 +12,7 @@ M.capabilities.textDocument.completion.completionItem.snippetSupport = true
M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities)
M.setup = function()
local icons = require("user.icons")
local icons = require("chris.icons")
local signs = {
{ name = "DiagnosticSignError", text = icons.diagnostics.Error },
{ name = "DiagnosticSignWarn", text = icons.diagnostics.Warning },
@ -121,6 +121,6 @@ function M.remove_augroup(name)
end
end
vim.cmd([[ command! LspToggleAutoFormat execute 'lua require("user.lsp.handlers").toggle_format_on_save()' ]])
vim.cmd([[ command! LspToggleAutoFormat execute 'lua require("chris.lsp.handlers").toggle_format_on_save()' ]])
return M

View File

@ -7,10 +7,10 @@ if not status_ok then
end
-- may add signature in future.
-- require "user.lsp.lsp-signature"
require "user.lsp.mason"
require "user.lsp.handlers".setup()
require "user.lsp.null-ls"
-- require "chris.lsp.lsp-signature"
require "chris.lsp.mason"
require "chris.lsp.handlers".setup()
require "chris.lsp.null-ls"
local l_status_ok, lsp_lines = pcall(require, "lsp_lines")
if not l_status_ok then

View File

@ -66,41 +66,41 @@ local opts = {}
for _, server in pairs(servers) do
opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
on_attach = require("chris.lsp.handlers").on_attach,
capabilities = require("chris.lsp.handlers").capabilities,
}
server = vim.split(server, "@", {})[1]
if server == "yamlls" then
local yamlls_opts = require("user.lsp.settings.yamlls")
local yamlls_opts = require("chris.lsp.settings.yamlls")
opts = vim.tbl_deep_extend("force", yamlls_opts, opts)
end
if server == "sumneko_lua" then
lspconfig.sumneko_lua.setup({
on_attach = require("user.lsp.handlers").on_attach,
on_attach = require("chris.lsp.handlers").on_attach,
})
goto continue
end
if server == "tsserver" then
local tsserver_opts = require("user.lsp.settings.tsserver")
local tsserver_opts = require("chris.lsp.settings.tsserver")
opts = vim.tbl_deep_extend("force", tsserver_opts, opts)
end
if server == "clangd" then
local clangd_opts = require("user.lsp.settings.clangd")
local clangd_opts = require("chris.lsp.settings.clangd")
opts = vim.tbl_deep_extend("force", clangd_opts, opts)
end
if server == "emmet_ls" then
local emmet_ls_opts = require("user.lsp.settings.emmet_ls")
local emmet_ls_opts = require("chris.lsp.settings.emmet_ls")
opts = vim.tbl_deep_extend("force", emmet_ls_opts, opts)
end
if server == "rust_analyzer" then
local rust_opts = require("user.lsp.settings.rust")
local rust_opts = require("chris.lsp.settings.rust")
-- opts = vim.tbl_deep_extend("force", rust_opts, opts)
local rust_tools_status_ok, rust_tools = pcall(require, "rust-tools")
if not rust_tools_status_ok then
@ -112,7 +112,7 @@ for _, server in pairs(servers) do
end
if server == "omnisharp" then
local omnisharp_opts = require("user.lsp.settings.omnisharp")
local omnisharp_opts = require("chris.lsp.settings.omnisharp")
opts = vim.tbl_deep_extend("force", omnisharp_opts, opts)
end

View File

@ -71,8 +71,8 @@ return {
--]]
-- cmd = { os.getenv "HOME" .. "/.local/bin/rust-analyzer" },
cmd = { "rustup", "run", "nightly", os.getenv "HOME" .. "/.local/bin/rust-analyzer" },
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
on_attach = require("chris.lsp.handlers").on_attach,
capabilities = require("chris.lsp.handlers").capabilities,
settings = {
["rust-analyzer"] = {

View File

@ -3,7 +3,7 @@ if not status_ok then
return
end
local icons = require "user.icons"
local icons = require "chris.icons"
lspsaga.init_lsp_saga({
code_action_icon = icons.diagnostics.Hint

View File

@ -4,7 +4,7 @@ if not status_ok then
return
end
local icons = require("user.icons")
local icons = require("chris.icons")
navic.setup({
icons = {

View File

@ -3,7 +3,7 @@ if not status_ok then
return
end
local icons = require "user.icons"
local icons = require "chris.icons"
notify.setup {
-- Animation style (see below for details)

View File

@ -8,7 +8,7 @@ if not config_status_ok then
return
end
local icons = require "user.icons"
local icons = require "chris.icons"
local tree_cb = nvim_tree_config.nvim_tree_callback

View File

@ -46,9 +46,9 @@ return packer.startup(function(use)
use("wbthomason/packer.nvim") -- Have packer manage inself
-- Lua Development
use("nvim-lua/plenary.nvim") -- useful lua functions
use("nvim-lua/popup.nvim")
use("folke/neodev.nvim")
--use("nvim-lua/plenary.nvim") -- useful lua functions
--use("nvim-lua/popup.nvim")
--use("folke/neodev.nvim")
-- LSP
use("neovim/nvim-lspconfig") -- enable LSP
@ -73,9 +73,9 @@ return packer.startup(function(use)
use("hrsh7th/cmp-nvim-lsp") -- lsp completions
use("hrsh7th/cmp-nvim-lua")
-- Snippet
use("L3MON4D3/LuaSnip") -- snippet engine
use("rafamadriz/friendly-snippets") -- a collection of useful snippets
-- Snippet {
--use("L3MON4D3/LuaSnip") -- snippet engine
--use("rafamadriz/friendly-snippets") -- a collection of useful snippets
-- Syntax/Treesitter
use("nvim-treesitter/nvim-treesitter")
@ -98,17 +98,17 @@ return packer.startup(function(use)
use("RRethy/nvim-base16")
-- Utility
use("rcarriga/nvim-notify")
--use("rcarriga/nvim-notify")
use("stevearc/dressing.nvim")
use("moll/vim-bbye")
use("lewis6991/impatient.nvim")
use("ghillb/cybu.nvim")
use("mbbill/undotree")
use("MunifTanjim/nui.nvim")
--use("moll/vim-bbye")
--use("lewis6991/impatient.nvim")
--use("ghillb/cybu.nvim")
--use("mbbill/undotree")
--use("MunifTanjim/nui.nvim")
-- noice
-- Icons
use("kyazdani42/nvim-web-devicons")
--use("kyazdani42/nvim-web-devicons")
-- Debugging
use("mfussenegger/nvim-dap")
@ -119,10 +119,10 @@ return packer.startup(function(use)
-- bufferline
-- Statusline
use("nvim-lualine/lualine.nvim")
--use("nvim-lualine/lualine.nvim")
-- Startup
use("goolord/alpha-nvim")
--use("goolord/alpha-nvim")
-- Indent
use("lukas-reineke/indent-blankline.nvim")

View File

@ -1,4 +1,4 @@
local icons = require "user.icons"
local icons = require "chris.icons"
vim.g.symbols_outline = {
highlight_hovered_item = true,
show_guides = true,

View File

@ -4,7 +4,7 @@ if not status_ok then
end
local actions = require "telescope.actions"
local icons = require "user.icons"
local icons = require "chris.icons"
telescope.setup {
defaults = {

View File

@ -3,7 +3,7 @@ if not status_ok then
return
end
local icons = require "user.icons"
local icons = require "chris.icons"
local error_red = "#F44747"
local warning_orange = "#ff8800"

View File

@ -0,0 +1,104 @@
vim.api.nvim_create_autocmd({ "User" }, {
pattern = { "AlphaReady" },
callback = function()
vim.cmd([[
set laststatus=0 | autocmd BufUnload <buffer> set laststatus=3
]])
end,
})
vim.api.nvim_create_autocmd({ "VimResized" }, {
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
vim.api.nvim_create_autocmd({ "CmdWinEnter" }, {
callback = function()
vim.cmd("quit")
end,
})
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
callback = function()
vim.cmd("set formatoptions-=cro")
end,
})
-- highlight on yank
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
callback = function()
vim.highlight.on_yank()
end,
})
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
vim.cmd("hi link illuminatedWord LspReferenceText")
end,
})
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- close some filetypes with <q>
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"qf",
"help",
"man",
"notify",
"lspinfo",
"spectre_panel",
"startuptime",
"tsplayground",
"PlenaryTestPopup",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
-- add spellcheck and wrapping to some file types
vim.api.nvim_create_autocmd("FileType", {
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Prevent auto comment on next line
vim.cmd([[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o]])
-- Set filetype to tex for .tex files?
vim.cmd([[autocmd BufRead,BufNewFile *.tex set filetype=tex]])
-- Trim whitespace from files on save
vim.cmd [[
autocmd BufWritePre * let currPos = getpos(".")
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
]]
-- Recompile and restart Xmonad on save of config file for Xmonad or Xmobar
vim.cmd([[autocmd BufWritePost ~/.xmonad/xmonad.hs,~/.config/xmobar/xmobar-main.hs,~/.config/xmobar/xmobar-sub.hs,~/.config/xmobar/xmobar-single.hs !xmonad --recompile && xmonad --restart]])
-- Run custom textclear command when exiting a .tex file (cleanup files)
vim.cmd([[autocmd VimLeave *.tex !texclear %]])
-- Run install when editing my scripts
vim.cmd([[
autocmd BufWritePost ~/repos/inks-scripts/scripts/** !~/repos/inks-scripts/install
]])

View File

@ -0,0 +1,116 @@
-- https://github.com/microsoft/vscode/blob/main/src/vs/base/common/codicons.ts
-- go to the above and then enter <c-v>u<unicode> and the symbold should appear
-- or go here and upload the font file: https://mathew-kurian.github.io/CharacterMap/
-- find more here: https://www.nerdfonts.com/cheat-sheet
return {
kind = {
Text = "",
-- Method = "m",
Function = "",
-- Constructor = "",
Method = "",
-- Function = "",
Constructor = "",
Field = "",
-- Variable = "",
Variable = "",
Namespace = "",
Class = "",
Interface = "",
-- Module = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Key = "k",
-- Keyword = "",
Keyword = "",
-- Snippet = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
},
type = {
Array = "",
Number = "",
String = "",
Boolean = "",
Null = "",
Object = "",
},
documents = {
File = "",
Files = "",
Folder = "",
OpenFolder = "",
},
git = {
Add = "",
Mod = "",
Remove = "",
Ignore = "",
Rename = "",
Diff = "",
Repo = "",
Octoface = "",
},
ui = {
ArrowClosed = "",
ArrowOpen = "",
Lock = "",
Circle = "",
BigCircle = "",
BigUnfilledCircle = "",
Close = "",
NewFile = "",
Search = "",
Lightbulb = "",
Project = "",
Dashboard = "",
History = "",
Comment = "",
Bug = "",
Code = "",
Telescope = "",
Gear = "",
Package = "",
List = "",
SignIn = "",
SignOut = "",
Check = "",
Fire = "",
Note = "",
BookMark = "",
Pencil = "",
-- ChevronRight = "",
ChevronRight = ">",
Table = "",
Calendar = "",
CloudDownload = "",
},
diagnostics = {
Error = "",
Warning = "",
Information = "",
Question = "",
Hint = "",
},
misc = {
Robot = "",
Squirrel = "",
Tag = "",
Watch = "",
Smiley = "",
Package = "",
CircuitBoard = "",
},
}

View File

@ -0,0 +1,45 @@
local opts = { noremap = true, silent = true }
local map = vim.api.nvim_set_keymap
-- NORMAL
-- Move text up and down
map("n", "<C-k>", "<ESC>:m .-2<CR>==", opts)
map("n", "<C-j>", "<ESC>:m .+1<CR>==", opts)
-- Copy/Paste
map("n", "<C-y>", '"+y', opts)
map("n", "<C-p>", '"+y', opts)
-- Save
map("n", "<C-s>", ":w<CR>", opts)
-- Switch between buffers
map("n", "<S-l>", ":CybuNext<CR>", opts)
map("n", "<S-h>", ":CybuPrev<CR>", opts)
-- center after up and down movements
map("n", "<C-u>", "<C-u>zz", opts)
map("n", "<C-d>", "<C-d>zz", opts)
-- INSERT
-- Easy exit insert mode
map("i", "jk", "<ESC>", opts)
-- Paste
map("i", "<C-p>", '"+y', opts)
-- Save
map("i", "<C-s>", "<ESC>:w<CR>a", opts)
-- VISUAL
-- Indenting
map("v", "<", "<gv", opts)
map("v", ">", ">gv", opts)
-- Move text up and down
map("v", "<C-j>", ":m .+1<CR>==<ESC>V", opts)
map("v", "<C-k>", ":m .-2<CR>==<ESC>V", opts)
-- Copy
map("v", "<C-y>", '"+y', opts)

View File

@ -0,0 +1,66 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "
local options = {
backup = false, -- creates a backup file
clipboard = "unnamedplus", -- gives nvim access to clipboard
cmdheight = 1, -- more space in nvim cmd line
completeopt = { "menuone", "noselect" }, -- cmp related
conceallevel = 3, -- don't hide `` in md
fileencoding = "utf-8",
hlsearch = false,
ignorecase = true,
mouse = "a", -- allow use of mouse (bad I know but sometimes useful)
pumheight = 10, -- popup menu height
showmode = true,
smartcase = true,
smartindent = true,
splitbelow = true,
splitright = true,
swapfile = false,
termguicolors = true,
timeoutlen = 500,
ttimeoutlen = 10,
undofile = true,
updatetime = 100,
writebackup = false,
expandtab = true, -- use spaces instead of tab
shiftwidth = 4, -- insert 4 spaces for indentation
tabstop = 4, -- insert 4 spaces for tab
cursorline = false,
number = true,
laststatus = 3,
showcmd = false,
ruler = false,
relativenumber = true,
numberwidth = 2,
signcolumn = "yes",
wrap = false,
scrolloff = 8,
sidescrolloff = 8,
guifont = "monospace:h17",
title = true,
spelllang = "en_us",
autowrite = true,
confirm = true,
formatoptions = "jcroqlnt", -- tcqj
grepformat = "%f:%l:%c:%m",
grepprg = "rg --vimgrep",
guifont = "FiraCode Nerd Font:h11",
}
vim.opt.fillchars = vim.opt.fillchars + 'eob: '
vim.opt.shortmess:append "c"
for k, v in pairs(options) do
vim.opt[k] = v
end
vim.cmd "set whichwrap+=<,>,[,],h,l"
vim.cmd "set colorcolumn=80"
vim.cmd [[set iskeyword+=-]]
-- fix markdown indentation settings
vim.g.markdown_recommended_style = 0

View File

@ -0,0 +1,129 @@
local M = {}
M.root_patterns = { ".git", "/lua" }
---@param on_attach fun(client, buffer)
function M.on_attach(on_attach)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local buffer = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end
-- returns the root directory based on:
-- * lsp workspace folders
-- * lsp root_dir
-- * root pattern of filename of the current buffer
-- * root pattern of cwd
---@return string
function M.get_root()
---@type string?
local path = vim.api.nvim_buf_get_name(0)
path = path ~= "" and vim.loop.fs_realpath(path) or nil
---@type string[]
local roots = {}
if path then
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
local workspace = client.config.workspace_folders
local paths = workspace and vim.tbl_map(function(ws)
return vim.uri_to_fname(ws.uri)
end, workspace) or client.config.root_dir and { client.config.root_dir } or {}
for _, p in ipairs(paths) do
local r = vim.loop.fs_realpath(p)
if path:find(r, 1, true) then
roots[#roots + 1] = r
end
end
end
end
table.sort(roots, function(a, b)
return #a > #b
end)
---@type string?
local root = roots[1]
if not root then
path = path and vim.fs.dirname(path) or vim.loop.cwd()
---@type string?
root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
root = root and vim.fs.dirname(root) or vim.loop.cwd()
end
---@cast root string
return root
end
---@param silent boolean?
---@param values? {[1]:any, [2]:any}function
function M.toggle(option, silent, values)
if values then
if vim.opt_local[option]:get() == values[1] then
vim.opt_local[option] = values[2]
else
vim.opt_local[option] = values[1]
end
return vim.notify(
"Set " .. option .. " to " .. vim.opt_local[option]:get(),
vim.log.levels.INFO,
{ title = "Option" }
)
end
vim.opt_local[option] = not vim.opt_local[option]:get()
if not silent then
vim.notify(
(vim.opt_local[option]:get() and "Enabled" or "Disabled") .. " " .. option,
vim.log.levels.INFO,
{ title = "Option" }
)
end
end
local enabled = true
function M.toggle_diagnostics()
enabled = not enabled
if enabled then
vim.diagnostic.enable()
vim.notify("Enabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
else
vim.diagnostic.disable()
vim.notify("Disabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
end
end
function M.smart_quit()
local bufnr = vim.api.nvim_get_current_buf()
local modified = vim.api.nvim_buf_get_option(bufnr, "modified")
if modified then
vim.ui.input({
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
}, function(input)
if input == "y" then
vim.cmd "q!"
end
end)
else
vim.cmd "q!"
end
end
function M.isempty(s)
return s == nil or s == ""
end
function M.get_buf_option(opt)
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
if not status_ok then
return nil
else
return buf_option
end
end
function M.telescope(builtin, opts)
return function()
require("telescope.builtin")[builtin](vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}))
end
end
return M

View File

@ -0,0 +1,38 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = "lazy.plugins",
defaults = { lazy = true, version = "*" },
checker = { enabled = true },
performance = {
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
vim.keymap.set("n", "<leader>l", "<cmd>:Lazy<cr>")
vim.cmd("colorscheme base16-gruvbox-dark-medium")

View File

@ -0,0 +1,47 @@
return {
{
"goolord/alpha-nvim" ,
config = function()
local dashboard = require"alpha.themes.dashboard"
local function button(sc, txt, key, key_opts)
local b = dashboard.button(sc, txt, key, key_opts)
b.opts.hl_shortcut = "Macro"
return b
end
local icons = require"user.icons"
dashboard.section.header.val = {
[[ , __ ___ __. _ __ ` , _ , _ ]],
[[ |' `. .' ` .' \ | / | |' `|' `.]],
[[ | | |----' | | ` / | | | |]],
[[ / | `.___, `._.' \/ / / ' /]],
}
dashboard.section.buttons.val = {
button("f", icons.documents.Files .. " Find file", ":Telescope find_files <CR>"),
button("e", icons.ui.NewFile .. " New file", ":ene <BAR> startinsert <CR>"),
button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles <CR>"),
button("t", icons.ui.List .. " Find text", ":Telescope live_grep <CR>"),
button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua <CR>"),
button("u", icons.ui.CloudDownload .. " Update", ":PackerSync<CR>"),
button("q", icons.ui.SignOut .. " Quit", ":qa<CR>"),
}
dashboard.section.footer.val = {
[[┬┌┐┌┬┌─┬ ┌─┐┌┬┐┌┐ ┬ ┌─┐┌┬┐┌─┐┌─┐┌┬┐]],
[[││││├┴┐│ ├┤ │ ├┴┐│ │ │ │ │ │ ││││]],
[[┴┘└┘┴ ┴┴─┘└─┘ ┴ └─┘┴─┘└─┘ ┴o└─┘└─┘┴ ┴]],
}
dashboard.section.header.opts.hl = "Include"
dashboard.section.buttons.opts.hl = "Macro"
dashboard.section.footer.opts.hl = "Type"
dashboard.opts.opts.noautocmd = true
require"alpha".setup(dashboard.opts)
end,
}
}

View File

@ -0,0 +1,54 @@
return {
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-emoji",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
cmp.setup({
completion = {
completeopt = "menu,menuone,noinsert",
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
{ name = "emoji" },
}),
formatting = {
format = function(_, item)
local icons = require("lazy.config.icons").kinds
if icons[item.kind] then
item.kind = icons[item.kind] .. item.kind
end
return item
end,
},
experimental = {
ghost_text = {
hl_group = "LspCodeLens",
},
},
})
end,
},
}

View File

@ -0,0 +1,24 @@
return {
{
"sainnhe/gruvbox-material",
lazy = true,
},
{
"sainnhe/sonokai",
lazy = true,
},
{
"dracula/vim",
lazy = true,
},
{
"RRethy/nvim-base16",
lazy = true,
},
{
"NvChad/nvim-colorizer.lua",
config = function()
require("colorizer").setup({})
end,
},
}

View File

@ -0,0 +1,33 @@
local function load(name)
local Util = require("lazy.core.util")
-- always load lazyvim, then user file
for _, mod in ipairs({ "lazy.config." .. name, "config." .. name }) do
Util.try(function()
require(mod)
end, {
msg = "Failed loading " .. mod,
on_error = function(msg)
local modpath = require("lazy.core.cache").find(mod)
if modpath then
Util.error(msg)
end
end,
})
end
end
-- load options here, before lazy init while sourcing plugin modules
-- this is needed to make sure options will be correctly applied
-- after installing missing plugins
load("options")
-- autocmds and keymaps can wait to load
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = function()
load("autocmds")
load("keymaps")
end,
})
return {}

View File

@ -0,0 +1,17 @@
return {
{
"stevearc/dressing.nvim",
init = function()
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.select = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.select(...)
end
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.input = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.input(...)
end
end,
},
}

View File

@ -0,0 +1,268 @@
local util = require"lazy.functions"
return {
{
"kyazdani42/nvim-tree.lua",
config = function()
local nvim_tree_config = require"nvim-tree.config"
local icons = require "user.icons"
local tree_cb = nvim_tree_config.nvim_tree_callback
nvim_tree.setup {
hijack_directories = {
enable = false,
},
ignore_ft_on_setup = {
"alpha",
},
filters = {
custom = { ".git" },
exclude = { ".gitignore" },
},
hijack_cursor = false,
update_cwd = true,
renderer = {
add_trailing = false,
group_empty = false,
highlight_git = false,
highlight_opened_files = "none",
root_folder_modifier = ":t",
indent_markers = {
enable = false,
icons = {
corner = "",
edge = "",
none = " ",
},
},
icons = {
webdev_colors = true,
git_placement = "before",
padding = " ",
symlink_arrow = "",
show = {
file = true,
folder = true,
folder_arrow = true,
git = true,
},
glyphs = {
default = "",
symlink = "",
folder = {
arrow_open = icons.ui.ArrowOpen,
arrow_closed = icons.ui.ArrowClosed,
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
git = {
unstaged = "",
staged = "S",
unmerged = "",
renamed = "",
untracked = "U",
deleted = "",
ignored = "",
},
},
},
},
diagnostics = {
enable = true,
icons = {
hint = icons.diagnostics.Hint,
info = icons.diagnostics.Information,
warning = icons.diagnostics.Warning,
error = icons.diagnostics.Error,
},
},
update_focused_file = {
enable = true,
update_cwd = true,
ignore_list = {},
},
git = {
enable = true,
ignore = true,
timeout = 500,
},
view = {
width = 30,
hide_root_folder = false,
side = "left",
mappings = {
custom_only = false,
list = {
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
{ key = "h", cb = tree_cb "close_node" },
{ key = "v", cb = tree_cb "vsplit" },
},
},
number = false,
relativenumber = false,
},
actions = {
open_file = {
quit_on_open = true,
}
}
}
end,
},
{
"windwp/nvim-spectre",
-- stylua: ignore
keys = {
{ "<leader>sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" },
},
},
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
keys = {
{ "<leader>/", util.telescope("live_grep"), desc = "Find in Files (Grep)" },
{ "<leader><space>", util.telescope("find_files"), desc = "Find Files (root dir)" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" },
{ "<leader>ff", util.telescope("find_files"), desc = "Find Files (root dir)" },
{ "<leader>fF", util.telescope("find_files", { cwd = false }), desc = "Find Files (cwd)" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
{ "<leader>ha", "<cmd>Telescope autocommands<cr>", desc = "Auto Commands" },
{ "<leader>hc", "<cmd>Telescope commands<cr>", desc = "Commands" },
{ "<leader>hf", "<cmd>Telescope filetypes<cr>", desc = "File Types" },
{ "<leader>hh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" },
{ "<leader>hk", "<cmd>Telescope keymaps<cr>", desc = "Key Maps" },
{ "<leader>hm", "<cmd>Telescope man_pages<cr>", desc = "Man Pages" },
{ "<leader>ho", "<cmd>Telescope vim_options<cr>", desc = "Options" },
{ "<leader>hs", "<cmd>Telescope highlights<cr>", desc = "Search Highlight Groups" },
{ "<leader>ht", "<cmd>Telescope builtin<cr>", desc = "Telescope" },
{ "<leader>sb", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "Buffer" },
{ "<leader>sc", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{ "<leader>sg", util.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>sG", util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
{ "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" },
{ "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" },
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{
"<leader>ss",
util.telescope("lsp_document_symbols", {
symbols = {
"Class",
"Function",
"Method",
"Constructor",
"Interface",
"Module",
"Struct",
"Trait",
"Field",
"Property",
},
}),
desc = "Goto Symbol",
},
},
config = {
defaults = {
prompt_prefix = "",
selection_caret = "",
mappings = {
i = {
["<c-t>"] = function(...)
return require("trouble.providers.telescope").open_with_trouble(...)
end,
["<C-i>"] = function()
util.telescope("find_files", { no_ignore = true })()
end,
["<C-h>"] = function()
util.telescope("find_files", { hidden = true })()
end,
["<C-Down>"] = function(...)
return require("telescope.actions").cycle_history_next(...)
end,
["<C-Up>"] = function(...)
return require("telescope.actions").cycle_history_prev(...)
end,
},
},
},
},
},
{
"folke/which-key.nvim",
event = "VeryLazy",
config = function()
local wk = require("which-key")
wk.setup({
plugins = { spelling = true },
key_labels = { ["<leader>"] = "SPC" },
})
wk.register({
mode = { "n", "v" },
["g"] = { name = "+goto" },
["]"] = { name = "+next" },
["["] = { name = "+prev" },
["<leader>b"] = { name = "+buffer" },
["<leader>c"] = { name = "+code" },
["<leader>f"] = { name = "+file" },
["<leader>g"] = { name = "+git" },
["<leader>h"] = { name = "+help" },
["<leader>n"] = { name = "+noice" },
["<leader>o"] = { name = "+open" },
["<leader>q"] = { name = "+quit/session" },
["<leader>s"] = { name = "+search" },
["<leader>t"] = { name = "+toggle" },
["<leader>x"] = { name = "+diagnostics/quickfix" },
["<leader>w"] = { name = "+windows" },
["<leader><tab>"] = { name = "+tabs" },
})
end,
},
{
"RRethy/vim-illuminate",
event = "BufReadPost",
config = function()
require("illuminate").configure({ delay = 200 })
end,
-- stylua: ignore
keys = {
{ "]]", function() require("illuminate").goto_next_reference(false) end, desc = "Next Reference", },
{ "[[", function() require("illuminate").goto_prev_reference(false) end, desc = "Prev Reference" },
},
},
{
"folke/trouble.nvim",
cmd = { "TroubleToggle", "Trouble" },
config = { use_diagnostic_signs = true },
keys = {
{ "<leader>xx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
{ "<leader>xX", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
},
},
{
"folke/todo-comments.nvim",
cmd = { "TodoTrouble", "TodoTelescope" },
event = "BufReadPost",
config = true,
-- stylua: ignore
keys = {
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" },
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" },
{ "<leader>xt", "<cmd>TodoTrouble<cr>", desc = "Todo Trouble" },
{ "<leader>xtt", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo Trouble" },
{ "<leader>xT", "<cmd>TodoTelescope<cr>", desc = "Todo Telescope" },
},
},
{
"numToStr/Comment.nvim",
config = function()
require"Comment".setup({})
end,
},
}

View File

@ -0,0 +1,43 @@
return {
{
"lewis6991/gitsigns.nvim",
event = "BufReadPre",
config = {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
on_attach = function(buffer)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
end
-- stylua: ignore start
map("n", "]h", gs.prev_hunk, "Next Hunk")
map("n", "[h", gs.next_hunk, "Prev Hunk")
map({ "n", "v" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
map({ "n", "v" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
map("n", "<leader>ghp", gs.preview_hunk, "Preview Hunk")
map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
map("n", "<leader>ghd", gs.diffthis, "Diff This")
map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk")
end,
},
},
{
"f-person/git-blame.nvim",
},
{
"tpope/vim-fugitive",
},
}

View File

@ -0,0 +1,40 @@
local M = {}
M.autoformat = true
function M.toggle()
M.autoformat = not M.autoformat
vim.notify(M.autoformat and "Enabled format on save" or "Disabled format on save")
end
function M.format()
local buf = vim.api.nvim_get_current_buf()
local ft = vim.bo[buf].filetype
local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0
vim.lsp.buf.format({
bufnr = buf,
filter = function(client)
if have_nls then
return client.name == "null-ls"
end
return client.name ~= "null-ls"
end,
})
end
function M.on_attach(client, buf)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("LspFormat." .. buf, {}),
buffer = buf,
callback = function()
if M.autoformat then
M.format()
end
end,
})
end
end
return M

View File

@ -0,0 +1,114 @@
return {
-- lspconfig
{
"neovim/nvim-lspconfig",
event = "BufReadPre",
dependencies = {
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
{ "folke/neodev.nvim", config = true },
"mason.nvim",
"williamboman/mason-lspconfig.nvim",
"hrsh7th/cmp-nvim-lsp",
},
---@type lspconfig.options
servers = {
jsonls = {},
sumneko_lua = {
settings = {
Lua = {
workspace = {
checkThirdParty = false,
},
completion = {
callSnippet = "Replace",
},
},
},
},
},
-- you can do any additional lsp server setup here
-- return true if you don't want this server to be setup with lspconfig
---@param server string lsp server name
---@param opts _.lspconfig.options any options set for the server
setup_server = function(server, opts)
return false
end,
config = function(plugin)
-- setup formatting and keymaps
require("lazy.functions").on_attach(function(client, buffer)
require("lazy.plugins.lsp.format").on_attach(client, buffer)
require("lazy.plugins.lsp.keymaps").on_attach(client, buffer)
end)
-- diagnostics
for name, icon in pairs(require("lazy.config.icons").diagnostics) do
name = "DiagnosticSign" .. name
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
end
vim.diagnostic.config({
underline = true,
update_in_insert = false,
virtual_text = { spacing = 4, prefix = "" },
severity_sort = true,
})
---@type lspconfig.options
local servers = plugin.servers or {}
local capabilities =
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) })
require("mason-lspconfig").setup_handlers({
function(server)
local opts = servers[server] or {}
opts.capabilities = capabilities
if not plugin.setup_server(opts) then
require("lspconfig")[server].setup(opts)
end
end,
})
end,
},
-- formatters
{
"jose-elias-alvarez/null-ls.nvim",
event = "BufReadPre",
dependencies = { "mason.nvim" },
config = function()
local nls = require("null-ls")
nls.setup({
sources = {
-- nls.builtins.formatting.prettierd,
nls.builtins.formatting.stylua,
nls.builtins.diagnostics.flake8,
},
})
end,
},
-- cmdline tools and lsp servers
{
"williamboman/mason.nvim",
cmd = "Mason",
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
config = function(plugin)
require("mason").setup()
local mr = require("mason-registry")
for _, tool in ipairs(plugin.ensure_installed) do
local p = mr.get_package(tool)
if not p:is_installed() then
p:install()
end
end
end,
},
}

View File

@ -0,0 +1,73 @@
local M = {}
function M.on_attach(client, buffer)
local self = M.new(client, buffer)
self:map("<leader>cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
self:map("<leader>cl", "LspInfo", { desc = "Lsp Info" })
self:map("<leader>xd", "Telescope diagnostics", { desc = "Telescope Diagnostics" })
self:map("gd", "Telescope lsp_definitions", { desc = "Goto Definition" })
self:map("gr", "Telescope lsp_references", { desc = "References" })
self:map("gD", "Telescope lsp_declarations", { desc = "Goto Declaration" })
self:map("gI", "Telescope lsp_implementations", { desc = "Goto Implementation" })
self:map("gt", "Telescope lsp_type_definitions", { desc = "Goto Type Definition" })
self:map("K", vim.lsp.buf.hover, { desc = "Hover" })
self:map("gK", vim.lsp.buf.signature_help, { desc = "Signature Help", has = "signatureHelp" })
self:map("[d", M.diagnostic_goto(true), { desc = "Next Diagnostic" })
self:map("]d", M.diagnostic_goto(false), { desc = "Prev Diagnostic" })
self:map("]e", M.diagnostic_goto(true, "ERROR"), { desc = "Next Error" })
self:map("[e", M.diagnostic_goto(false, "ERROR"), { desc = "Prev Error" })
self:map("]w", M.diagnostic_goto(true, "WARNING"), { desc = "Next Warning" })
self:map("[w", M.diagnostic_goto(false, "WARNING"), { desc = "Prev Warning" })
self:map("<leader>ca", vim.lsp.buf.code_action, { desc = "Code Action", mode = { "n", "v" }, has = "codeAction" })
local format = require("lazy.plugins.lsp.format").format
self:map("<leader>cf", format, { desc = "Format Document", has = "documentFormatting" })
self:map("<leader>cf", format, { desc = "Format Range", mode = "v", has = "documentRangeFormatting" })
self:map("<leader>cr", M.rename, { expr = true, desc = "Rename", has = "rename" })
if client.name == "tsserver" and pcall(require, "typescript") then
self:map("<leader>co", "TypescriptOrganizeImports", { desc = "Organize Imports" })
self:map("<leader>cR", "TypescriptRenameFile", { desc = "Rename File" })
end
end
function M.new(client, buffer)
return setmetatable({ client = client, buffer = buffer }, { __index = M })
end
function M:has(cap)
return self.client.server_capabilities[cap .. "Provider"]
end
function M:map(lhs, rhs, opts)
opts = opts or {}
if opts.has and not self:has(opts.has) then
return
end
vim.keymap.set(
opts.mode or "n",
lhs,
type(rhs) == "string" and ("<cmd>%s<cr>"):format(rhs) or rhs,
---@diagnostic disable-next-line: no-unknown
{ silent = true, buffer = self.buffer, expr = opts.expr, desc = opts.desc }
)
end
function M.rename()
if pcall(require, "inc_rename") then
return ":IncRename " .. vim.fn.expand("<cword>")
else
vim.lsp.buf.rename()
end
end
function M.diagnostic_goto(next, severity)
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
severity = severity and vim.diagnostic.severity[severity] or nil
return function()
go({ severity = severity })
end
end
return M

View File

@ -0,0 +1,118 @@
return {
"nvim-lualine/lualine.nvim",
config = function ()
local colors = {
red = "#ca1243",
grey = "#a0a1a7",
black = "#383a42",
white = "#f3f3f3",
light_green = "#83a598",
orange = "#fe8019",
green = "#8ec07c",
}
-- Put proper separators and gaps between components in sections
local function process_sections(sections)
for name, section in pairs(sections) do
local left = name:sub(9, 10) < "x"
for pos = 1, name ~= "lualine_z" and #section or #section - 1 do
table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } })
end
for id, comp in ipairs(section) do
if type(comp) ~= "table" then
comp = { comp }
section[id] = comp
end
comp.separator = left and { right = "" } or { left = "" }
end
end
return sections
end
local function search_result()
if vim.v.hlsearch == 0 then
return ''
end
local last_search = vim.fn.getreg('/')
if not last_search or last_search == '' then
return ''
end
local searchcount = vim.fn.searchcount { maxcount = 9999 }
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
-- return ""
end
local function modified()
if vim.bo.modified then
return "+"
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
return "-"
end
return ""
end
local status_ok, navic = pcall(require, "nvim-navic")
if not status_ok then
print("navic error!")
return
end
require("lualine").setup({
options = {
theme = "gruvbox",
component_separators = "",
section_separators = { left = "", right = "" },
},
sections = process_sections({
lualine_a = { "mode" },
lualine_b = {
"branch",
"diff",
{
"diagnostics",
source = { "nvim" },
sections = { "error" },
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
},
{
"diagnostics",
source = { "nvim" },
sections = { "warn" },
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
},
{ "filename", file_status = false, path = 1 },
{ modified, color = { bg = colors.red } },
{
"%w",
cond = function()
return vim.wo.previewwindow
end,
},
{
"%r",
cond = function()
return vim.bo.readonly
end,
},
{
"%q",
cond = function()
return vim.bo.buftype == "quickfix"
end,
},
},
lualine_c = {
{ navic.get_location, cond = navic.is_available },
},
lualine_x = {},
-- lualine_y = { search_result, 'filetype' },
lualine_y = { "filetype " },
lualine_z = { "%l:%c", "%p%%/%L" },
}),
inactive_sections = {
lualine_c = { "%f %y %m" },
lualine_x = {},
},
})
end,
}

View File

@ -0,0 +1,28 @@
return {
{
"folke/noice.nvim",
event = "VeryLazy",
config = {
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
},
},
presets = {
bottom_search = true,
command_palette = true,
long_message_to_split = true,
},
},
-- stylua: ignore
keys = {
{ "<S-Enter>", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" },
{ "<leader>nl", function() require("noice").cmd("last") end, desc = "Noice Last Message" },
{ "<leader>nh", function() require("noice").cmd("history") end, desc = "Noice History" },
{ "<leader>na", function() require("noice").cmd("all") end, desc = "Noice All" },
{ "<c-f>", function() if not require("noice.lsp").scroll(4) then return "<c-f>" end end, silent = true, expr = true },
{ "<c-b>", function() if not require("noice.lsp").scroll(-4) then return "<c-b>" end end, silent = true, expr = true },
},
},
}

View File

@ -0,0 +1,30 @@
return {
{
"L3MON4D3/LuaSnip",
dependencies = {
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
config = {
history = true,
delete_check_events = "TextChanged",
},
-- stylua: ignore
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true, remap = true, silent = true, mode = "i",
},
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
},
},
{
"rafamadriz/friendly-snippets", -- collection of useful snippets
},
}

View File

@ -0,0 +1,66 @@
return {
{
"echasnovski/mini.starter",
enabled = false,
version = false, -- wait till new 0.7.0 release to put it back on semver
event = "VimEnter",
config = function()
local logo = table.concat({
"██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z",
"██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z",
"██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z",
"██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z",
"███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║",
"╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝",
}, "\n")
local pad = string.rep(" ", 22)
local new_section = function(name, action, section)
return { name = name, action = action, section = pad .. section }
end
local starter = require("mini.starter")
--stylua: ignore
local config = {
evaluate_single = true,
header = logo,
items = {
new_section("Find file", "Telescope find_files", "Telescope"),
new_section("Recent files", "Telescope oldfiles", "Telescope"),
new_section("Grep text", "Telescope live_grep", "Telescope"),
new_section("init.lua", "e $MYVIMRC", "Config"),
new_section("Lazy", "Lazy", "Config"),
new_section("New file", "ene | startinsert", "Built-in"),
new_section("Quit", "qa", "Built-in"),
},
content_hooks = {
starter.gen_hook.adding_bullet(pad .. "", false),
starter.gen_hook.aligning("center", "center"),
},
}
-- close Lazy and re-open when starter is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
pattern = "MiniStarterOpened",
callback = function()
require("lazy").show()
end,
})
end
starter.setup(config)
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
local pad_footer = string.rep(" ", 8)
MiniStarter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
pcall(MiniStarter.refresh)
end,
})
end,
},
}

View File

@ -0,0 +1,19 @@
return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = "BufReadPost",
ensure_installed = "all",
config = function(plugin)
require("nvim-treesitter.configs").setup({
sync_install = false,
ensure_installed = plugin.ensure_installed,
matchup = { enable = true },
highlight = { enable = true },
autopairs = { enable = true },
indent = { enable = true },
context_commentstring = { enable = true, enable_autocmd = false },
})
end,
},
}

View File

@ -0,0 +1,274 @@
return {
{
"nvim-lua/plenary.nvim",
},
{
"nvim-lua/popup.nvim",
},
{
"folke/neodev.nvim",
},
{
"rcarriga/nvim-notify",
config = function()
local icons = require "user.icons"
require"notify".setup {
-- Animation style (see below for details)
stages = "fade_in_slide_out",
-- Function called when a new window is opened, use for changing win settings/config
on_open = nil,
-- Function called when a window is closed
on_close = nil,
-- Render function for notifications. See notify-render()
render = "default",
-- Default timeout for notifications
timeout = 2000,
-- For stages that change opacity this is treated as the highlight behind the window
-- Set this to either a highlight group or an RGB hex value e.g. "#000000"
background_colour = "Normal",
-- Minimum width for notification windows
minimum_width = 10,
-- Icons for the different levels
icons = {
ERROR = icons.diagnostics.Error,
WARN = icons.diagnostics.Warning,
INFO = icons.diagnostics.Information,
DEBUG = icons.ui.Bug,
TRACE = icons.ui.Pencil,
},
}
end,
},
{
"moll/vim-bbye",
},
{
"lewis6991/impatient.nvim",
config = function()
require"impatient".enable_profile()
end,
},
{
"ghillb/cybu.nvim",
config = function()
require"cybu".setup({
position = {
relative_to = "win", -- win, editor, cursor
anchor = "topright", -- topleft, topcenter, topright,
-- centerleft, center, centerright,
-- bottomleft, bottomcenter, bottomright
-- vertical_offset = 10, -- vertical offset from anchor in lines
-- horizontal_offset = 0, -- vertical offset from anchor in columns
-- max_win_height = 5, -- height of cybu window in lines
-- max_win_width = 0.5, -- integer for absolute in columns
-- float for relative to win/editor width
},
display_time = 1750, -- time the cybu window is displayed
style = {
separator = " ", -- string used as separator
prefix = "", -- string used as prefix for truncated paths
padding = 1, -- left & right padding in number of spaces
hide_buffer_id = true,
devicons = {
enabled = true, -- enable or disable web dev icons
colored = true, -- enable color for web dev icons
},
},
})
end,
},
{
"mbbill/undotree",
},
{
"MunifTanjim/nui.nvim",
},
{
"kyazdani42/nvim-web-devicons"
},
{
"lukas-reineke/indent-blankline.nvim",
config = function()
vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
vim.g.indent_blankline_filetype_exclude = {
"help",
"startify",
"dashboard",
"packer",
"neogitstatus",
"NvimTree",
"Trouble",
"text"
}
vim.g.indentLine_enabled = 1
vim.g.indent_blankline_char = ""
vim.g.indent_blankline_show_trailing_blankline_indent = false
vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_use_treesitter = false
vim.g.indent_blankline_show_current_context = true
require"indent_blankline".setup({
show_current_context = true,
})
end,
},
{
"windwp/nvim-autopairs",
config = function()
require"nvim-autopairs".setup({
disable_filetype = { "TelescopePrompt", "spectre_panel" },
ignore_next_char = "[%w%.*]", -- don't place pair when cursor sits in front of any char
})
end,
},
{
"preservim/vim-markdown",
},
{
"nacro90/numb.nvim",
config = function()
require"numb".setup({
show_numbers = true, -- enable 'number' for the window while peeking
show_cursorline = true, -- enable 'cursorline' for window wdile peeking
})
end,
},
{
"andymass/vim-matchup",
},
{
"junegunn/vim-slash",
},
{
"folke/zen-mode.nvim",
config = function()
require"zen-mode".setup({
window = {
backdrop = 1,
height = 0.9,
width = 80,
options = {
signcolumn = "no",
number = false,
relativenumber = false,
cursorline = true,
cursorcolumn = false, -- disable cursor column
},
},
plugins = {
gitsigns = { enabled = false },
tmux = { enabled = false },
twilight = { enabled = false },
},
on_open = function()
vim.g.cmp_active = false
vim.cmd [[LspStop]]
local status_ok, _ = pcall(vim.api.nvim_set_option_value, "winbar", nil, { scope = "local" })
if not status_ok then
return
end
if vim.fn.exists("#" .. "_winbar") == 1 then
vim.cmd("au! " .. "_winbar")
end
end,
on_close = function()
vim.g.cmp_active = true
vim.cmd [[LspStart]]
require("user.winbar").create_winbar()
end,
})
end,
},
{
"tpope/vim-surround",
},
{
"danymat/neogen",
config = function()
require"neogen".setup({
enabled = true,
input_after_comment = true,
})
end,
},
{
"monaqa/dial.nvim",
config = function()
local dial_config = require"dial.config"
local y = "2024/05/29"
local augend = require "dial.augend"
dial_config.augends:register_group {
default = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias["%Y/%m/%d"],
},
typescript = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.constant.new { elements = { "let", "const" } },
},
visual = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias["%Y/%m/%d"],
augend.constant.alias.alpha,
augend.constant.alias.Alpha,
},
mygroup = {
augend.constant.new {
elements = { "and", "or" },
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
cyclic = true, -- "or" is incremented into "and".
},
augend.constant.new {
elements = { "True", "False" },
word = true,
cyclic = true,
},
augend.constant.new {
elements = { "public", "private" },
word = true,
cyclic = true,
},
augend.constant.new {
elements = { "&&", "||" },
word = false,
cyclic = true,
},
augend.date.alias["%d/%m/%Y"], -- date (02/19/2022, etc.)
augend.constant.alias.bool, -- boolean value (true <-> false)
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.semver.alias.semver
},
}
local map = require "dial.map"
-- change augends in VISUAL mode
vim.api.nvim_set_keymap("n", "<C-a>", map.inc_normal "mygroup", { noremap = true })
vim.api.nvim_set_keymap("n", "<C-x>", map.dec_normal "mygroup", { noremap = true })
vim.api.nvim_set_keymap("v", "<C-a>", map.inc_normal "visual", { noremap = true })
vim.api.nvim_set_keymap("v", "<C-x>", map.dec_normal "visual", { noremap = true })
vim.cmd [[
" enable only for specific FileType
autocmd FileType typescript,javascript lua vim.api.nvim_buf_set_keymap(0, "n", "<C-a>", require("dial.map").inc_normal("typescript"), {noremap = true})
]]
end,
},
{
"ThePrimeagen/harpoon",
},
}