new nvim config with lazy.nvim

This commit is contained in:
juancwu 2023-07-09 01:27:48 -04:00
commit 11c0551a76
No known key found for this signature in database
21 changed files with 561 additions and 1 deletions

View file

@ -1 +0,0 @@
packer_compiled.lua

19
.config/nvim/init.lua Normal file
View file

@ -0,0 +1,19 @@
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", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- custom modules:
require("keymaps")
require("clipboard")
require("options")
require("lazy").setup("plugins")

View file

@ -0,0 +1,27 @@
{
"Comment.nvim": { "branch": "master", "commit": "176e85eeb63f1a5970d6b88f1725039d85ca0055" },
"LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"gitsigns.nvim": { "branch": "main", "commit": "dc2962f7fce953a2a98e7c6d3d7fc4c1d1f66758" },
"harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" },
"lazy.nvim": { "branch": "main", "commit": "5af331ea65418dc9361769891921fdee4bcc837a" },
"lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" },
"lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" },
"mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" },
"null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" },
"nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" },
"nvim-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" },
"nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" },
"nvim-treesitter": { "branch": "master", "commit": "d9104a1d10023ed9e7eacf68639ad887425246eb" },
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" },
"nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" },
"plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" },
"rose-pine": { "branch": "main", "commit": "932adb0d9351186db047302de021bb2976756a07" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "e03ff55962417b69c85ef41424079bb0580546ba" },
"telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
"todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" },
"undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" },
"vim-floaterm": { "branch": "master", "commit": "bd0aee3c861d613f56b85bd9eaffdcab459071fd" }
}

View file

@ -0,0 +1,12 @@
vim.g.clipboard = {
name = "win32yank",
copy = {
['+'] = "win32yank.exe -i --crlf",
['*'] = "win32yank.exe -i --crlf",
},
paste = {
['+'] = "win32yank.exe -o --lf",
['*'] = "win32yank.exe -o --lf",
},
cache_enabled = 0,
}

View file

@ -0,0 +1,89 @@
vim.g.mapleader = " "
-- easy escape
vim.keymap.set("i", "<C-[>", "<Esc>", { noremap = true, silent = true })
vim.keymap.set("v", "<C-[>", "<Esc>", { noremap = true, silent = true })
vim.keymap.set("n", "<C-[>", "<Esc>", { noremap = true, silent = true })
-- open the explorer
vim.keymap.set("n", "<leader>e", "<cmd>Ex<CR>")
-- move highlighted lines
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- make cursor stay in same position when appending line below
vim.keymap.set("n", "J", "mzJ`z")
-- make cursor stay in the middle while moving down/up the page
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- make cursor stay in the middle while looking through search results
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- do not copy with x, for god sake, WHY copy something that is being deleted??
vim.keymap.set("n", "x", "\"_x")
-- smile :)
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "q", "<nop>", { noremap = true })
vim.keymap.set("n", "<leader>q", "q", { noremap = true })
-- select and replace
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
-- no copy, delete line, for god sake...
vim.keymap.set("n", "dd", "\"_dd")
vim.keymap.set("n", "<leader>dd", "dd") -- cut line, under my control
-- copy/paste to/from system clipboard
vim.keymap.set({ "n", "v" }, "<leader>y", "\"+y")
vim.keymap.set({ "n", "v" }, "<leader>p", "\"+p")
-- increment/decrement a count, helpful for changing indeces
vim.keymap.set("n", "+", "<C-a>")
vim.keymap.set("n", "-", "<C-x>")
-- do not copy when deleting word
vim.keymap.set("n", "dw", "\"_dw")
vim.keymap.set("n", "de", "\"_de")
vim.keymap.set("n", "<leader>dw", "dw")
vim.keymap.set("n", "<leader>de", "de")
vim.keymap.set("n", "db", "vb\"_d") -- delete in backwards
vim.keymap.set("n", "<leader>db", "vbd")
vim.keymap.set("n", "<C-a>", "gg<S-v>G") -- select all
-- split pane
vim.keymap.set("n", "ss", ":split<Return><C-w>w", { silent = true }) -- horizontal
vim.keymap.set("n", "sv", ":vsplit<Return><C-w>w", { silent = true }) -- vertical
-- pane movement
vim.keymap.set("n", "..", "<C-w>w") -- toggle
vim.keymap.set("n", "sh", "<C-w>h")
vim.keymap.set("n", "sk", "<C-w>k")
vim.keymap.set("n", "sl", "<C-w>l")
vim.keymap.set("n", "sj", "<C-w>j")
-- resize pane
vim.keymap.set("n", "<C-w><left>", "<C-w><")
vim.keymap.set("n", "<C-w><right>", "<C-w>>")
vim.keymap.set("n", "<C-w><up>", "<C-w>+")
vim.keymap.set("n", "<C-w><down>", "<C-w>-")
-- my arrow keys babyyyy
vim.keymap.set("i", "<C-h>", "<Left>", { noremap = true })
vim.keymap.set("i", "<C-j>", "<Down>", { noremap = true })
vim.keymap.set("i", "<C-k>", "<Up>", { noremap = true })
vim.keymap.set("i", "<C-l>", "<Right>", { noremap = true })
-- terminal keymaps
vim.keymap.set("t", "<C-t>", "<C-\\><C-n>", { noremap = true })
vim.keymap.set("t", "<C-x>", "<cmd>bd!<CR>", { noremap = true })
vim.keymap.set("n", "<C-t>", "<cmd>term<CR>i", { noremap = true })
-- lazygit on floaterm
vim.keymap.set("n", "<leader>g", "<cmd>FloatermNew lazygit<CR>", { noremap = true })

