Skip to content

Commit 646c5e3

Browse files
committed
add v1
1 parent 369688b commit 646c5e3

File tree

8 files changed

+334
-0
lines changed

8 files changed

+334
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
plugin/packer_compiled.lua

init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "user.options"
2+
require "user.keymaps"
3+
require "user.plugins"
4+
require "user.colorscheme"
5+
require "user.cmp"
6+
require "user.cmp"
7+
8+
vim.o.background = "dark" -- or "light" for light mode
9+
vim.cmd([[colorscheme gruvbox]])

lua/user/cmp.lua

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
local cmp_status_ok, cmp = pcall(require, "cmp")
2+
if not cmp_status_ok then
3+
return
4+
end
5+
6+
local snip_status_ok, luasnip = pcall(require, "luasnip")
7+
if not snip_status_ok then
8+
return
9+
end
10+
11+
require("luasnip/loaders/from_vscode").lazy_load()
12+
13+
local check_backspace = function()
14+
local col = vim.fn.col "." - 1
15+
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
16+
end
17+
18+
--   פּ ﯟ   some other good icons
19+
local kind_icons = {
20+
Text = "",
21+
Method = "m",
22+
Function = "",
23+
Constructor = "",
24+
Field = "",
25+
Variable = "",
26+
Class = "",
27+
Interface = "",
28+
Module = "",
29+
Property = "",
30+
Unit = "",
31+
Value = "",
32+
Enum = "",
33+
Keyword = "",
34+
Snippet = "",
35+
Color = "",
36+
File = "",
37+
Reference = "",
38+
Folder = "",
39+
EnumMember = "",
40+
Constant = "",
41+
Struct = "",
42+
Event = "",
43+
Operator = "",
44+
TypeParameter = "",
45+
}
46+
-- find more here: https://www.nerdfonts.com/cheat-sheet
47+
48+
cmp.setup {
49+
snippet = {
50+
expand = function(args)
51+
luasnip.lsp_expand(args.body)
52+
end,
53+
},
54+
window = {
55+
completion = cmp.config.window.bordered(),
56+
documentation = cmp.config.window.bordered(),
57+
},
58+
mapping = {
59+
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
60+
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
61+
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
62+
["<C-e>"] = cmp.mapping {
63+
i = cmp.mapping.abort(),
64+
c = cmp.mapping.close(),
65+
},
66+
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
67+
["<CR>"] = cmp.mapping.confirm({ select = true }),
68+
69+
["<C-k>"] = cmp.mapping.select_prev_item(),
70+
["<C-j>"] = cmp.mapping.select_next_item(),
71+
72+
["<Tab>"] = cmp.mapping(function(fallback)
73+
if cmp.visible() then
74+
cmp.select_next_item()
75+
elseif luasnip.expandable() then
76+
luasnip.expand()
77+
elseif luasnip.expand_or_jumpable() then
78+
luasnip.expand_or_jump()
79+
elseif check_backspace() then
80+
fallback()
81+
else
82+
fallback()
83+
end
84+
end, { "i", "s" }),
85+
86+
["<S-Tab>"] = cmp.mapping(function(fallback)
87+
if cmp.visible() then
88+
cmp.select_prev_item()
89+
elseif luasnip.jumpable(-1) then
90+
luasnip.jump(-1)
91+
else
92+
fallback()
93+
end
94+
end, { "i", "s" }),
95+
},
96+
formatting = {
97+
fields = { "kind", "abbr", "menu" },
98+
format = function(entry, vim_item)
99+
-- Kind icons
100+
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
101+
vim_item.menu = ({
102+
luasnip = "[Snippet]",
103+
buffer = "[Buffer]",
104+
path = "[Path]",
105+
})[entry.source.name]
106+
return vim_item
107+
end,
108+
},
109+
-- sort order of results
110+
sources = cmp.config.sources({
111+
{ name = "luasnip" },
112+
{ name = "buffer" },
113+
{ name = "path" },
114+
}),
115+
confirm_opts = {
116+
behavior = cmp.ConfirmBehavior.Replace,
117+
select = false,
118+
},
119+
experimental = {
120+
ghost_text = true,
121+
native_menu = false,
122+
},
123+
}

lua/user/colorscheme.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local colorscheme = "default"
2+
3+
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
4+
if not status_ok then
5+
vim.notify("colorscheme " .. colorscheme .. " not found!")
6+
return
7+
end

