Skip to content

Commit

Permalink
feat: config version 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kaichevannes committed Nov 11, 2024
0 parents commit e3a4bb6
Show file tree
Hide file tree
Showing 18 changed files with 391 additions and 0 deletions.
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("config")
21 changes: 21 additions & 0 deletions lazy-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"context.vim": { "branch": "master", "commit": "82eb26de265292808917b82f3eda2725b53d785c" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
"lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" },
"nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" },
"nvim": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" },
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
"nvim-lspconfig": { "branch": "master", "commit": "4cb925e96288a71409a86c84fd97f4434a95453e" },
"nvim-treesitter": { "branch": "master", "commit": "bb06afa3f1111780932b3c5493ad65473ce85f9d" },
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" },
"vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }
}
9 changes: 9 additions & 0 deletions lazyvim.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extras": [

],
"news": {
"NEWS.md": "7107"
},
"version": 6
}
3 changes: 3 additions & 0 deletions lua/config/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require("config.remap")
require("config.set")
require("config.lazy")
35 changes: 35 additions & 0 deletions lua/config/lazy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- 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"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
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 = "\\"

-- 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 = { "catppuccin" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
53 changes: 53 additions & 0 deletions lua/config/remap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
vim.g.mapleader = " "

-- Move visually selected lines of text.
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")

-- Centre screen after motion.
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")

-- Paste without losing buffer contents.
vim.keymap.set("x", "<leader>p", "\"_dP")

-- Copy to system clipboard.
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")
vim.keymap.set("n", "<leader>Y", "\"+Y")

-- Paste from system clipboard.
vim.keymap.set("n", "<leader>p", function()
vim.cmd('normal! "+p')
if vim.fn.search("\\r", "n") > 0 then
vim.cmd('normal! :%s/\r//g<CR>')
end
end)
vim.keymap.set("n", "<leader>P", function()
vim.cmd('normal! "+P')
if vim.fun.search("\\r", "n" > 0) then
vim.cmd('normal! :%s/\r//g<CR>')
end
end)

-- Avoid accidentally entering Ex mode.
vim.keymap.set("n", "Q", "<nop>")

-- Quickfix/Local list navigation
vim.keymap.set("n", "<C-.>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-,>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>.", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<ledaer>,", "<cmd>lprev<CR>zz")

-- Global replace word
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])

-- Set current file to be executable in unix
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })

-- Rebind increment and decrement
vim.keymap.set("n", "<C-x>", "<cmd>normal! <C-a><CR>")
vim.keymap.set("n", "<C-z>", "<cmd>normal! <C-x><CR>")
31 changes: 31 additions & 0 deletions lua/config/set.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
vim.opt.number = true
vim.opt.relativenumber = true

vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true

vim.opt.smartindent = true

vim.opt.wrap = true

vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim.undodir"
vim.opt.undofile = true

vim.opt.hlsearch = false
vim.opt.incsearch = true

vim.opt.termguicolors = true

vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")

vim.opt.updatetime = 50

vim.opt.colorcolumn = "80"

vim.g.mapleader = " "
11 changes: 11 additions & 0 deletions lua/plugins/colorscheme.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
-- Install the catppuccin colorscheme
{
"catppuccin/nvim",
lazy = false,
priority = 1000,
config = function()
vim.cmd([[colorscheme catppuccin]])
end,
},
}
6 changes: 6 additions & 0 deletions lua/plugins/commentary.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
"numToStr/Comment.nvim",
config = function()
require("Comment").setup()
end
}
3 changes: 3 additions & 0 deletions lua/plugins/context.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
"wellle/context.vim",
}
6 changes: 6 additions & 0 deletions lua/plugins/fugitive.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
"tpope/vim-fugitive",
config = function()
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
end
}
21 changes: 21 additions & 0 deletions lua/plugins/harpoon.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },

config = function()
local harpoon = require("harpoon")

-- REQUIRED
harpoon:setup()
-- REQUIRED

vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)

vim.keymap.set("n", "<C-h>", function() harpoon:list():select(1) end)
vim.keymap.set("n", "<C-j>", function() harpoon:list():select(2) end)
vim.keymap.set("n", "<C-k>", function() harpoon:list():select(3) end)
vim.keymap.set("n", "<C-l>", function() harpoon:list():select(4) end)
end
}
112 changes: 112 additions & 0 deletions lua/plugins/lspzero.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
return {
{
'williamboman/mason.nvim',
lazy = false,
opts = {},
},

-- Autocompletion
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
config = function()
local cmp = require('cmp')

cmp.setup({
sources = {
{ name = 'nvim_lsp' },
},
mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
}),
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
})
end
},

-- LSP
{
'neovim/nvim-lspconfig',
cmd = { 'LspInfo', 'LspInstall', 'LspStart' },
event = { 'BufReadPre', 'BufNewFile' },
dependencies = {
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
},
init = function()
-- Reserve a space in the gutter
-- This will avoid an annoying layout shift in the screen
vim.opt.signcolumn = 'yes'
end,

config = function()
local lsp_defaults = require('lspconfig').util.default_config

require('mason-lspconfig').setup({
ensure_installed = { "eslint" },
handlers = {
-- this first function is the "default handler"
-- it applies to every language server without a "custom handler"
function(server_name)
require('lspconfig')[server_name].setup({})
end,
}
})

-- Add cmp_nvim_lsp capabilities settings to lspconfig
-- This should be executed before you configure any language server
lsp_defaults.capabilities = vim.tbl_deep_extend(
'force',
lsp_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)

-- LspAttach is where you enable features that only work
-- if there is a language server active in the file
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = { buffer = event.buf }

vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
vim.keymap.set({ 'n', 'x' }, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
end,
})

local cmp = require('cmp')
local cmp_select = { behaviour = cmp.SelectBehavior.Select }

cmp.setup({
sources = {
{ name = 'nvim_lsp' },
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-Space>'] = cmp.mapping.complete(),
}),
})
end
},
}
23 changes: 23 additions & 0 deletions lua/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
},
config = function()
require("neo-tree").setup({
window = {
width = 28,
mappings = {
['e'] = function() vim.api.nvim_exec('Neotree focus filesystem left', true) end,
['b'] = function() vim.api.nvim_exec('Neotree focus buffers left', true) end,
['g'] = function() vim.api.nvim_exec('Neotree focus git_status left', true) end,
}
}
})
vim.keymap.set("n", "<leader>jv", "<Cmd>Neotree toggle<CR>")
end
}
3 changes: 3 additions & 0 deletions lua/plugins/surround.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
"tpope/vim-surround"
}
13 changes: 13 additions & 0 deletions lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>jf', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<C-p>', builtin.git_files, { desc = 'Git file search'})
vim.keymap.set('n', '<leader>js', function()
builtin.grep_string({search = vim.fn.input("Grep > ")})
end)
end
}
Loading

0 comments on commit e3a4bb6

Please sign in to comment.