init config base

This commit is contained in:
Triston Armstrong 2024-06-26 20:49:17 -04:00
commit 851bdaa611
No known key found for this signature in database
GPG Key ID: FADE6AC6F956FC52
15 changed files with 389 additions and 0 deletions

4
init.lua Normal file
View File

@ -0,0 +1,4 @@
require("config.keymaps")
require("config.lazy")
vim.cmd.colorscheme "catppuccin-mocha"

22
lazy-lock.json Normal file
View File

@ -0,0 +1,22 @@
{
"LuaSnip": { "branch": "master", "commit": "ba3ea5bcfd969679f38fefb1bc801cd45524045b" },
"bufferline.nvim": { "branch": "main", "commit": "99337f63f0a3c3ab9519f3d1da7618ca4f91cffe" },
"catppuccin": { "branch": "main", "commit": "894efb557728e532aa98b98029d16907a214ec05" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"gitsigns.nvim": { "branch": "main", "commit": "fa42613096ebfa5fee1ea87d70f8625ab9685d01" },
"lazy.nvim": { "branch": "main", "commit": "aa1c9572aa1916e582f9b9c3d43e272b4f23b326" },
"lazygit.nvim": { "branch": "main", "commit": "ad3e1ea592f9d13e86e0d4e850224d9d78069508" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
"mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" },
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
"nvim-lspconfig": { "branch": "master", "commit": "9c9eb07fecc578e25e28db8dc9002b43fff2ed79" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
"oil.nvim": { "branch": "master", "commit": "65c53dbe4f2140236590a7568a5f22a77d16be39" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"supermaven-nvim": { "branch": "main", "commit": "ec7ae4c8190c96002aa466b1eb4a23aa51e24812" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }
}

28
lua/config/keymaps.lua Normal file
View File

@ -0,0 +1,28 @@
local map = vim.keymap.set
vim.g.mapleader = " "
map({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
map("n", "Q", "<Nop>")
map("n", "q:", "<Nop>")
map("n", "<C-c>", "<Esc>")
map("n", "<C-s>", "<cmd>w<CR>")
map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map("n", "<CR>", '{->v:hlsearch ? ":nohl\\<CR>" : "\\<CR>"}()', { expr = true })
map("v", "J", ":m '>+1<CR>gv=gv")
map("v", "K", ":m '<-2<CR>gv=gv")
-- Buffers
map("n", "<Tab>", "<cmd>bn<CR>")
map("n", "<S-Tab>", "<cmd>bp<CR>")
map("n", "<space>bd", "<cmd>bd<CR>")
-- Visual
map("x", "<", "<gv")
map("x", ">", ">gv")
map("x", "K", ":move '<-2<CR>gv-gv")
map("x", "J", ":move '>+1<CR>gv-gv")
-- Oil keymaps
map("n", "<space>e", "<cmd>Oil<CR>")

31
lua/config/lazy.lua Normal file
View File

@ -0,0 +1,31 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.inccommand = "split"
vim.opt.termguicolors = true
vim.opt.number = true
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "catpuccin-mocha" } },
-- automatically check for plugin updates
checker = { enabled = true, notify = false },
})

22
lua/config/util.lua Normal file
View File

@ -0,0 +1,22 @@
local Util = require("lazy.core.util")
local M = {}
M.format_on_save = true
function M.toggle_format_on_save()
if vim.b.autoformat == false then
vim.b.autoformat = nil
M.format_on_save = true
else
M.format_on_save = not M.format_on_save
end
if M.format_on_save then
Util.info("Enabled format on save", { title = "Format" })
else
Util.warn("Disabled format on save", { title = "Format" })
end
end
return M

View File

@ -0,0 +1,10 @@
return {
{
'akinsho/bufferline.nvim',
version = "*",
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
require('bufferline').setup()
end,
},
}

20
lua/plugins/gitsigns.lua Normal file
View File

@ -0,0 +1,20 @@
return {
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
},
keys = {
{ "]g", "<cmd>Gitsigns next_hunk<CR>", desc = "Next Git Hunk" },
{ "[g", "<cmd>Gitsigns prev_hunk<CR>", desc = "Previous Git Hunk" },
},
}

20
lua/plugins/lazygit.lua Normal file
View File