lua/user/keymaps.lua

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-- See: https://github.com/LunarVim/Neovim-from-scratch/blob/02-keymaps/lua/user/keymaps.lua
2+
3+
local opts = { noremap = true, silent = true }
4+
5+
local term_opts = { silent = true }
6+
7+
-- Shorten function name
8+
local keymap = vim.api.nvim_set_keymap
9+
10+
--Remap space as leader key
11+
keymap("", "<Space>", "<Nop>", opts)
12+
vim.g.mapleader = " "
13+
vim.g.maplocalleader = " "
14+
15+
-- Modes
16+
-- normal_mode = "n",
17+
-- insert_mode = "i",
18+
-- visual_mode = "v",
19+
-- visual_block_mode = "x",
20+
-- term_mode = "t",
21+
-- command_mode = "c",
22+
23+
-- Normal --
24+
-- Better window navigation
25+
--keymap("n", "<C-h>", "<C-w>h", opts)
26+
--keymap("n", "<C-j>", "<C-w>j", opts)
27+
--keymap("n", "<C-k>", "<C-w>k", opts)
28+
--keymap("n", "<C-l>", "<C-w>l", opts)
29+
30+
--keymap("n", "<leader>e", ":Lex 30<cr>", opts)
31+
32+
-- Resize with arrows
33+
--keymap("n", "<C-Up>", ":resize -2<CR>", opts)
34+
--keymap("n", "<C-Down>", ":resize +2<CR>", opts)
35+
--keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
36+
--keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
37+
38+
-- Navigate buffers
39+
--keymap("n", "<S-l>", ":bnext<CR>", opts)
40+
--keymap("n", "<S-h>", ":bprevious<CR>", opts)
41+
42+
-- Move text up and down
43+
--keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
44+
--keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
45+
46+
-- Insert --
47+
-- Press jk fast to enter
48+
--keymap("i", "jk", "<ESC>", opts)
49+
50+
-- Visual --
51+
-- Stay in indent mode
52+
--keymap("v", "<", "<gv", opts)
53+
--keymap("v", ">", ">gv", opts)
54+
55+
-- Move text up and down
56+
--keymap("v", "<A-j>", ":m .+1<CR>==", opts)
57+
--keymap("v", "<A-k>", ":m .-2<CR>==", opts)
58+
--keymap("v", "p", '"_dP', opts)
59+
60+
-- Visual Block --
61+
-- Move text up and down
62+
--keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
63+
--keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
64+
--keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
65+
--keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)
66+
67+
-- Terminal --
68+
-- Better terminal navigation
69+
--keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
70+
--keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
71+
--keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
72+
--keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)

lua/user/lsp.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
local status_ok, mason = pcall(require, "mason")
2+
if not status_ok then
3+
return
4+
end
5+
6+
local status_ok, masonLspConfig = pcall(require, "mason-lspconfig")
7+
if not status_ok then
8+
return
9+
end
10+
11+
local status_ok, _ = pcall(require, "lspconfig")
12+
if not status_ok then
13+
return
14+
end
15+
16+
mason.setup()
17+
masonLspConfig.setup({
18+
ensure_installed = { "tsserver" }
19+
})

lua/user/options.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- :help options
2+
local options = {
3+
backup = false,
4+
clipboard = "unnamedplus",
5+
cmdheight = 2,
6+
expandtab = true,
7+
fileencoding = "utf-8",
8+
hlsearch = true,
9+
ignorecase = true,
10+
mouse = "a",
11+
number = true,
12+
pumheight = 10,
13+
relativenumber = false,
14+
shiftwidth = 2,
15+
smartcase = true,
16+
smartindent = true,
17+
splitbelow = true,
18+
splitright = true,
19+
swapfile = false,
20+
tabstop = 2,
21+
timeoutlen = 1000,
22+
undofile = true,
23+
updatetime = 300,
24+
wrap = false,
25+
writebackup = false,
26+
}
27+
28+
for k, v in pairs(options) do
29+
vim.opt[k] = v
30+
end
31+
32+
-- font used in graphical neovim applications
33+
vim.opt.guifont = "MesloLGS NF:h14"
34+
35+
-- set language to English
36+
vim.api.nvim_exec("language en_US", true)

lua/user/plugins.lua

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- Automatically install packer
2+
local install_path = vim.fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"
3+
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
4+
PACKER_BOOTSTRAP = vim.fn.system {
5+
"git",
6+
"clone",
7+
"--depth",
8+
"1",
9+
"https://github.com/wbthomason/packer.nvim",
10+
install_path,
11+
}
12+
print "Installing packer close and reopen Neovim..."
13+
vim.cmd [[packadd packer.nvim]]
14+
end
15+
16+
-- Autocommand that reloads neovim whenever you save the plugins.lua file
17+
vim.cmd [[
18+
augroup packer_user_config
19+
autocmd!
20+
autocmd BufWritePost plugins.lua source <afile> | PackerSync
21+
augroup end
22+
]]
23+
24+
-- Use a protected call so we don’t error out on first use
25+
local status_ok, packer = pcall(require, "packer")
26+
if not status_ok then
27+
return
28+
end
29+
30+
-- Init (maybe unnecessary)
31+
--packer.init {}
32+
33+
-- Install plugins
34+
return packer.startup(function(use)
35+
use "wbthomason/packer.nvim" -- Have packer manage itself
36+
--use "nvim-lua/popup.nvim" -- An implementation of the Popup API from vim in Neovim
37+
--use "nvim-lua/plenary.nvim" -- Useful lua functions used by lots of plugins
38+
39+
-- auto-completion
40+
use "hrsh7th/nvim-cmp"
41+
use "hrsh7th/cmp-buffer"
42+
use "hrsh7th/cmp-cmdline"
43+
use "hrsh7th/cmp-path"
44+
use "saadparwaiz1/cmp_luasnip"
45+
use "hrsh7th/cmp-nvim-lsp"
46+
use "hrsh7th/cmp-nvim-lua"
47+
48+
-- snippet engine
49+
use "L3MON4D3/LuaSnip"
50+
use "rafamadriz/friendly-snippets"
51+
52+
-- language server protocol (LSP)
53+
use "williamboman/mason.nvim"
54+
use "williamboman/mason-lspconfig.nvim"
55+
use "neovim/nvim-lspconfig"
56+
57+
-- themes
58+
use "ellisonleao/gruvbox.nvim" -- gruvbox theme
59+
--use "rktjmp/lush.nvim" -- colorscheme creation aid for Neovim
60+
--use "davidscotson/sonokai-nvim" -- sonokai theme
61+
62+
-- Automatically set up your configuration after cloning packer.nvim
63+
-- Put this at the end after all plugins
64+
if PACKER_BOOTSTRAP then
65+
require("packer").sync()
66+
end
67+
end)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy