Skip to content

Commit 20c6a71

Browse files
committed
init change
1 parent a229761 commit 20c6a71

File tree

1 file changed

+64
-145
lines changed

1 file changed

+64
-145
lines changed

init.lua

Lines changed: 64 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,11 @@
1-
--[[
2-
3-
=====================================================================
4-
==================== READ THIS BEFORE CONTINUING ====================
5-
=====================================================================
6-
======== .-----. ========
7-
======== .----------------------. | === | ========
8-
======== |.-""""""""""""""""""-.| |-----| ========
9-
======== || || | === | ========
10-
======== || KICKSTART.NVIM || |-----| ========
11-
======== || || | === | ========
12-
======== || || |-----| ========
13-
======== ||:Tutor || |:::::| ========
14-
======== |'-..................-'| |____o| ========
15-
======== `"")----------------(""` ___________ ========
16-
======== /::::::::::| |::::::::::\ \ no mouse \ ========
17-
======== /:::========| |==hjkl==:::\ \ required \ ========
18-
======== '""""""""""""' '""""""""""""' '""""""""""' ========
19-
======== ========
20-
=====================================================================
21-
=====================================================================
22-
23-
What is Kickstart?
24-
25-
Kickstart.nvim is *not* a distribution.
26-
27-
Kickstart.nvim is a starting point for your own configuration.
28-
The goal is that you can read every line of code, top-to-bottom, understand
29-
what your configuration is doing, and modify it to suit your needs.
30-
31-
Once you've done that, you can start exploring, configuring and tinkering to
32-
make Neovim your own! That might mean leaving Kickstart just the way it is for a while
33-
or immediately breaking it into modular pieces. It's up to you!
34-
35-
If you don't know anything about Lua, I recommend taking some time to read through
36-
a guide. One possible example which will only take 10-15 minutes:
37-
- https://learnxinyminutes.com/docs/lua/
38-
39-
After understanding a bit more about Lua, you can use `:help lua-guide` as a
40-
reference for how Neovim integrates Lua.
41-
- :help lua-guide
42-
- (or HTML version): https://neovim.io/doc/user/lua-guide.html
43-
44-
Kickstart Guide:
45-
46-
TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.
47-
48-
If you don't know what this means, type the following:
49-
- <escape key>
50-
- :
51-
- Tutor
52-
- <enter key>
53-
54-
(If you already know the Neovim basics, you can skip this step.)
55-
56-
Once you've completed that, you can continue working through **AND READING** the rest
57-
of the kickstart init.lua.
58-
59-
Next, run AND READ `:help`.
60-
This will open up a help window with some basic information
61-
about reading, navigating and searching the builtin help documentation.
62-
63-
This should be the first place you go to look when you're stuck or confused
64-
with something. It's one of my favorite Neovim features.
65-
66-
MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation,
67-
which is very useful when you're not exactly sure of what you're looking for.
68-
69-
I have left several `:help X` comments throughout the init.lua
70-
These are hints about where to find more information about the relevant settings,
71-
plugins or Neovim features used in Kickstart.
72-
73-
NOTE: Look for lines like this
74-
75-
Throughout the file. These are for you, the reader, to help you understand what is happening.
76-
Feel free to delete them once you know what you're doing, but they should serve as a guide
77-
for when you are first encountering a few different constructs in your Neovim config.
78-
79-
If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.
80-
81-
I hope you enjoy your Neovim journey,
82-
- TJ
83-
84-
P.S. You can delete this when you're done too. It's your config now! :)
85-
--]]
86-
871
-- Set <space> as the leader key
882
-- See `:help mapleader`
893
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
904
vim.g.mapleader = ' '
915
vim.g.maplocalleader = ' '
926

937
-- Set to true if you have a Nerd Font installed and selected in the terminal
94-
vim.g.have_nerd_font = false
8+
vim.g.have_nerd_font = true
959

9610
-- [[ Setting options ]]
9711
-- See `:help vim.opt`
@@ -102,7 +16,7 @@ vim.g.have_nerd_font = false
10216
vim.opt.number = true
10317
-- You can also add relative line numbers, to help with jumping.
10418
-- Experiment for yourself to see if you like it!
105-
-- vim.opt.relativenumber = true
19+
vim.opt.relativenumber = true
10620

10721
-- Enable mouse mode, can be useful for resizing splits for example!
10822
vim.opt.mouse = 'a'
@@ -175,11 +89,8 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
17589
-- or just use <C-\><C-n> to exit terminal mode
17690
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
17791

178-
-- TIP: Disable arrow keys in normal mode
179-
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
180-
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
181-
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
182-
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
92+
--NVIM Tree
93+
vim.keymap.set('n', '<leader>e', '<cmd>NvimTreeToggle<CR>')
18394

18495
-- Keybinds to make split navigation easier.
18596
-- Use CTRL+<hjkl> to switch between windows
@@ -255,6 +166,17 @@ require('lazy').setup({
255166
},
256167
},
257168
},
169+
{
170+
'nvim-tree/nvim-tree.lua',
171+
version = '*',
172+
lazy = false,
173+
dependencies = {
174+
'nvim-tree/nvim-web-devicons',
175+
},
176+
config = function()
177+
require('nvim-tree').setup {}
178+
end,
179+
},
258180

