Skip to content

Commit f4c7398

Browse files
committed
feat: v1
0 parents  commit f4c7398

20 files changed

+661
-0
lines changed

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lazy-lock.json
2+
hyperfine-*

‎README.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Sazed's Neovim Config
2+
3+
A Neovim config built on top of kickstart.nvim, with inspiration from a bunch of other people's configs.
4+
5+
## Installation
6+
7+
Make sure to backup your current config, then clone this repository
8+
9+
For Windows(PowerShell)
10+
```sh
11+
git clone https://github.com/SazedWorldbringer/nvim $env:LOCALAPPDATA\nvim
12+
```
13+
14+
Linux/MacOS(Unix)
15+
```sh
16+
git clone https://github.com/SazedWorldbringer/nvim ~/.config/nvim
17+
```
18+
19+
Just opening Neovim now will install Lazy(the plugin manager), and all the plugins.
20+
```sh
21+
nvim
22+
```
23+
24+
## Credits
25+
26+
- [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim)
27+
- [ThePrimeagen's "Neovim from scratch" video](https://youtu.be/w7i4amO_zaE)
28+
- [devaslife's "Neovim for coding React..." video](https://youtu.be/ajmK0ZNcM4Q)

‎init.lua‎

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
-- Install lazy
2+
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
3+
if not vim.loop.fs_stat(lazypath) then
4+
vim.fn.system({
5+
"git",
6+
"clone",
7+
"--filter=blob:none",
8+
"https://github.com/folke/lazy.nvim.git",
9+
"--branch=stable", -- latest stable release
10+
lazypath,
11+
})
12+
end
13+
vim.opt.rtp:prepend(lazypath)
14+
15+
-- [[ Basic Keymaps ]]
16+
-- Set <space> as the leader key
17+
-- See `:help mapleader`
18+
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
19+
vim.g.mapleader = ' '
20+
vim.g.maplocalleader = ' '
21+
22+
-- load plugins using lazy.nvim
23+
require('lazy').setup('plugins')
24+
25+
-- load base
26+
require('base')
27+
28+
-- Keymaps
29+
require('keymaps')
30+
31+
-- Enable Comment.nvim
32+
require('Comment').setup()
33+
34+
-- Enable `lukas-reineke/indent-blankline.nvim`
35+
-- See `:help indent_blankline.txt`
36+
37+
-- [[ Configure Telescope ]]
38+
-- See `:help telescope` and `:help telescope.setup()`
39+
require('telescope').setup {
40+
defaults = {
41+
mappings = {
42+
i = {
43+
['<C-u>'] = false,
44+
['<C-d>'] = false,
45+
},
46+
},
47+
},
48+
}
49+
50+
-- Enable telescope fzf native, if installed
51+
pcall(require('telescope').load_extension, 'fzf')
52+
53+
-- See `:help telescope.builtin`
54+
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
55+
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
56+
vim.keymap.set('n', '<leader>/', function()
57+
-- You can pass additional configuration to telescope to change theme, layout, etc.
58+
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
59+
winblend = 10,
60+
previewer = false,
61+
})
62+
end, { desc = '[/] Fuzzily search in current buffer]' })
63+
64+
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
65+
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
66+
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
67+
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
68+
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
69+
70+
-- Diagnostic keymaps
71+
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
72+
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
73+
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
74+
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
75+
76+
-- LSP settings.
77+
-- Setup mason so it can manage external tooling
78+
require('mason').setup()
79+
80+
-- Ensure the servers above are installed
81+
local mason_lspconfig = require 'mason-lspconfig'
82+
83+
-- This function gets run when an LSP connects to a particular buffer.
84+
local on_attach = function(_, bufnr)
85+
-- NOTE: Remember that lua is a real programming language, and as such it is possible
86+
-- to define small helper and utility functions so you don't have to repeat yourself
87+
-- many times.
88+
--
89+
-- In this case, we create a function that lets us more easily define mappings specific
90+
-- for LSP related items. It sets the mode, buffer and description for us each time.
91+
local nmap = function(keys, func, desc)
92+
if desc then
93+
desc = 'LSP: ' .. desc
94+
end
95+
96+
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
97+
end
98+
99+
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
100+
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
101+
102+
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
103+
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
104+
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
105+
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
106+
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
107+
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
108+
109+
-- See `:help K` for why this keymap
110+
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
111+
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
112+
113+
-- Lesser used LSP functionality
114+
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
115+
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
116+
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
117+
nmap('<leader>wl', function()
118+
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
119+
end, '[W]orkspace [L]ist Folders')
120+
121+
-- Create a command `:Format` local to the LSP buffer
122+
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
123+
vim.lsp.buf.format()
124+
end, { desc = 'Format current buffer with LSP' })
125+
end
126+
127+
-- Enable the following language servers
128+
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
129+
--
130+
-- Add any additional override configuration in the following tables. They will be passed to
131+
-- the `settings` field of the server config. You must look up that documentation yourself.
132+
local servers = {
133+
-- clangd = {},
134+
-- gopls = {},
135+
-- pyright = {},
136+
-- rust_analyzer = {},
137+
-- tsserver = {},
138+
139+
lua_ls = {
140+
Lua = {
141+
workspace = { checkThirdParty = false },
142+
telemetry = { enable = false },
143+
},
144+
},
145+
}
146+
147+
-- Setup neovim lua configuration
148+
require('neodev').setup()
149+
--
150+
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
151+
local capabilities = vim.lsp.protocol.make_client_capabilities()
152+
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
153+
154+
mason_lspconfig.setup {
155+
ensure_installed = vim.tbl_keys(servers),
156+
}
157+
158+
mason_lspconfig.setup_handlers {
159+
function(server_name)
160+
require('lspconfig')[server_name].setup {
161+
capabilities = capabilities,
162+
on_attach = on_attach,
163+
settings = servers[server_name],
164+
}
165+
end,
166+
}
167+
168+
-- Turn on lsp status information
169+
require('fidget').setup()
170+
171+
-- nvim-cmp setup
172+
local cmp = require 'cmp'
173+
local luasnip = require 'luasnip'
174+
175+
cmp.setup {
176+
snippet = {
177+
expand = function(args)
178+
luasnip.lsp_expand(args.body)
179+
end,
180+
},
181+
mapping = cmp.mapping.preset.insert {
182+
['<C-d>'] = cmp.mapping.scroll_docs(-4),
183+
['<C-f>'] = cmp.mapping.scroll_docs(4),
184+
['<C-Space>'] = cmp.mapping.complete(),
185+
['<CR>'] = cmp.mapping.confirm {
186+
behavior = cmp.ConfirmBehavior.Replace,
187+
select = true,
188+
},
189+
['<Tab>'] = cmp.mapping(function(fallback)
190+
if cmp.visible() then
191+
cmp.select_next_item()
192+
elseif luasnip.expand_or_jumpable() then
193+
luasnip.expand_or_jump()
194+
else
195+
fallback()
196+
end
197+
end, { 'i', 's' }),
198+
['<S-Tab>'] = cmp.mapping(function(fallback)
199+
if cmp.visible() then
200+
cmp.select_prev_item()
201+
elseif luasnip.jumpable(-1) then
202+
luasnip.jump(-1)
203+
else
204+
fallback()
205+
end
206+
end, { 'i', 's' }),
207+
},
208+
sources = {
209+
{ name = 'nvim_lsp' },
210+
{ name = 'luasnip' },
211+
},
212+
}
213+
214+
-- The line beneath this is called `modeline`. See `:help modeline`
215+
-- vim: ts=2 sts=2 sw=2 et

