initial commit

main
jaredgoldman 2024-04-06 21:14:14 -06:00
commit 94bf4f62c1
16 changed files with 457 additions and 0 deletions

12
init.lua 100644
View File

@ -0,0 +1,12 @@
require("options")
require("plugins")
require("config.telescope")
require("keymaps")
require("lsp")
require("colorscheme")
require("config.mason")
require("config.nvim-tree")
require("config.comment")
require("config.themery")
require("config.theme")
require("config.lualine")

23
lazy-lock.json 100644
View File

@ -0,0 +1,23 @@
{
"LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
"catppuccin": { "branch": "main", "commit": "aebe43db9cb26e1c70fc5b2fd4158169c405e720" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9dfcf2036c223920826140f0151d929a43f9eceb" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" },
"nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },
"nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" },
"nvim-lspconfig": { "branch": "master", "commit": "9619e53d3f99f0ca4ea3b88f5d97fce703131820" },
"nvim-tree.lua": { "branch": "master", "commit": "81eb8d519233c105f30dc0a278607e62b20502fd" },
"nvim-web-devicons": { "branch": "master", "commit": "93ddac6966d5d3416f96df728d7b92e27aaa4452" },
"plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" },
"telescope.nvim": { "branch": "master", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" },
"themery.nvim": { "branch": "main", "commit": "1005a58801276d29c4b1e11244cf7631250f9143" },
"vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" }
}

View File

@ -0,0 +1,8 @@
-- define your colorscheme here
local colorscheme = 'monokai_pro'
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not is_ok then
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
return
end

View File

@ -0,0 +1 @@
require('nvim_comment').setup({comment_empty = false})

View File

@ -0,0 +1,8 @@
-- local base16 = require'lualine.themes.base16'
local ayu_dark = require'lualine.themes.ayu_dark'
-- Change the background of lualine_c section for normal mode
require('lualine').setup {
options = { theme = ayu_dark },
}

View File

@ -0,0 +1,24 @@
-- Mason
require('mason').setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
})
-- A list of servers to automatically install if they're not already installed
require('mason-lspconfig').setup({
ensure_installed = {
'cssls',
'cssmodules_ls',
'graphql',
'html',
'intelephense',
'tailwindcss',
'tsserver',
'jsonls',
'lua_ls'
},
})

View File

@ -0,0 +1,78 @@
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")
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
-- Use <C-b/f> to scroll the docs
['<C-b>'] = cmp.mapping.scroll_docs( -4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Use <C-k/j> to switch in items
['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-j>'] = cmp.mapping.select_next_item(),
-- Use <CR>(Enter) to confirm selection
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = true }),
-- A super tab
-- sourc: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
["<Tab>"] = cmp.mapping(function(fallback)
-- Hint: if the completion menu is visible select next one
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }), -- i - insert mode; s - select mode
["<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" }),
}),
-- Let's configure the item's appearance
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
formatting = {
-- Set order from left to right
-- kind: single letter indicating the type of completion
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
fields = { 'abbr', 'menu' },
-- customize the appearance of the completion menu
format = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = '[Lsp]',
luasnip = '[Luasnip]',
buffer = '[File]',
path = '[Path]',
})[entry.source.name]
return vim_item
end,
},
-- Set source precedence
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'luasnip' }, -- For luasnip user
{ name = 'buffer' }, -- For buffer word completion
{ name = 'path' }, -- For path completion
})
})

View File

@ -0,0 +1,14 @@
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})

View File

@ -0,0 +1,30 @@
local actions = require("telescope.actions")
require('telescope').setup {
defaults = {
-- Default configuration for telescope goes here:
-- config_key = value,
mappings = {
i = {
["<esc>"] = actions.close,
["<C-u>"] = false
}
}
},
pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
},
extensions = {
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
}
}

View File

@ -0,0 +1,5 @@
-- Themery block
-- This block will be replaced by Themery.
vim.cmd("colorscheme catppuccin-mocha")
vim.g.theme_id = 2
-- end themery block