259181
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
260182
--
@@ -274,55 +196,57 @@ require('lazy').setup({
274196
{ -- Useful plugin to show you pending keybinds.
275197
'folke/which-key.nvim',
276198
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
277-
opts = {
278-
icons = {
279-
-- set icon mappings to true if you have a Nerd Font
280-
mappings = vim.g.have_nerd_font,
281-
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
282-
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
283-
keys = vim.g.have_nerd_font and {} or {
284-
Up = '<Up> ',
285-
Down = '<Down> ',
286-
Left = '<Left> ',
287-
Right = '<Right> ',
288-
C = '<C-…> ',
289-
M = '<M-…> ',
290-
D = '<D-…> ',
291-
S = '<S-…> ',
292-
CR = '<CR> ',
293-
Esc = '<Esc> ',
294-
ScrollWheelDown = '<ScrollWheelDown> ',
295-
ScrollWheelUp = '<ScrollWheelUp> ',
296-
NL = '<NL> ',
297-
BS = '<BS> ',
298-
Space = '<Space> ',
299-
Tab = '<Tab> ',
300-
F1 = '<F1>',
301-
F2 = '<F2>',
302-
F3 = '<F3>',
303-
F4 = '<F4>',
304-
F5 = '<F5>',
305-
F6 = '<F6>',
306-
F7 = '<F7>',
307-
F8 = '<F8>',
308-
F9 = '<F9>',
309-
F10 = '<F10>',
310-
F11 = '<F11>',
311-
F12 = '<F12>',
199+
config = function() -- This is the function that runs, AFTER loading
200+
require('which-key').setup {
201+
icons = {
202+
-- set icon mappings to true if you have a Nerd Font
203+
mappings = vim.g.have_nerd_font,
204+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
205+
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
206+
keys = vim.g.have_nerd_font and {} or {
207+
Up = '<Up> ',
208+
Down = '<Down> ',
209+
Left = '<Left> ',
210+
Right = '<Right> ',
211+
C = '<C-…> ',
212+
M = '<M-…> ',
213+
D = '<D-…> ',
214+
S = '<S-…> ',
215+
CR = '<CR> ',
216+
Esc = '<Esc> ',
217+
ScrollWheelDown = '<ScrollWheelDown> ',
218+
ScrollWheelUp = '<ScrollWheelUp> ',
219+
NL = '<NL> ',
220+
BS = '<BS> ',
221+
Space = '<Space> ',
222+
Tab = '<Tab> ',
223+
F1 = '<F1>',
224+
F2 = '<F2>',
225+
F3 = '<F3>',
226+
F4 = '<F4>',
227+
F5 = '<F5>',
228+
F6 = '<F6>',
229+
F7 = '<F7>',
230+
F8 = '<F8>',
231+
F9 = '<F9>',
232+
F10 = '<F10>',
233+
F11 = '<F11>',
234+
F12 = '<F12>',
235+
},
312236
},
313-
},
237+
}
314238

315239
-- Document existing key chains
316-
spec = {
240+
require('which-key').add {
317241
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
318242
{ '<leader>d', group = '[D]ocument' },
319243
{ '<leader>r', group = '[R]ename' },
320244
{ '<leader>s', group = '[S]earch' },
321245
{ '<leader>w', group = '[W]orkspace' },
322246
{ '<leader>t', group = '[T]oggle' },
323247
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
324-
},
325-
},
248+
}
249+
end,
326250
},
327251

328252
-- NOTE: Plugins can specify dependencies.
@@ -605,9 +529,9 @@ require('lazy').setup({
605529
-- - settings (table): Override the default settings passed when initializing the server.
606530
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
607531
local servers = {
608-
-- clangd = {},
532+
clangd = {},
609533
-- gopls = {},
610-
-- pyright = {},
534+
pyright = {},
611535
-- rust_analyzer = {},
612536
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
613537
--
@@ -647,6 +571,7 @@ require('lazy').setup({
647571
local ensure_installed = vim.tbl_keys(servers or {})
648572
vim.list_extend(ensure_installed, {
649573
'stylua', -- Used to format Lua code
574+
'clang-format',
650575
})
651576
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
652577

@@ -673,7 +598,7 @@ require('lazy').setup({
673598
{
674599
'<leader>f',
675600
function()
676-
require('conform').format { async = true, lsp_format = 'fallback' }
601+
require('conform').format { async = true, lsp_fallback = true }
677602
end,
678603
mode = '',
679604
desc = '[F]ormat buffer',
@@ -686,15 +611,9 @@ require('lazy').setup({
686611
-- have a well standardized coding style. You can add additional
687612
-- languages here or re-enable it for the disabled ones.
688613
local disable_filetypes = { c = true, cpp = true }
689-
local lsp_format_opt
690-
if disable_filetypes[vim.bo[bufnr].filetype] then
691-
lsp_format_opt = 'never'
692-
else
693-
lsp_format_opt = 'fallback'
694-
end
695614
return {
696615
timeout_ms = 500,
697-
lsp_format = lsp_format_opt,
616+
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
698617
}
699618
end,
700619
formatters_by_ft = {
@@ -779,9 +698,9 @@ require('lazy').setup({
779698

780699
-- If you prefer more traditional completion keymaps,
781700
-- you can uncomment the following lines
782-
--['<CR>'] = cmp.mapping.confirm { select = true },
783-
--['<Tab>'] = cmp.mapping.select_next_item(),
784-
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
701+
['<CR>'] = cmp.mapping.confirm { select = true },
702+
['<Tab>'] = cmp.mapping.select_next_item(),
703+
['<S-Tab>'] = cmp.mapping.select_prev_item(),
785704

786705
-- Manually trigger a completion from nvim-cmp.
787706
-- Generally you don't need this, because nvim-cmp will display

0 commit comments

Comments
 (0)