mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Create User Command To Open Init Config as a Neovim TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1256 TILs and counting..._
|
_1257 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@ _1256 TILs and counting..._
|
|||||||
* [Mac](#mac)
|
* [Mac](#mac)
|
||||||
* [MongoDB](#mongodb)
|
* [MongoDB](#mongodb)
|
||||||
* [MySQL](#mysql)
|
* [MySQL](#mysql)
|
||||||
|
* [Neovim](#neovim)
|
||||||
* [Netlify](#netlify)
|
* [Netlify](#netlify)
|
||||||
* [Next.js](#nextjs)
|
* [Next.js](#nextjs)
|
||||||
* [Phoenix](#phoenix)
|
* [Phoenix](#phoenix)
|
||||||
@@ -536,6 +537,10 @@ _1256 TILs and counting..._
|
|||||||
- [Show Tables That Match A Pattern](mysql/show-tables-that-match-a-pattern.md)
|
- [Show Tables That Match A Pattern](mysql/show-tables-that-match-a-pattern.md)
|
||||||
- [Show Indexes For A Table](mysql/show-indexes-for-a-table.md)
|
- [Show Indexes For A Table](mysql/show-indexes-for-a-table.md)
|
||||||
|
|
||||||
|
### Neovim
|
||||||
|
|
||||||
|
- [Create User Command To Open Init Config](neovim/create-user-command-to-open-init-config.md)
|
||||||
|
|
||||||
### Netlify
|
### Netlify
|
||||||
|
|
||||||
- [Override The Default Yarn Version](netlify/override-the-default-yarn-version.md)
|
- [Override The Default Yarn Version](netlify/override-the-default-yarn-version.md)
|
||||||
|
|||||||
27
neovim/create-user-command-to-open-init-config.md
Normal file
27
neovim/create-user-command-to-open-init-config.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Create User Command To Open Init Config
|
||||||
|
|
||||||
|
I'm experimenting with a fresh Neovim configuration using
|
||||||
|
[kickstart](https://github.com/nvim-lua/kickstart.nvim). That means I'm
|
||||||
|
frequently navigating to my `init.lua` file to add and adjust things that I
|
||||||
|
find are missing from my workflow.
|
||||||
|
|
||||||
|
I got tired of typing out the path—in my case `~/.config/nvim/init.lua`—every
|
||||||
|
single time I wanted to edit it. So, I typed out that path one last time so
|
||||||
|
that I could add a custom user command.
|
||||||
|
|
||||||
|
```
|
||||||
|
-- Open this config file
|
||||||
|
vim.api.nvim_create_user_command(
|
||||||
|
'Config',
|
||||||
|
"e ~/.config/nvim/init.lua",
|
||||||
|
{bang = true, desc = "Open init.lua Neovim config"}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
This uses [the lua command
|
||||||
|
API](https://neovim.io/doc/user/api.html#api-command) to create a user-defined
|
||||||
|
command.
|
||||||
|
|
||||||
|
When I invoke `:Config` from the Neovim command prompt and hit enter, Neovim
|
||||||
|
will effectively replace that command with the second argument to that command
|
||||||
|
— `:e ~/.config/nvim/init.lua`. Which opens me up to the config file.
|
||||||
Reference in New Issue
Block a user