‎lua/base.lua‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-- [[ Setting options ]]
2+
-- See `:help vim.o`
3+
4+
-- encoding
5+
vim.scriptencoding = 'utf-8'
6+
vim.o.encoding = 'utf-8'
7+
vim.o.fileencoding = 'utf-8'
8+
9+
-- better ui
10+
vim.o.title = true
11+
vim.o.laststatus = 2
12+
vim.o.wrap = false
13+
14+
-- shell
15+
vim.o.shellcmdflag = "-c"
16+
vim.o.cmdheight = 1
17+
vim.o.shell = "pwsh"
18+
19+
-- Set highlight on search
20+
vim.o.hlsearch = false
21+
22+
-- Make relative line numbers default
23+
vim.wo.number = true
24+
vim.wo.relativenumber = true
25+
26+
-- Disable mouse mode
27+
vim.cmd [[set mouse=]]
28+
29+
-- indenting
30+
vim.o.autoindent = true
31+
vim.o.smartindent = true
32+
vim.o.shiftwidth = 2
33+
vim.o.tabstop = 2
34+
vim.o.softtabstop = 2
35+
vim.o.breakindent = true
36+
37+
-- Save undo history
38+
vim.o.undofile = true
39+
40+
-- Case insensitive searching UNLESS /C or capital in search
41+
vim.o.ignorecase = true
42+
vim.o.smartcase = true
43+
44+
-- Decrease update time
45+
vim.o.updatetime = 250
46+
vim.wo.signcolumn = 'yes'
47+
48+
-- Set colorscheme
49+
vim.o.termguicolors = true
50+
function ColorMyPencils(color)
51+
color = color or 'onedark'
52+
vim.cmd.colorscheme(color)
53+
54+
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
55+
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
56+
end
57+
58+
ColorMyPencils('habamax')
59+
60+
-- Set completeopt to have a better completion experience
61+
vim.o.completeopt = 'menuone,noselect'
62+
63+
-- [[ Highlight on yank ]]
64+
-- See `:help vim.highlight.on_yank()`
65+
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
66+
vim.api.nvim_create_autocmd('TextYankPost', {
67+
callback = function()
68+
vim.highlight.on_yank()
69+
end,
70+
group = highlight_group,
71+
pattern = '*',
72+
})

0 commit comments

Comments
 (0)