View File

@ -0,0 +1,13 @@
-- Set custom name to the list
require("themery").setup({
themes = { {
name = "Day",
colorscheme = "catppuccin-latte",
},
{
name = "Night",
colorscheme = "catppuccin-mocha",
} },
themeConfigFile = "~/.config/nvim/lua/config/theme.lua", -- Desibed below
livePreview = true, -- Apply theme while browsing. Default to true.
})

50
lua/keymaps.lua 100644
View File

@ -0,0 +1,50 @@
local keymap = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
local mappings = {
n = {
["<leader>nh"] = ":nohl<CR>",
["<leader>sv"] = "<C-w>s",
["<leader>sh"] = "<C-w>v",
["<leader>se"] = "<C-w>=",
["<leader>sx"] = ":close<CR>",
-- nvim-tree
["<leader>e"] = ":NvimTreeToggle<CR>",
["<leader>cf"] = ":NvimTreeCollapse<CR>",
-- lsp
["<leader>ls"] = ":lspstop<CR>",
["<leader>lo"] = ":lspstart<CR>",
-- move between buffers
["<c-h>"] = "<C-w>h",
["<c-j>"] = "<C-w>j",
["<c-k>"] = "<C-w>k",
["<c-l>"] = "<C-w>l",
["<leader>ff"] = "<cmd>Telescope find_files<CR>",
["<leader>fw"] = "<cmd>Telescope live_grep<CR>",
["<leader>fc"] = "<cmd>Telescope grep_string<CR>",
["<leader>th"] = "<cmd>Themery<CR>",
["<leader>sm"] = ":MaximizerToggle<CR>"
},
x = {
["J"] = ":move '>+1<CR>gv-gv",
["K"] = ":move '<-2<CR>gv-gv",
["<A-j>"] = ":move '>+1<CR>gv-gv",
["<A-k>"] = ":move '<-2<CR>gv-gv",
},
i = {
["c-j"] = [[<cmd>lua require('copilot').accept()<CR>]],
["<m-l>"] = "<esc>",
},
}
for mode, mode_mappings in pairs(mappings) do
for key, mapping in pairs(mode_mappings) do
if type(mapping) == "function" then
keymap(mode, key, "<cmd>lua " .. mapping() .. "<>", opts)
elseif type(mapping) == "table" then
keymap(mode, key, mapping[1], mapping[2] or opts)
else
keymap(mode, key, mapping, opts)
end
end
end

75
lua/lsp.lua 100644
View File

