File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
12
12
13
- _ 1256 TILs and counting..._
13
+ _ 1257 TILs and counting..._
14
14
15
15
---
16
16
@@ -40,6 +40,7 @@ _1256 TILs and counting..._
40
40
* [ Mac] ( #mac )
41
41
* [ MongoDB] ( #mongodb )
42
42
* [ MySQL] ( #mysql )
43
+ * [ Neovim] ( #neovim )
43
44
* [ Netlify] ( #netlify )
44
45
* [ Next.js] ( #nextjs )
45
46
* [ Phoenix] ( #phoenix )
@@ -536,6 +537,10 @@ _1256 TILs and counting..._
536
537
- [ Show Tables That Match A Pattern] ( mysql/show-tables-that-match-a-pattern.md )
537
538
- [ Show Indexes For A Table] ( mysql/show-indexes-for-a-table.md )
538
539
540
+ ### Neovim
541
+
542
+ - [ Create User Command To Open Init Config] ( neovim/create-user-command-to-open-init-config.md )
543
+
539
544
### Netlify
540
545
541
546
- [ Override The Default Yarn Version] ( netlify/override-the-default-yarn-version.md )
Original file line number Diff line number Diff line change
1
+ # Create User Command To Open Init Config
2
+
3
+ I'm experimenting with a fresh Neovim configuration using
4
+ [ kickstart] ( https://github.com/nvim-lua/kickstart.nvim ) . That means I'm
5
+ frequently navigating to my ` init.lua ` file to add and adjust things that I
6
+ find are missing from my workflow.
7
+
8
+ I got tired of typing out the path—in my case ` ~/.config/nvim/init.lua ` —every
9
+ single time I wanted to edit it. So, I typed out that path one last time so
10
+ that I could add a custom user command.
11
+
12
+ ```
13
+ -- Open this config file
14
+ vim.api.nvim_create_user_command(
15
+ 'Config',
16
+ "e ~/.config/nvim/init.lua",
17
+ {bang = true, desc = "Open init.lua Neovim config"}
18
+ )
19
+ ```
20
+
21
+ This uses [ the lua command
22
+ API] ( https://neovim.io/doc/user/api.html#api-command ) to create a user-defined
23
+ command.
24
+
25
+ When I invoke ` :Config ` from the Neovim command prompt and hit enter, Neovim
26
+ will effectively replace that command with the second argument to that command
27
+ — ` :e ~/.config/nvim/init.lua ` . Which opens me up to the config file.
You can’t perform that action at this time.
0 commit comments