Skip to content

Commit 147d304

Browse files
committed
every plugins have been modularized and created their files...
- lazy.nvim has been shifted to init.lua file. - created seperate files for plugins. - startup time has been reduced by 100ms to 35ms in average.
1 parent d7e0c01 commit 147d304

File tree

10 files changed

+131
-128
lines changed

10 files changed

+131
-128
lines changed

init.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
require("user.options")
33
-- settings for vscode key shortcuts.
44
require("user.keymaps")
5-
-- settings for plugins and list plugins.
6-
require("user.plugins")
7-
-- settings for colorscheme.
8-
require("user.colorscheme")
9-
-- settings for neovim statusline.
10-
require("user.statusline")
11-
-- settings for auto completion.
12-
require("user.completion")
5+
-- check and use lazy if unavailable.
6+
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
7+
if not (vim.uv or vim.loop).fs_stat(lazypath) then
8+
vim.fn.system({'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath})
9+
end
10+
vim.opt.rtp:prepend(lazypath)
11+
require("lazy").setup("plugins")

lua/plugins/autopairs.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
return {
2+
"windwp/nvim-autopairs",
3+
event = "InsertEnter",
4+
config = function()
5+
require("nvim-autopairs").setup {}
6+
end
7+
}

lua/plugins/colorscheme.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
return {
2+
"OurCodeBase/everforest-nvim",
3+
lazy = false,
4+
priority = 1000,
5+
config = function()
6+
local everforest = require("everforest")
7+
everforest.setup {
8+
background = "hard",
9+
ui_contrast = "low",
10+
dim_inactive_windows = false,
11+
better_performance = true,
12+
}
13+
everforest.load()
14+
end
15+
}

lua/plugins/completions.lua

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
return {
2+
-- completions
3+
"hrsh7th/nvim-cmp", -- completion engine
4+
event = "InsertEnter",
5+
dependencies = {
6+
"hrsh7th/cmp-buffer", -- buffer completion
7+
"hrsh7th/cmp-path", -- path completion
8+
{ "hrsh7th/cmp-cmdline", event = "CmdlineEnter" }, -- cmdline completion
9+
-- snippets
10+
"L3MON4D3/LuaSnip", -- snippet engine
11+
"saadparwaiz1/cmp_luasnip", -- snippet engine
12+
"OurCodeBase/friendly-snippets", -- snippet collection
13+
},
14+
config = function()
15+
local cmp = require'cmp'
16+
local luasnip = require("luasnip")
17+
18+
cmp.setup({
19+
snippet = {
20+
expand = function(args)
21+
require('luasnip').lsp_expand(args.body)
22+
end,
23+
},
24+
window = {
25+
completion = cmp.config.window.bordered(),
26+
documentation = cmp.config.window.bordered(),
27+
},
28+
mapping = cmp.mapping.preset.insert({
29+
['<M-Up>'] = cmp.mapping.scroll_docs(-4),
30+
['<M-Down>'] = cmp.mapping.scroll_docs(4),
31+
['<M-Space>'] = cmp.mapping.complete(),
32+
['<M-c>'] = cmp.mapping.abort(),
33+
['<CR>'] = cmp.mapping.confirm({ select = true }),
34+
["<Tab>"] = cmp.mapping(function(fallback)
35+
if luasnip.jumpable(1) then luasnip.jump(1)
36+
else fallback()
37+
end
38+
end, { "i", "s" }),
39+
["<M-Left>"] = cmp.mapping(function(fallback)
40+
if luasnip.jumpable(-1) then luasnip.jump(-1)
41+
else fallback()
42+
end
43+
end, { "i", "s" }),
44+
}),
45+
sources = cmp.config.sources({
46+
{ name = 'nvim_lsp' },
47+
{ name = 'luasnip' },
48+
}, {
49+
{ name = 'buffer' },
50+
})
51+
})
52+
53+
cmp.setup.cmdline({ '/', '?' }, {
54+
mapping = {
55+
['<CR>'] = cmp.mapping.confirm({ select = true }),
56+
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
57+
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
58+
},
59+
sources = {
60+
{ name = 'buffer' }
61+
}
62+
})
63+
64+
cmp.setup.cmdline(':', {
65+
mapping = {
66+
['<CR>'] = cmp.mapping.confirm({ select = true }),
67+
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
68+
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
69+
},
70+
sources = cmp.config.sources({
71+
{ name = 'path' }
72+
}, {
73+
{ name = 'cmdline' }
74+
}),
75+
matching = { disallow_symbol_nonprefix_matching = true }
76+
})
77+
78+
-- this loads friendly-snippets as lazy-load.
79+
require('luasnip.loaders.from_vscode').lazy_load()
80+
end
81+
}

lua/plugins/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return {}

lua/plugins/statusline.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
return {
2+
"nvim-lualine/lualine.nvim",
3+
config = function()
4+
local lualine = require("lualine")
5+
lualine.setup {
6+
options = {
7+
theme = "auto",
8+
icons_enabled = false
9+
},
10+
sections = {
11+
lualine_a = {"mode"},
12+
lualine_b = {"filename"},
13+
lualine_c = {},
14+
lualine_x = {},
15+
lualine_y = {"filetype"},
16+
lualine_z = {"location"}
17+
},
18+
}
19+
end
20+
}

lua/user/colorscheme.lua

Lines changed: 0 additions & 13 deletions
This file was deleted.

lua/user/completion.lua

Lines changed: 0 additions & 65 deletions
This file was deleted.

lua/user/plugins.lua

Lines changed: 0 additions & 27 deletions
This file was deleted.

lua/user/statusline.lua

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)