@ -0,0 +1,75 @@
-- Set different settings for different languages' LSP
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
-- - the settings table is sent to the LSP
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
local lspconfig = require('lspconfig')
-- Customized on_attach function
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true }
local mappings = {
['<leader>k'] = vim.diagnostic.open_float,
['[d'] = vim.diagnostic.goto_prev,
[']d'] = vim.diagnostic.goto_next,
['<leader>q'] = vim.diagnostic.setloclist,
['gD'] = vim.lsp.buf.declaration,
['gd'] = vim.lsp.buf.definition,
['K'] = vim.lsp.buf.hover,
['gi'] = vim.lsp.buf.implementation,
['<leader>wa'] = vim.lsp.buf.add_workspace_folder,
['<leader>wr'] = vim.lsp.buf.remove_workspace_folder,
['<leader>wl'] = function()
print(vim.inspect(vim.lsp.buf.list_workleader_folders()))
end,
['<leader>D'] = vim.lsp.buf.type_definition,
['<leader>rn'] = vim.lsp.buf.rename,
['<leader>ca'] = vim.lsp.buf.code_action,
['gr'] = vim.lsp.buf.references,
['<leader>fm'] = function()
vim.lsp.buf.format({ async = true })
end,
}
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
local bufopts = { noremap = true, silent = true, buffer = bufnr }
for key, mapping in pairs(mappings) do
vim.keymap.set('n', key, mapping, bufopts)
end
end
local servers = {
"tsserver",
"intelephense",
"tailwindcss",
"lua_ls",
}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem = {
documentationFormat = { "markdown", "plaintext" },
snippetSupport = true,
preselectSupport = true,
insertReplaceSupport = true,
labelDetailsSupport = true,
deprecatedSupport = true,
commitCharactersSupport = true,
tagSupport = { valueSet = { 1 } },
resolveSupport = {
properties = {
"documentation",
"detail",
"additionalTextEdits",
},
},
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end

48
lua/options.lua 100644
View File

@ -0,0 +1,48 @@
local opt = vim.opt
local api = vim.api
local global = vim.g
-- Hint: use `:h <option>` to figure out the meaning if needed
opt.clipboard = "unnamedplus" -- use system clipboard
opt.completeopt = { "menu", "menuone", "noselect" }
opt.mouse = "a" -- allow the mouse to be used in Nvim
-- General
opt.wrap = false
global.loaded_netrw = 1
global.loaded_netrwPlugin = 1
global.mapleader = " "
-- Navigation
opt.cursorline = true
opt.backspace = "indent,eol,start"
-- Tab
opt.tabstop = 4 -- number of visual spaces per TAB
opt.softtabstop = 4 -- number of spacesin tab when editing
opt.shiftwidth = 4 -- insert 4 spaces on a tab
opt.expandtab = true -- tabs are spaces, mainly because of python
-- UI config
opt.number = true -- show absolute number
-- opt.relativenumber = true -- add numbers to each line on the left side
opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
opt.splitbelow = true -- open new vertical split bottom
opt.splitright = true -- open new horizontal splits right
opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
-- Searching
opt.incsearch = true -- search as characters are entered
opt.hlsearch = false -- do not highlight matches
opt.ignorecase = true -- ignore case in searches by default
opt.smartcase = true -- but make it case sensitive if an uppercase is entered
-- Show trailing whitespace
api.nvim_set_option("list", true)
api.nvim_set_option("listchars", "eol:$,nbsp:_,tab:>-,trail:~,extends:>,precedes:<")
-- Remove whitespace on save
api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[if &filetype !~# 'lsp' | %s/\s\+$//e | endif]],
})

60
lua/plugins.lua 100644
View File

@ -0,0 +1,60 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or 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)
require("lazy").setup({
"tanvirtin/monokai.nvim",
{
"onsails/lspkind.nvim",
event = { "VimEnter" },
},
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 },
-- Auto-completion engine
{
"hrsh7th/nvim-cmp",
dependencies = { "lspkind.nvim" },
config = function()
require("config.nvim-cmp")
end,
},
{ "hrsh7th/cmp-nvim-lsp", dependencies = { "nvim-cmp" } },
{ "hrsh7th/cmp-buffer", dependencies = { "nvim-cmp" } }, -- buffer auto-completion
{ "hrsh7th/cmp-path", dependencies = { "nvim-cmp" } }, -- path auto-completion
{ "hrsh7th/cmp-cmdline", dependencies = { "nvim-cmp" } }, -- cmdline auto-completion
-- Code snippet engine
{
"L3MON4D3/LuaSnip",
version = "v2.*",
},
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
"nvim-tree/nvim-tree.lua",
version = "*",
lazy = false,
dependencies = {
"nvim-tree/nvim-web-devicons",
},
{
'nvim-telescope/telescope.nvim',
tag = '0.1.6',
dependencies = { 'nvim-lua/plenary.nvim' }
},
'zaldih/themery.nvim',
'terrortylor/nvim-comment',
'szw/vim-maximizer',
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' }
}
})

8
requirements.md 100644
View File

@ -0,0 +1,8 @@
# Requirements for my setup
- file tree x
- lsp with mason x
- telescope x
- theming x
- tabfluline
- harpoon
- extended history