View file

@ -0,0 +1,44 @@
vim.scriptencoding = "utf-8"
vim.opt.encoding = "utf-8"
vim.opt.fileencoding = "utf-8"
vim.wo.number = true -- show line number
vim.opt.relativenumber = true -- juicy relativity
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smarttab = true
vim.opt.breakindent = true
vim.opt.wrap = false -- bad, stay away from me!
vim.opt.hlsearch = false
vim.opt.incsearch = true -- highlight search pattern as you type
vim.opt.scrolloff = 8 -- give me some personal space
vim.opt.updatetime = 50
vim.opt.ignorecase = true -- case-insensitive search
vim.opt.backspace = { "start", "eol", "indent" }
-- don't want to look into these...
vim.opt.wildignore:append { "*/node_modules/*", "*/__pycache__/*" }
-- add '*' in block comments
vim.opt.formatoptions:append { 'r' }
-- theme
vim.opt.winblend = 0
vim.opt.wildoptions = "pum" -- show popup for autocomplete
vim.opt.pumblend = 5
vim.opt.background = "dark"
vim.opt.termguicolors = true -- good shit, just take it
-- activate persistent undo
vim.opt.undofile = true

View file

@ -0,0 +1,7 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = {
disable_filetype = { "TelescopePrompt", "vim" }
},
}

View file

@ -0,0 +1,8 @@
return {
"windwp/nvim-ts-autotag",
dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' },
config = function()
local autotag = require('nvim-ts-autotag')
autotag.setup()
end
}

View file

@ -0,0 +1,34 @@
return {
"numToStr/Comment.nvim",
dependencies = {
"JoosepAlviste/nvim-ts-context-commentstring",
},
config = function()
local comment = require('Comment')
comment.setup({
pre_hook = function(ctx)
-- only for tsx/jsx filetypes
if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then
local U = require('Comment.utils')
-- determine wheter to use linwise or blockwise commentstring
local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline'
-- determine the location where to calcualte commentstring from
local location = nil
if ctx.ctype == U.ctype.blockwise 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 = type,
location = location,
})
end
end,
})
end
}

View file

@ -0,0 +1,6 @@
return {
"voldikss/vim-floaterm",
keys = {
{ "<leader>gg", "<cmd>FloatermNew lazygit<CR>", desc = "Open lazygit in a floating window" },
},
}

View file

@ -0,0 +1,12 @@
return {
"lewis6991/gitsigns.nvim",
config = {
current_line_blame = true,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol',
delay = 1000,
ignore_whitespace = false
},
},
}

View file

@ -0,0 +1,18 @@
return {
"ThePrimeagen/harpoon",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<leader>q", function() ui.nav_file(1) end)
vim.keymap.set("n", "<leader>w", function() ui.nav_file(2) end)
vim.keymap.set("n", "<leader>e", function() ui.nav_file(3) end)
vim.keymap.set("n", "<leader>r", function() ui.nav_file(4) end)
vim.keymap.set("n", "<leader>,", ui.nav_prev)
vim.keymap.set("n", "<leader>.", ui.nav_next)
end
}

View file

