Skip to content

Commit fcc054d

Browse files
committed
make modular
1 parent f421c09 commit fcc054d

File tree

3 files changed

+131
-139
lines changed

3 files changed

+131
-139
lines changed

init.lua

Lines changed: 6 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
======== ========
2020
=====================================================================
2121
=====================================================================
22-
test
22+
2323
What is Kickstart?
2424
2525
Kickstart.nvim is *not* a distribution.
@@ -84,137 +84,6 @@ I hope you enjoy your Neovim journey,
8484
P.S. You can delete this when you're done too. It's your config now! :)
8585
--]]
8686

87-
-- Set <space> as the leader key
88-
-- See `:help mapleader`
89-
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
90-
vim.g.mapleader = ' '
91-
vim.g.maplocalleader = ' '
92-
93-
-- Set to true if you have a Nerd Font installed and selected in the terminal
94-
vim.g.have_nerd_font = true
95-
96-
-- [[ Setting options ]]
97-
-- See `:help vim.opt`
98-
-- NOTE: You can change these options as you wish!
99-
-- For more options, you can see `:help option-list`
100-
101-
-- Make line numbers default
102-
vim.opt.number = true
103-
-- You can also add relative line numbers, to help with jumping.
104-
-- Experiment for yourself to see if you like it!
105-
vim.opt.relativenumber = true
106-
107-
-- Enable mouse mode, can be useful for resizing splits for example!
108-
vim.opt.mouse = 'a'
109-
110-
-- Don't show the mode, since it's already in the status line
111-
vim.opt.showmode = false
112-
113-
-- Sync clipboard between OS and Neovim.
114-
-- Remove this option if you want your OS clipboard to remain independent.
115-
-- See `:help 'clipboard'`
116-
vim.opt.clipboard = 'unnamedplus'
117-
118-
-- Enable break indent
119-
vim.opt.breakindent = true
120-
121-
-- Save undo history
122-
vim.opt.undofile = true
123-
124-
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
125-
vim.opt.ignorecase = true
126-
vim.opt.smartcase = true
127-
128-
-- Keep signcolumn on by default
129-
vim.opt.signcolumn = 'yes'
130-
131-
-- Decrease update time
132-
vim.opt.updatetime = 250
133-
134-
-- Decrease mapped sequence wait time
135-
-- Displays which-key popup sooner
136-
vim.opt.timeoutlen = 200
137-
138-
-- Configure how new splits should be opened
139-
vim.opt.splitright = true
140-
vim.opt.splitbelow = true
141-
142-
-- Sets how neovim will display certain whitespace characters in the editor.
143-
-- See `:help 'list'`
144-
-- and `:help 'listchars'`
145-
vim.opt.list = true
146-
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
147-
148-
-- Preview substitutions live, as you type!
149-
vim.opt.inccommand = 'split'
150-
151-
-- Show which line your cursor is on
152-
vim.opt.cursorline = true
153-
154-
-- Minimal number of screen lines to keep above and below the cursor.
155-
vim.opt.scrolloff = 10
156-
157-
-- [[ Basic Keymaps ]]
158-
-- See `:help vim.keymap.set()`
159-
160-
-- Set highlight on search, but clear on pressing <Esc> in normal mode
161-
vim.opt.hlsearch = true
162-
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
163-
164-
-- Diagnostic keymaps
165-
vim.keymap.set('n', '<Up>', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
166-
vim.keymap.set('n', '<Down>', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
167-
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
168-
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
169-
170-
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
171-
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
172-
-- is not what someone will guess without a bit more experience.
173-
--
174-
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
175-
-- or just use <C-\><C-n> to exit terminal mode
176-
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
177-
178-
-- Custom
179-
vim.keymap.set('n', 'c*', '*``cgn')
180-
vim.keymap.set('n', 'c#', '*``cgN')
181-
vim.keymap.set('n', 'c#', '*``cgN')
182-
vim.api.nvim_set_keymap('n', '<C-t>', ':lua InsertTodo()<CR>', { noremap = true, silent = true })
183-
vim.api.nvim_set_keymap('i', '<C-t>', '// todo: ', { noremap = true, silent = true })
184-
185-
-- TIP: Disable arrow keys in normal mode
186-
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
187-
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
188-
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
189-
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
190-
191-
-- Keybinds to make split navigation easier.
192-
-- Use CTRL+<hjkl> to switch between windows
193-
--
194-
-- See `:help wincmd` for a list of all window commands
195-
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
196-
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
197-
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
198-
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
199-
200-
-- [[ Basic Autocommands ]]
201-
-- See `:help lua-guide-autocommands`
202-
203-
-- Highlight when yanking (copying) text
204-
-- Try it with `yap` in normal mode
205-
-- See `:help vim.highlight.on_yank()`
206-
vim.api.nvim_create_autocmd('TextYankPost', {
207-
desc = 'Highlight when yanking (copying) text',
208-
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
209-
callback = function()
210-
vim.highlight.on_yank()
211-
end,
212-
})
213-
214-
function InsertTodo()
215-
vim.api.nvim_put({ '// todo: ' }, 'l', true, true)
216-
end
217-
21887
-- [[ Install `lazy.nvim` plugin manager ]]
21988
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
22089
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
@@ -228,12 +97,10 @@ vim.opt.rtp:prepend(lazypath)
22897
--
22998
-- To check the current status of your plugins, run
23099
-- :Lazy
231-
--
232-
-- You can press `?` in this menu for help. Use `:q` to close the window
233-
--
234-
-- To update plugins you can run
235-
-- :Lazy update
236-
--
100+
101+
require 'keymaps'
102+
require 'functions'
103+
237104
-- NOTE: Here is where you install your plugins.
238105
require('lazy').setup({
239106
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
@@ -267,7 +134,7 @@ require('lazy').setup({
267134
-- a lot faster to initialize.
268135
-- filewatching = true,
269136
filewatching = false,
270-
commit = 'c4d36a00852be07ef34768cf9da6cac94b13aeff',
137+
-- commit = 'c4d36a00852be07ef34768cf9da6cac94b13aeff',
271138
},
272139
-- "gc" to comment visual regions/lines
273140
{ 'numToStr/Comment.nvim', opts = {} },

lua/functions.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function InsertTodo()
2+
vim.api.nvim_put({ '// todo: ' }, 'l', true, true)
3+
end
4+
5+
function InsertId()
6+
vim.api.nvim_put({ '[Id()]' }, 'l', true, true)
7+
end

lua/keymaps.lua

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
vim.g.mapleader = ' '
2+
vim.g.maplocalleader = ' '
3+
4+
-- Set to true if you have a Nerd Font installed and selected in the terminal
5+
vim.g.have_nerd_font = true
6+
7+
-- [[ Setting options ]]
8+
-- See `:help vim.opt`
9+
-- NOTE: You can change these options as you wish!
10+
-- For more options, you can see `:help option-list`
11+
12+
-- Make line numbers default
13+
vim.opt.number = true
14+
-- You can also add relative line numbers, to help with jumping.
15+
-- Experiment for yourself to see if you like it!
16+
vim.opt.relativenumber = true
17+
18+
-- Enable mouse mode, can be useful for resizing splits for example!
19+
vim.opt.mouse = 'a'
20+
21+
-- Don't show the mode, since it's already in the status line
22+
vim.opt.showmode = false
23+
24+
-- Sync clipboard between OS and Neovim.
25+
-- Remove this option if you want your OS clipboard to remain independent.
26+
-- See `:help 'clipboard'`
27+
vim.opt.clipboard = 'unnamedplus'
28+
29+
-- Enable break indent
30+
vim.opt.breakindent = true
31+
32+
-- Save undo history
33+
vim.opt.undofile = true
34+
35+
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
36+
vim.opt.ignorecase = true
37+
vim.opt.smartcase = true
38+
39+
-- Keep signcolumn on by default
40+
vim.opt.signcolumn = 'yes'
41+
42+
-- Decrease update time
43+
vim.opt.updatetime = 250
44+
45+
-- Decrease mapped sequence wait time
46+
-- Displays which-key popup sooner
47+
vim.opt.timeoutlen = 200
48+
49+
-- Configure how new splits should be opened
50+
vim.opt.splitright = true
51+
vim.opt.splitbelow = true
52+
53+
-- Sets how neovim will display certain whitespace characters in the editor.
54+
-- See `:help 'list'`
55+
-- and `:help 'listchars'`
56+
vim.opt.list = true
57+
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
58+
59+
-- Preview substitutions live, as you type!
60+
vim.opt.inccommand = 'split'
61+
62+
-- Show which line your cursor is on
63+
vim.opt.cursorline = true
64+
65+
-- Minimal number of screen lines to keep above and below the cursor.
66+
vim.opt.scrolloff = 15
67+
68+
-- [[ Basic Keymaps ]]
69+
-- See `:help vim.keymap.set()`
70+
71+
-- Set highlight on search, but clear on pressing <Esc> in normal mode
72+
vim.opt.hlsearch = true
73+
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
74+
75+
-- Diagnostic keymaps
76+
vim.keymap.set('n', '<Up>', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
77+
vim.keymap.set('n', '<Down>', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
78+
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
79+
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
80+
81+
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
82+
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
83+
-- is not what someone will guess without a bit more experience.
84+
--
85+
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
86+
-- or just use <C-\><C-n> to exit terminal mode
87+
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
88+
89+
-- [[ Custom ]]
90+
vim.keymap.set('n', 'c*', '*``cgn')
91+
vim.keymap.set('n', 'c#', '*``cgN')
92+
vim.keymap.set('n', 'c#', '*``cgN')
93+
94+
vim.keymap.set('n', 'L', '$')
95+
vim.keymap.set('n', 'H', '^')
96+
97+
vim.api.nvim_set_keymap('n', '<C-t>', ':lua InsertTodo()<CR>', { noremap = true, silent = true })
98+
vim.api.nvim_set_keymap('i', '<C-t>', '// todo: ', { noremap = true, silent = true })
99+
100+
vim.api.nvim_set_keymap('n', '<C-i>', ':lua InsertId()<CR>', { noremap = true, silent = true })
101+
vim.api.nvim_set_keymap('i', '<C-i>', '[Id()]', { noremap = true, silent = true })
102+
103+
-- See `:help wincmd` for a list of all window commands
104+
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
105+
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
106+
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
107+
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
108+
109+
-- Highlight when yanking (copying) text
110+
-- Try it with `yap` in normal mode
111+
-- See `:help vim.highlight.on_yank()`
112+
vim.api.nvim_create_autocmd('TextYankPost', {
113+
desc = 'Highlight when yanking (copying) text',
114+
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
115+
callback = function()
116+
vim.highlight.on_yank()
117+
end,
118+
})

0 commit comments

Comments
 (0)