structure updates
This commit is contained in:
97
tech_docs/linux/Neovim-Configuration-with-Lua.md
Normal file
97
tech_docs/linux/Neovim-Configuration-with-Lua.md
Normal file
@@ -0,0 +1,97 @@
|
||||
## Initialization (`init.lua`)
|
||||
- **Create `init.lua`**:
|
||||
```bash
|
||||
touch ~/.config/nvim/init.lua
|
||||
```
|
||||
This command creates a new file named `init.lua` in your Neovim configuration directory, which will store your custom settings.
|
||||
|
||||
- **Basic Settings in `init.lua`**:
|
||||
```lua
|
||||
vim.o.number = true -- Enable line numbers
|
||||
vim.cmd('syntax enable') -- Enable syntax highlighting
|
||||
```
|
||||
These lines set basic Neovim options: enabling line numbers and syntax highlighting, which are essential for better readability and coding efficiency.
|
||||
|
||||
## Modular Setup
|
||||
- **Create Modules**:
|
||||
- Make Lua files like `keymaps.lua`, `plugins.lua` in `~/.config/nvim/lua/`. This modular approach allows you to organize your configuration efficiently. For example, `keymaps.lua` can hold all your keybindings, while `plugins.lua` can manage your plugin configurations.
|
||||
|
||||
- **Include Modules in `init.lua`**:
|
||||
```lua
|
||||
require('keymaps')
|
||||
require('plugins')
|
||||
```
|
||||
These lines in your `init.lua` file load the modules you created. It keeps your main configuration file clean and your settings organized.
|
||||
|
||||
## Plugin Management
|
||||
- **Install Packer**:
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
|
||||
~/.local/share/nvim/site/pack/packer/start/packer.nvim
|
||||
```
|
||||
Packer is a plugin manager for Neovim. This command installs Packer, allowing you to easily add, update, and manage your Neovim plugins.
|
||||
|
||||
- **Define Plugins in `plugins.lua`**:
|
||||
```lua
|
||||
use {'neovim/nvim-lspconfig', config = function() require('lsp') end}
|
||||
```
|
||||
Here, you're telling Packer to use the `nvim-lspconfig` plugin. This plugin is used for configuring LSP (Language Server Protocol), which provides features like auto-completion, code navigation, and syntax checking.
|
||||
|
||||
## Key Mappings (`keymaps.lua`)
|
||||
- **Global Mappings Example**:
|
||||
```lua
|
||||
vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>', {noremap = true})
|
||||
```
|
||||
This code maps `<Leader>f` to `Telescope find_files` in normal mode, enabling you to quickly search for files.
|
||||
|
||||
- **Mode-Specific Mappings Example**:
|
||||
```lua
|
||||
vim.api.nvim_set_keymap('i', 'jj', '<Esc>', {noremap = true})
|
||||
```
|
||||
This snippet maps `jj` to `<Esc>` in insert mode, providing a quick way to exit insert mode.
|
||||
|
||||
## LSP and Autocomplete (`lsp.lua`)
|
||||
- **Configure LSP Client**:
|
||||
```lua
|
||||
require'lspconfig'.pyright.setup{}
|
||||
```
|
||||
This line sets up an LSP client for Python using `pyright`. LSPs are crucial for advanced coding assistance like error detection and code suggestions.
|
||||
|
||||
- **Setup Autocomplete**:
|
||||
- Use a plugin like `nvim-compe` for autocomplete. This plugin offers intelligent code completion, which is a huge productivity boost.
|
||||
|
||||
# Tmux Configuration
|
||||
|
||||
## Basic Configuration (`tmux.conf`)
|
||||
- **Create/Edit `.tmux.conf`**:
|
||||
```bash
|
||||
touch ~/.tmux.conf
|
||||
```
|
||||
This creates or edits your Tmux configuration file, where you can customize Tmux to your liking.
|
||||
|
||||
- **Set Global Options in `.tmux.conf`**:
|
||||
```
|
||||
set-option -g prefix C-a
|
||||
set -g status-right 'Battery: #{battery_percentage}'
|
||||
```
|
||||
These commands change the default prefix key to `Ctrl-a` and add a battery status indicator to the right side of the status line.
|
||||
|
||||
## Lua Scripting for Tmux
|
||||
- **Write Lua Scripts** to generate dynamic Tmux commands.
|
||||
- **Run Scripts** to update your `.tmux.conf`. For example, a Lua script can be written to adjust the status line based on time of day or system status.
|
||||
|
||||
## Key Bindings and Session Management
|
||||
- **Add Key Bindings in `.tmux.conf`** for efficient navigation. For instance, binding keys for splitting panes or switching between them can significantly speed up your workflow.
|
||||
- **Script Session Setups**: Create scripts for predefined layouts and windows, enabling you to launch complex Tmux environments with a single command.
|
||||
|
||||
## Status Line Customization
|
||||
- **Use Lua Scripts** for dynamic status line updates in Tmux, like changing colors or displaying contextual information.
|
||||
|
||||
## Performance and Testing
|
||||
- **Regularly Review** your configurations for performance impacts. This includes monitoring load times and responsiveness.
|
||||
- **Test Config
|
||||
ChatGPT
|
||||
urations** in a separate tmux session to ensure your changes work as expected without disrupting your current workflow.
|
||||
|
||||
## Troubleshooting and FAQs
|
||||
- **Include a Section**: Adding a troubleshooting section or an FAQ can help users resolve common issues they might encounter while configuring Neovim or Tmux.
|
||||
Reference in New Issue
Block a user