@ -0,0 +1,20 @@
-- nvim v0.8.0
return {
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
-- setting the keybinding for LazyGit with 'keys' is recommended in
-- order to load the plugin when the command is run for the first time
keys = {
{ "<leader>gg", "<cmd>LazyGit<cr>", desc = "LazyGit" }
}
}

175
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,175 @@
return {
{
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
-- LSP Support
{ "williamboman/mason.nvim", cmd = "Mason", build = ":MasonUpdate" },
{
"williamboman/mason-lspconfig.nvim",
config = function(_, opts) end,
},
},
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
tsserver = {
settings = {},
},
lua_ls = {
settings = { Lua = { diagnostics = { globals = { "vim" } } } },
},
},
},
config = function(_, opts)
require("mason").setup()
local mason_lspconfig = require("mason-lspconfig")
local lsp_config = require("lspconfig")
local lsp_capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
require("cmp_nvim_lsp").default_capabilities()
)
local lsp_attach = function(client, bufnr)
local key_opts = { buffer = bufnr, remap = false }
-- Keymaps
vim.keymap.set("n", "K", vim.lsp.buf.hover, key_opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, key_opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, key_opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, key_opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, key_opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_next, key_opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, key_opts)
vim.keymap.set("n", "<leader>df", vim.diagnostic.open_float, key_opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, key_opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, key_opts)
vim.keymap.set("i", "<C-h>", vim.lsp.buf.signature_help, key_opts)
end
mason_lspconfig.setup({
ensure_installed = {
"cssls",
"emmet_ls",
"eslint",
"jsonls",
"lua_ls",
--"tailwindcss",
"tsserver",
-- linter
-- "eslint_d",
-- formatter
-- "stylua",
-- "prettierd",
},
})
mason_lspconfig.setup_handlers({
function(server_name)
lsp_config[server_name].setup({
on_attach = lsp_attach,
capabilities = lsp_capabilities,
settings = opts.servers[server_name] and opts.servers[server_name].settings or {},
})
end,
})
vim.diagnostic.config({
underline = true,
update_in_insert = false,
virtual_text = {
spacing = 4,
source = "if_many",
},
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
})
end,
},
{
"L3MON4D3/LuaSnip",
build = (not jit.os:find("Windows"))
and "echo -e 'NOTE: jsregexp is optional, so not a big deal if it fails to build\n'; make install_jsregexp"
or nil,
-- dependencies = {
-- "rafamadriz/friendly-snippets",
-- config = function()
-- require("luasnip.loaders.from_vscode").lazy_load()
-- end,
-- },
},
{
"hrsh7th/nvim-cmp",
version = false, -- last release is way too old
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local cmp = require("cmp")
local compare = require("cmp.config.compare")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = cmp.config.sources({
{ name = "nvim_lsp", priority = 1 },
{ name = "luasnip", priority = 5, keyword_length = 2 },
-- { name = "buffer", priority = 10, keyword_length = 3 },
{ name = "path", priority = 2 },
}),
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = 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" }),
}),
})
end,
}
}

8
lua/plugins/mason.lua Normal file
View File

@ -0,0 +1,8 @@
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end
}
}

6
lua/plugins/oil.lua Normal file
View File

@ -0,0 +1,6 @@
return {
'stevearc/oil.nvim',
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
}

View File

@ -0,0 +1,12 @@
return {
"supermaven-inc/supermaven-nvim",
config = function()
require("supermaven-nvim").setup({
keymap = {
accept_suggestion = "<C-[>",
clear_suggestion = "<C-]>",
accept_word = "<C-j>",
}
})
end,
}

View File

@ -0,0 +1,3 @@
return {
'nvim-telescope/telescope.nvim', tag = '0.1.8',
}

3
lua/plugins/theme.lua Normal file
View File

@ -0,0 +1,3 @@
return {
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 }
}

25
lua/plugins/whichkey.lua Normal file
View File

@ -0,0 +1,25 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
config = function()
local wk = require("which-key")
-- f key register
wk.register({
f = {
name = "Buffers",
f = { "<cmd>Telescope buffers<cr>", "Find Buffer" }
}
}, { prefix = "<leader>" })
-- q key register
wk.register({
q = {"<cmd>bdelete<cr>", "Close Buffer"}
}, { prefix = "<leader>" })
end
}