@ -0,0 +1,76 @@
return {
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
dependencies = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{ -- Optional
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
},
config = function()
local lspzero = require("lsp-zero")
lspzero.preset("recommended")
lspzero.on_attach(function(client, bufnr)
lspzero.default_keymaps({ buffer = bufnr })
-- format with space + f
vim.keymap.set("n", "<leader>f", "<cmd>lua vim.lsp.buf.format()<CR>")
end)
lspzero.ensure_installed({
"tsserver",
"eslint",
"tailwindcss",
})
lspzero.format_on_save({
format_ops = {
async = true,
timeout_ms = 10000,
},
servers = {
["lua_ls"] = { "lua" },
["null-ls"] = {
"javascript",
"typescript",
"javascriptreact",
"typescriptreact",
},
},
})
local status, lspconfig = pcall(require, "lspconfig")
if status then
lspconfig.tsserver.setup({})
lspconfig.tailwindcss.setup({})
end
lspzero.setup()
local cmp
status, cmp = pcall(require, "cmp")
if not status then return end
cmp.setup({
mapping = {
-- press 'enter' to confirm completion/suggestion
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping.abort(),
},
})
end
}

View file

@ -0,0 +1,56 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons", lazy = true },
config = function ()
local lualine = require('lualine')
lualine.setup {
options = {
icons_enabled = true,
section_separators = {
left = '',
right = ''
},
component_separators = {
left = '',
right = ''
},
disabled_filetypes = {}
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch' },
lualine_c = { {
'filename',
file_status = true, -- display file status
path = 0 -- no file path
} },
lualine_x = {
{
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '', hint = '' }
},
'enconding',
'filetype'
},
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { {
'filename',
file_status = true,
path = 1
} },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = { 'fugitive' }
}
end
}

View file

@ -0,0 +1,15 @@
return {
"jose-elias-alvarez/null-ls.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.prettierd,
null_ls.builtins.diagnostics.eslint,
},
})
end
}

View file

@ -0,0 +1,7 @@
return {
"rose-pine/nvim",
name = "rose-pine",
config = function ()
vim.cmd.colorscheme("rose-pine")
end
}

View file

@ -0,0 +1,7 @@
return {
"nvim-telescope/telescope-file-browser.nvim",
dependencies = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
},
}

View file

@ -0,0 +1,70 @@
return {
"nvim-telescope/telescope.nvim",
version = "0.1.2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local telescope = require("telescope")
local actions = require("telescope.actions")
local builtin = require("telescope.builtin")
local fb_actions = require "telescope".extensions.file_browser.actions
local function telescope_buffer_dir()
return vim.fn.expand("%:p:h")
end
telescope.setup({
defaults = {
mappings = {
n = {
['q'] = actions.close
}
}
},
extensions = {
file_browser = {
theme = "dropdown",
hijack_netrw = true,
hidden = true,
mappings = {
['i'] = {
['<C-w>'] = function() vim.cmd("normal vbd") end,
['<C-j>'] = function(bufnr) actions.move_selection_next(bufnr) end,
['<C-k>'] = function(bufnr) actions.move_selection_previous(bufnr) end,
['<C-s>'] = function(bufnr) actions.select_vertical(bufnr) end,
},
['n'] = {
['N'] = fb_actions.create,
['h'] = fb_actions.goto_parent_dir,
['/'] = function() vim.cmd("startinsert") end,
['D'] = fb_actions.remove,
['<C-s>'] = function(bufnr) actions.select_vertical(bufnr) end,
['<C-a>'] = function(bufnr) actions.toggle_all(bufnr) end,
}
}
},
}
})
telescope.load_extension("file_browser")
-- Set up keymaps specific to telescope
vim.keymap.set("n", ";f", function()
builtin.find_files({ no_ignore = false, hidden = true })
end)
vim.keymap.set("n", ";g", builtin.git_files)
vim.keymap.set("n", "sf",
function()
telescope.extensions.file_browser.file_browser({
path = "%:p:h",
cwd = telescope_buffer_dir(),
respect_gitignore = true,
hidden = true,
grouped = true,
previewer = false,
initial_mode = "normal",
layout_config = { height = 40 }
})
end)
vim.keymap.set("n", ";h", builtin.help_tags)
end
}

View file

@ -0,0 +1,5 @@
return {
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = {},
}

View file

@ -0,0 +1,27 @@
return {
'nvim-treesitter/nvim-treesitter',
build = ":TSUpdate",
config = function()
local treesitter = require("nvim-treesitter.configs")
treesitter.setup {
-- A list of parser names, or "all"
ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
enable = true,
},
context_commentstring = {
enable = true,
},
}
end
}

View file

@ -0,0 +1,22 @@
return {
"mbbill/undotree",
keys = {
{ "<leader>u", "<cmd>UndotreeToggle<CR>", desc = "Toggle Undotree" },
},
config = function()
local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" })
if has_persistent_undo then
local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" })
local is_directory = vim.api.nvim_call_function("isdirectory", { target_path })
if not is_directory then
vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 })
end
vim.opt.undodir = target_path
vim.opt.undofile = true
end
end
}