mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-25 02:41:26 +01:00
fix: neovim
This commit is contained in:
168
flake.lock
generated
168
flake.lock
generated
@@ -50,11 +50,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688882536,
|
||||
"narHash": "sha256-JXhHLy3+OxRghen7X8no1/8Ab+NkYSxrCIB9IILKUUc=",
|
||||
"lastModified": 1688999459,
|
||||
"narHash": "sha256-b0rFzeHWXGq2rrx+W93I1Lpb0HFq0T5Pfx7QLVcZ/jE=",
|
||||
"owner": "lnl7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "4e3fc1864712a534d30ef074d695e968f1fb1487",
|
||||
"rev": "83620edf499ba8033ad43d4f5edc50fdf3eeee5f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -104,24 +104,6 @@
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687709756,
|
||||
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
|
||||
@@ -223,15 +205,15 @@
|
||||
},
|
||||
"lib-aggregate": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688299754,
|
||||
"narHash": "sha256-ElNJ28wfORNv8JaCOFb/mniLiQe0cpuaj2DdD/dqdKw=",
|
||||
"lastModified": 1688904595,
|
||||
"narHash": "sha256-ZEEDxrc7WSa3A1CBY6M+gwdnybYWBlu2Dhd7jLiTaUs=",
|
||||
"owner": "nix-community",
|
||||
"repo": "lib-aggregate",
|
||||
"rev": "6107c923522c233458760d0c7f31ad71bf1d2146",
|
||||
"rev": "f451e910531a7dd731ab4c25174b23a2d320fe4d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -240,38 +222,17 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nil": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_3",
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1683653883,
|
||||
"narHash": "sha256-Xg3Cux5wQDatXRvQWsVD0YPfmxfijjG8+gxYqgoT6JE=",
|
||||
"owner": "oxalica",
|
||||
"repo": "nil",
|
||||
"rev": "18de045d7788df2343aec58df7b85c10d1f5d5dd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"ref": "2023-05-09",
|
||||
"repo": "nil",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-eval-jobs": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs_5"
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688608231,
|
||||
"narHash": "sha256-RQeR/tirHIa5jhZYLCK7KnQiYTG/kq/vWdgDFLi+4+g=",
|
||||
"lastModified": 1688953990,
|
||||
"narHash": "sha256-835HVBBkaumj8b098dC7u4fOGBMsIsnYitRYNQkb+jA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-eval-jobs",
|
||||
"rev": "477d7196a493dd011f05704fc7b42cbe95f5b30d",
|
||||
"rev": "4006da54d54e1243da26ad4d75d6b4c9f7a456ba",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -334,11 +295,11 @@
|
||||
},
|
||||
"nixpkgs-darwin": {
|
||||
"locked": {
|
||||
"lastModified": 1688825351,
|
||||
"narHash": "sha256-XKrQsDLF/XvKbuF7j6ihcIpLFk2zB6yMa/RmEi5s3bc=",
|
||||
"lastModified": 1688939073,
|
||||
"narHash": "sha256-jYhYjeK5s6k8QS3i+ovq9VZqBJaWbxm7awTKNhHL9d0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3dce5e9104d5a1658b8edc0900c916f6b0853648",
|
||||
"rev": "8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -350,11 +311,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1688259758,
|
||||
"narHash": "sha256-CYVbYQfIm3vwciCf6CCYE+WOOLE3vcfxfEfNHIfKUJQ=",
|
||||
"lastModified": 1688864644,
|
||||
"narHash": "sha256-rk7VVprLetgpG3yv/Y7QpIBKNwgX4DMXShiFoZs+LZ4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "a92befce80a487380ea5e92ae515fe33cebd3ac6",
|
||||
"rev": "c413648b507efb6df90a8aaa87500364c9e962cc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -365,11 +326,11 @@
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1688679045,
|
||||
"narHash": "sha256-t3xGEfYIwhaLTPU8FLtN/pLPytNeDwbLI6a7XFFBlGo=",
|
||||
"lastModified": 1688918189,
|
||||
"narHash": "sha256-f8ZlJ67LgEUDnN7ZsAyd1/Fyby1VdOXWg4XY/irSGrQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3c7487575d9445185249a159046cc02ff364bff8",
|
||||
"rev": "408c0e8c15a1c9cf5c3226931b6f283c9867c484",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -384,14 +345,14 @@
|
||||
"flake-compat": "flake-compat",
|
||||
"lib-aggregate": "lib-aggregate",
|
||||
"nix-eval-jobs": "nix-eval-jobs",
|
||||
"nixpkgs": "nixpkgs_6"
|
||||
"nixpkgs": "nixpkgs_5"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688890783,
|
||||
"narHash": "sha256-mfGfmi9XCdquoCbkNEQ+TWObiYKpB/FkYEF9nikL77g=",
|
||||
"lastModified": 1688987658,
|
||||
"narHash": "sha256-hKvYJwjbo3JtJzX0X8bUGWmiDmGBlnL8Lln+YRXmjF8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "3941f76246a0429d4b1f196f5e219138f82da64e",
|
||||
"rev": "d78e947b1770490bac0d6dfaa89bd62314e91d73",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -418,27 +379,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1682929865,
|
||||
"narHash": "sha256-jxVrgnf5QNjO+XoxDxUWtN2G5xyJSGZ5SWDQFxMuHxc=",
|
||||
"lastModified": 1688939073,
|
||||
"narHash": "sha256-jYhYjeK5s6k8QS3i+ovq9VZqBJaWbxm7awTKNhHL9d0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f2e9a130461950270f87630b11132323706b4d91",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1688764204,
|
||||
"narHash": "sha256-FsvK+tIvelCI0tWwlMDKfiyb7P/KfxpGbXMrdCKiT8s=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d8bb6c681cf86265fdcf3cc3119f757bbb085835",
|
||||
"rev": "8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -448,13 +393,13 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_5": {
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1688607075,
|
||||
"narHash": "sha256-KDWpwZ4xl4au5R+A+Ka+uVbyiwMDVczjwRTSqBOyqWM=",
|
||||
"lastModified": 1688951312,
|
||||
"narHash": "sha256-0oG4uv60m5+oOMqgYYQ3ao3OK3YP3n3t7nWFtuyR/uQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ff81c24d1dd4dc3698aeb27d2cc3991124e627e6",
|
||||
"rev": "2a5f6cac357616d2596167d0631b4ca729e9a3ea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -464,13 +409,13 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_6": {
|
||||
"nixpkgs_5": {
|
||||
"locked": {
|
||||
"lastModified": 1688679045,
|
||||
"narHash": "sha256-t3xGEfYIwhaLTPU8FLtN/pLPytNeDwbLI6a7XFFBlGo=",
|
||||
"lastModified": 1688918189,
|
||||
"narHash": "sha256-f8ZlJ67LgEUDnN7ZsAyd1/Fyby1VdOXWg4XY/irSGrQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3c7487575d9445185249a159046cc02ff364bff8",
|
||||
"rev": "408c0e8c15a1c9cf5c3226931b6f283c9867c484",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -486,39 +431,13 @@
|
||||
"darwin": "darwin_2",
|
||||
"home-manager": "home-manager_2",
|
||||
"hyprland": "hyprland",
|
||||
"nil": "nil",
|
||||
"nixos-generators": "nixos-generators",
|
||||
"nixpkgs": "nixpkgs_4",
|
||||
"nixpkgs": "nixpkgs_3",
|
||||
"nixpkgs-darwin": "nixpkgs-darwin",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"nixpkgs-wayland": "nixpkgs-wayland"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nil",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nil",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682907601,
|
||||
"narHash": "sha256-FfUAYvRJ+6s9WWjXNPdRzuuvAeu2VHIXIbUkPJr4t14=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "5eaff055dd57128c53ae373dc96af944f5849daa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
@@ -534,21 +453,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"wlroots": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
||||
@@ -71,9 +71,6 @@
|
||||
|
||||
# secrets management, lock with git commit at 2023/5/15
|
||||
agenix.url = "github:ryantm/agenix/db5637d10f797bb251b94ef9040b237f4702cde3";
|
||||
|
||||
# nix language server, used by vscode & neovim
|
||||
nil.url = "github:oxalica/nil/2023-05-09";
|
||||
};
|
||||
|
||||
# The `outputs` function will return all the build results of the flake.
|
||||
|
||||
1
flakes
1
flakes
Submodule flakes deleted from 1c6bfb0789
@@ -2,6 +2,7 @@
|
||||
{
|
||||
imports = [
|
||||
../server
|
||||
./neovim
|
||||
|
||||
./development.nix
|
||||
./media.nix
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, nil, ... }:
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
#############################################################
|
||||
@@ -12,12 +12,6 @@
|
||||
#############################################################
|
||||
|
||||
home.packages = with pkgs; [
|
||||
nil.packages."${pkgs.system}".default # nix language server
|
||||
|
||||
# IDE
|
||||
jetbrains.pycharm-community
|
||||
jetbrains.idea-community
|
||||
|
||||
# cloud native
|
||||
skopeo
|
||||
docker-compose
|
||||
@@ -38,19 +32,9 @@
|
||||
|
||||
# DO NOT install build tools for C/C++, set it per project by devShell instead
|
||||
gnumake # used by this repo, to simplify the deployment
|
||||
clang-tools
|
||||
clang-analyzer
|
||||
|
||||
# Golang
|
||||
go
|
||||
delve
|
||||
gopls
|
||||
|
||||
# Rust
|
||||
rustup
|
||||
|
||||
# python
|
||||
(python310.withPackages (ps: with ps; [
|
||||
(python311.withPackages (ps: with ps; [
|
||||
ipython
|
||||
pandas
|
||||
requests
|
||||
|
||||
122
home/base/desktop/neovim/README.md
Normal file
122
home/base/desktop/neovim/README.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# Neovim
|
||||
|
||||
Based on [nvimdev/dope](https://github.com/nvimdev/dope)
|
||||
|
||||
Fast speed and modernity.
|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
├── init.lua
|
||||
├── lua
|
||||
│ ├── core
|
||||
│ │ ├── cli.lua
|
||||
│ │ ├── helper.lua
|
||||
│ │ ├── init.lua
|
||||
│ │ ├── keymap.lua
|
||||
│ │ ├── options.lua
|
||||
│ │ └── pack.lua
|
||||
│ ├── keymap
|
||||
│ │ ├── config.lua
|
||||
│ │ └── init.lua
|
||||
│ └── modules
|
||||
│ ├── completion
|
||||
│ │ ├── config.lua
|
||||
│ │ └── package.lua
|
||||
│ ├── editor
|
||||
│ │ ├── config.lua
|
||||
│ │ └── package.lua
|
||||
│ ├── tools
|
||||
│ │ ├── config.lua
|
||||
│ │ └── package.lua
|
||||
│ └── ui
|
||||
│ ├── config.lua
|
||||
│ └── package.lua
|
||||
├── snippets
|
||||
│ ├── lua.json
|
||||
│ ├── lua.lua
|
||||
│ └── package.json
|
||||
```
|
||||
|
||||
- `core` heart of dope it include the api of dope
|
||||
- `modlues` plugin module and config in this folder
|
||||
- `snippets` vscode snippets json file
|
||||
|
||||
## Usage
|
||||
|
||||
- Click button `Use this template` It will generate a new repo based on dope on your GitHub
|
||||
|
||||
### Cli tool
|
||||
|
||||
`bin/dope` is a cli tool for dope config. run `./bin/dope help` check more detail
|
||||
|
||||
you can use `/bin/dope debug ui,editor` for debug modues. when you get trouble
|
||||
this is useful for your debug, this command mean disable `ui editor` modules.Then
|
||||
the plugins in `ui,editor` modules not load.
|
||||
|
||||
## How to install plugins
|
||||
|
||||
dope use [lazy.nvim](https://github.com/folk/lazy.nvim) as package management plugin. register a plugin in `package.lua` by using dope api `require('core.pack').package`. more usage check the
|
||||
lazy.nvim doc and you can some examples in package.lua file.
|
||||
|
||||
### How to create module
|
||||
|
||||
create a fold inside `modlues` folder and `package.lua` file you must created inside your module.
|
||||
dope will auto read this file at startup.
|
||||
|
||||
### How to config keymap
|
||||
|
||||
In dope there are some apis that make it easy to set keymap. All apis are defined in `core/keymap.lua`.
|
||||
|
||||
```lua
|
||||
keymap.(n/i/c/v/x/t)map -- function to generate keymap by vim.keymap.set
|
||||
keymap.new_opts -- generate opts into vim.keymap.set
|
||||
-- function type that work with keymap.new_opts
|
||||
keymap.silent keymap.noremap keymap.expr keymap.nowait keymap.remap
|
||||
keymap.cmd -- just return string with <Cmd> and <CR>
|
||||
keymap.cu -- work like cmd but for visual map
|
||||
```
|
||||
|
||||
Use these apis to config your keymap in `keymap` folder. In this folder `keymap/init.lua` is necessary but if you
|
||||
|
||||
have many vim mode remap you can config them in `keymap/other-file.lua` in dope is `config.lua` just an
|
||||
|
||||
example file. Then config plugins keymap in `keymap/init.lua`. the example of api usage
|
||||
|
||||
````lua
|
||||
-- generate keymap in noremal mode
|
||||
nmap {
|
||||
-- packer
|
||||
{'<Leader>pu',cmd('Lazy update'),opts(noremap,silent,'Lazy update')},
|
||||
{"<C-h>",'<C-w>h',opts(noremap)},
|
||||
|
||||
}
|
||||
|
||||
also you can pass a table not include sub table to `map` like
|
||||
|
||||
```lua
|
||||
nmap {'key','rhs',opts(noremap,silent)}
|
||||
````
|
||||
|
||||
use `:h vim.keymap.set` to know more about.
|
||||
|
||||
## Tips
|
||||
|
||||
- Improve key repeat
|
||||
|
||||
```
|
||||
mac os need restart
|
||||
defaults write NSGlobalDomain KeyRepeat -int 1
|
||||
defaults write NSGlobalDomain InitialKeyRepeat -int 10
|
||||
|
||||
linux
|
||||
xset r rate 210 40
|
||||
```
|
||||
|
||||
## Donate
|
||||
|
||||
[](https://paypal.me/bobbyhub)
|
||||
|
||||
If you'd like to support my work financially, buy me a drink through [paypal](https://paypal.me/bobbyhub)
|
||||
|
||||
## License MIT
|
||||
90
home/base/desktop/neovim/bin/dope
Executable file
90
home/base/desktop/neovim/bin/dope
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env lua
|
||||
|
||||
local arguments = {
|
||||
install = true,
|
||||
update = true,
|
||||
clean = true,
|
||||
doctor = true,
|
||||
debug = true,
|
||||
help = true,
|
||||
modules = true,
|
||||
}
|
||||
|
||||
local argument
|
||||
|
||||
if #arg == 0 then
|
||||
argument = 'install'
|
||||
else
|
||||
if #arg > 1 and (arg[1] ~= 'debug' and arg[1] ~= 'doctor') then
|
||||
error('passed multiple arguments.')
|
||||
end
|
||||
|
||||
if not arguments[arg[1]] then
|
||||
error('unknow argument ' .. arg[1])
|
||||
end
|
||||
argument = arg[1]
|
||||
|
||||
if arg[1] == 'debug' then
|
||||
local modules = [[let g:disable_modules="]]
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
for _, k in pairs({ table.unpack(arg, 2, #arg) } or {}) do
|
||||
modules = modules .. ',' .. 'modules/' .. k .. '/plugins'
|
||||
end
|
||||
modules = modules .. '"'
|
||||
os.execute("nvim --cmd '" .. modules .. "'")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local handle
|
||||
handle = assert(io.popen([[nvim --clean --headless --cmd 'echo $VIMRUNTIME|q' 2>&1]], 'r'))
|
||||
if not handle then
|
||||
return
|
||||
end
|
||||
|
||||
local rtp = handle:read('*a')
|
||||
handle:close()
|
||||
|
||||
-- read config path
|
||||
handle = assert(io.popen([[nvim --clean --headless --cmd 'echo stdpath("config")|q' 2>&1]], 'r'))
|
||||
local config_path = handle:read('*a')
|
||||
handle:close()
|
||||
|
||||
-- set the poackage path
|
||||
package.path = package.path .. ';' .. rtp .. '/lua/vim/?.lua;' .. config_path .. '/lua/?.lua'
|
||||
|
||||
if argument == 'help' then
|
||||
local helper = require('core.helper')
|
||||
helper.green('Dope usage')
|
||||
local usage = {
|
||||
{ '\tinstall', ' install Plugins' },
|
||||
{ '\tupdate ', ' update Plugins' },
|
||||
{ '\tclean ', ' clean the directories' },
|
||||
{ '\tdoctor ', ' check the plugins info' },
|
||||
{ '\tmodules', ' Show all modules' },
|
||||
{ '\tdebug ', ' dynamic disable modules for debug' },
|
||||
{ '\thelp ', ' show the usage of bot' },
|
||||
}
|
||||
for _, msg in pairs(usage) do
|
||||
helper.write('blue')(msg[1])
|
||||
helper.write('white')(msg[2])
|
||||
print()
|
||||
end
|
||||
os.exit()
|
||||
end
|
||||
|
||||
-- read data path
|
||||
handle = assert(io.popen([[nvim --clean --headless --cmd 'echo stdpath("data")|q' 2>&1]], 'r'))
|
||||
local data_path = handle:read('*a')
|
||||
handle:close()
|
||||
|
||||
local cli = require('core.cli')
|
||||
|
||||
cli.rtp = rtp
|
||||
cli.config_path = config_path
|
||||
cli.data_path = data_path
|
||||
|
||||
-- env init
|
||||
cli:env_init()
|
||||
|
||||
cli:meta(argument)(table.unpack(arg, 2))
|
||||
@@ -1,48 +1,74 @@
|
||||
{ config, lib, inputs, pkgs, ... }:
|
||||
|
||||
# references:
|
||||
# https://github.com/nvimdev/dope
|
||||
# https://github.com/Ruixi-rebirth/flakes/tree/main/modules/editors/nvim
|
||||
# https://github.com/Chever-John/dotfiles/tree/master/nvim
|
||||
#
|
||||
# after apply, the first time you run nvim, it will download all configs into `.local/share/nvim`
|
||||
{
|
||||
home.file = {
|
||||
".config/nvim/bin".source = ./bin;
|
||||
".config/nvim/lua".source = ./lua;
|
||||
".config/nvim/snippets".source = ./snippets;
|
||||
".config/nvim/static".source = ./static;
|
||||
".config/nvim/init.lua".source = ./init.lua;
|
||||
};
|
||||
|
||||
nixpkgs.config = {
|
||||
programs.npm.npmrc = ''
|
||||
prefix = ''${HOME}/.npm-global
|
||||
'';
|
||||
};
|
||||
|
||||
programs = {
|
||||
neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
|
||||
viAlias = false;
|
||||
vimAlias = true;
|
||||
|
||||
withPython3 = true;
|
||||
withNodeJs = true;
|
||||
extraPackages = [
|
||||
];
|
||||
extraPackages = [];
|
||||
|
||||
#-- Plugins --#
|
||||
plugins = with pkgs.vimPlugins;[ ];
|
||||
#-- --#
|
||||
# currently we use lazy.nvim as neovim's package manager, so comment this one.
|
||||
# plugins = with pkgs.vimPlugins;[
|
||||
# search all the plugins using https://search.nixos.org/packages
|
||||
# catppuccin-nvim # https://github.com/catppuccin/nvim
|
||||
# nvim-treesitter.withAllGrammars
|
||||
# ];
|
||||
};
|
||||
};
|
||||
home = {
|
||||
packages = with pkgs; [
|
||||
# -- Compiler -- #
|
||||
gcc # c/c++ compiler, required by nvim-treesitter!
|
||||
llvmPackages.clang-unwrapped # c/c++ tools with clang-tools such as clangd
|
||||
zig
|
||||
go
|
||||
luajit
|
||||
|
||||
#-- LSP --#
|
||||
nodePackages_latest.typescript
|
||||
nodePackages_latest.typescript-language-server
|
||||
nodePackages_latest.vscode-langservers-extracted
|
||||
nodePackages_latest.bash-language-server
|
||||
|
||||
nil
|
||||
# rnix-lsp
|
||||
# nixd
|
||||
|
||||
lua-language-server
|
||||
gopls
|
||||
pyright
|
||||
zk
|
||||
rust-analyzer
|
||||
clang-tools
|
||||
haskell-language-server
|
||||
|
||||
#-- tree-sitter --#
|
||||
tree-sitter
|
||||
|
||||
#-- format --#
|
||||
stylua
|
||||
black
|
||||
@@ -50,12 +76,11 @@
|
||||
rustfmt
|
||||
beautysh
|
||||
nodePackages.prettier
|
||||
stylish-haskell
|
||||
|
||||
#-- Debug --#
|
||||
gdb
|
||||
lldb
|
||||
];
|
||||
};
|
||||
|
||||
home.file.".config/nvim/init.lua".source = ./init.lua;
|
||||
home.file.".config/nvim/lua".source = ./lua;
|
||||
}
|
||||
1
home/base/desktop/neovim/init.lua
Normal file
1
home/base/desktop/neovim/init.lua
Normal file
@@ -0,0 +1 @@
|
||||
require('core')
|
||||
193
home/base/desktop/neovim/lua/core/cli.lua
Normal file
193
home/base/desktop/neovim/lua/core/cli.lua
Normal file
@@ -0,0 +1,193 @@
|
||||
local cli = {}
|
||||
local helper = require('core.helper')
|
||||
|
||||
function cli:env_init()
|
||||
self.module_path = helper.path_join(self.config_path, 'lua', 'modules')
|
||||
self.lazy_dir = helper.path_join(self.data_path, 'lazy')
|
||||
|
||||
package.path = package.path
|
||||
.. ';'
|
||||
.. self.rtp
|
||||
.. '/lua/vim/?.lua;'
|
||||
.. self.module_path
|
||||
.. '/?.lua;'
|
||||
local shared = assert(loadfile(helper.path_join(self.rtp, 'lua', 'vim', 'shared.lua')))
|
||||
_G.vim = shared()
|
||||
end
|
||||
|
||||
function cli:get_all_packages()
|
||||
local pack = require('core.pack')
|
||||
local p = io.popen('find "' .. cli.module_path .. '" -type f')
|
||||
if not p then
|
||||
return
|
||||
end
|
||||
|
||||
for file in p:lines() do
|
||||
if file:find('package.lua') then
|
||||
local module = file:match(cli.module_path .. '/(.+).lua$')
|
||||
require(module)
|
||||
end
|
||||
end
|
||||
p:close()
|
||||
|
||||
local lazy_keyword = {
|
||||
'keys',
|
||||
'ft',
|
||||
'cmd',
|
||||
'event',
|
||||
'lazy',
|
||||
}
|
||||
|
||||
local function generate_node(tbl, list)
|
||||
local node = tbl[1]
|
||||
list[node] = {}
|
||||
list[node].type = tbl.dev and 'Local Plugin' or 'Remote Plugin'
|
||||
|
||||
local check_lazy = function(t, data)
|
||||
vim.tbl_filter(function(k)
|
||||
if vim.tbl_contains(lazy_keyword, k) then
|
||||
data.load = type(t[k]) == 'table' and table.concat(t[k], ',') or t[k]
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end, vim.tbl_keys(t))
|
||||
end
|
||||
|
||||
check_lazy(tbl, list[node])
|
||||
|
||||
if tbl.dependencies then
|
||||
for _, v in pairs(tbl.dependencies) do
|
||||
if type(v) == 'string' then
|
||||
v = { v }
|
||||
end
|
||||
|
||||
list[v[1]] = {
|
||||
from_depend = true,
|
||||
load_after = node,
|
||||
}
|
||||
|
||||
list[v[1]].type = v.dev and 'Local Plugin' or 'Remote Plugin'
|
||||
check_lazy(v, list[v[1]])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local list = {}
|
||||
for _, data in pairs(pack.repos or {}) do
|
||||
if type(data) == string then
|
||||
data = { data }
|
||||
end
|
||||
generate_node(data, list)
|
||||
end
|
||||
|
||||
return list
|
||||
end
|
||||
|
||||
function cli:boot_strap()
|
||||
helper.blue('🔸 Search plugin management lazy.nvim in local')
|
||||
if helper.isdir(self.lazy_dir) then
|
||||
helper.green('🔸 Found lazy.nvim skip download')
|
||||
return
|
||||
end
|
||||
helper.run_git('lazy.nvim', 'git clone https://github.com/folke/lazy.nvim ' .. self.lazy_dir, 'Install')
|
||||
helper.success('lazy.nvim')
|
||||
end
|
||||
|
||||
function cli:installer(type)
|
||||
cli:boot_strap()
|
||||
|
||||
local packages = cli:get_all_packages()
|
||||
---@diagnostic disable-next-line: unused-local, param-type-mismatch
|
||||
local res = {}
|
||||
for name, v in pairs(packages or {}) do
|
||||
if v.type:find('Remote') then
|
||||
local non_user_name = vim.split(name, '/')[2]
|
||||
local path = self.lazy_dir .. helper.path_sep .. non_user_name
|
||||
if helper.isdir(path) and type == 'install' then
|
||||
helper.purple('\t🥯 Skip already in plugin ' .. name)
|
||||
else
|
||||
local url = 'git clone https://github.com/'
|
||||
local cmd = type == 'install' and url .. name .. ' ' .. path or 'git -C ' .. path .. ' pull'
|
||||
local failed = helper.run_git(name, cmd, type)
|
||||
table.insert(res, failed)
|
||||
end
|
||||
else
|
||||
helper.purple('\t🥯 Skip local plugin ' .. name)
|
||||
end
|
||||
end
|
||||
if not vim.tbl_contains(res, true) then
|
||||
helper.green('🎉 Congratulations Config install or update success. Enjoy ^^')
|
||||
return
|
||||
end
|
||||
helper.red('Some plugins not install or update success please run install again')
|
||||
end
|
||||
|
||||
function cli.install()
|
||||
cli:installer('install')
|
||||
end
|
||||
|
||||
function cli.update()
|
||||
cli:installer('update')
|
||||
end
|
||||
|
||||
function cli.clean()
|
||||
os.execute('rm -rf ' .. cli.lazy_dir)
|
||||
end
|
||||
|
||||
function cli.doctor(pack_name)
|
||||
local list = cli:get_all_packages()
|
||||
if not list then
|
||||
return
|
||||
end
|
||||
|
||||
helper.yellow('🔹 Total: ' .. vim.tbl_count(list) + 1 .. ' Plugins')
|
||||
local packs = pack_name and { [pack_name] = list[pack_name] } or list
|
||||
for k, v in pairs(packs) do
|
||||
helper.blue('\t' .. '✨' .. k)
|
||||
if v.type then
|
||||
helper.write('purple')('\tType: ')
|
||||
helper.write('white')(v.type)
|
||||
print()
|
||||
end
|
||||
if v.load then
|
||||
helper.write('purple')('\tLoad: ')
|
||||
helper.write('white')(v.load)
|
||||
print()
|
||||
end
|
||||
|
||||
if v.from_depend then
|
||||
helper.write('purple')('\tDepend: ')
|
||||
helper.write('white')(v.load_after)
|
||||
print()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cli.modules()
|
||||
local p = io.popen('find "' .. cli.module_path .. '" -type d')
|
||||
if not p then
|
||||
return
|
||||
end
|
||||
local res = {}
|
||||
|
||||
for dict in p:lines() do
|
||||
dict = vim.split(dict, helper.path_sep)
|
||||
if dict[#dict] ~= 'modules' then
|
||||
table.insert(res, dict[#dict])
|
||||
end
|
||||
end
|
||||
|
||||
helper.green('Found ' .. #res .. ' Modules in Local')
|
||||
for _, v in pairs(res) do
|
||||
helper.write('yellow')('\t✅ ' .. v)
|
||||
print()
|
||||
end
|
||||
end
|
||||
|
||||
function cli:meta(arg)
|
||||
return function(data)
|
||||
self[arg](data)
|
||||
end
|
||||
end
|
||||
|
||||
return cli
|
||||
97
home/base/desktop/neovim/lua/core/helper.lua
Normal file
97
home/base/desktop/neovim/lua/core/helper.lua
Normal file
@@ -0,0 +1,97 @@
|
||||
local helper = {}
|
||||
helper.path_sep = package.config:sub(1, 1) == '\\' and '\\' or '/'
|
||||
|
||||
function helper.path_join(...)
|
||||
return table.concat({ ... }, helper.path_sep)
|
||||
end
|
||||
|
||||
function helper.data_path()
|
||||
local cli = require('core.cli')
|
||||
if cli.config_path then
|
||||
return cli.config_path
|
||||
end
|
||||
return vim.fn.stdpath('data')
|
||||
end
|
||||
|
||||
function helper.config_path()
|
||||
local cli = require('core.cli')
|
||||
if cli.data_path then
|
||||
return cli.data_path
|
||||
end
|
||||
return vim.fn.stdpath('config')
|
||||
end
|
||||
|
||||
local function get_color(color)
|
||||
local tbl = {
|
||||
black = '\027[90m',
|
||||
red = '\027[91m',
|
||||
green = '\027[92m',
|
||||
yellow = '\027[93m',
|
||||
blue = '\027[94m',
|
||||
purple = '\027[95m',
|
||||
cyan = '\027[96m',
|
||||
white = '\027[97m',
|
||||
}
|
||||
return tbl[color]
|
||||
end
|
||||
|
||||
local function color_print(color)
|
||||
local rgb = get_color(color)
|
||||
return function(text)
|
||||
print(rgb .. text .. '\027[m')
|
||||
end
|
||||
end
|
||||
|
||||
function helper.write(color)
|
||||
local rgb = get_color(color)
|
||||
return function(text)
|
||||
io.write(rgb .. text .. '\027[m')
|
||||
end
|
||||
end
|
||||
|
||||
function helper.success(msg)
|
||||
color_print('green')('\t🍻 ' .. msg .. ' Success ‼️ ')
|
||||
end
|
||||
|
||||
function helper.error(msg)
|
||||
color_print('red')(msg)
|
||||
end
|
||||
|
||||
function helper.run_git(name, cmd, type)
|
||||
local pip = assert(io.popen(cmd .. ' 2>&1'))
|
||||
color_print('green')('\t🍻 ' .. type .. ' ' .. name)
|
||||
local failed = false
|
||||
for line in pip:lines() do
|
||||
if line:find('fatal') then
|
||||
failed = true
|
||||
end
|
||||
io.write('\t ' .. line)
|
||||
io.write('\n')
|
||||
end
|
||||
|
||||
pip:close()
|
||||
return failed
|
||||
end
|
||||
|
||||
local function exists(file)
|
||||
local ok, _, code = os.rename(file, file)
|
||||
if not ok then
|
||||
if code == 13 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return ok
|
||||
end
|
||||
|
||||
--- Check if a directory exists in this path
|
||||
function helper.isdir(path)
|
||||
return exists(path .. '/')
|
||||
end
|
||||
|
||||
setmetatable(helper, {
|
||||
__index = function(_, k)
|
||||
return color_print(k)
|
||||
end,
|
||||
})
|
||||
|
||||
return helper
|
||||
51
home/base/desktop/neovim/lua/core/init.lua
Normal file
51
home/base/desktop/neovim/lua/core/init.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
local g, fn = vim.g, vim.fn
|
||||
local helper = require('core.helper')
|
||||
-- remove check is windows because I only use mac or linux
|
||||
local cache_dir = helper.path_join(vim.fn.stdpath('cache'), 'nvim')
|
||||
|
||||
-- Create cache dir and subs dir
|
||||
local createdir = function()
|
||||
local data_dir = {
|
||||
cache_dir .. 'backup',
|
||||
cache_dir .. 'session',
|
||||
cache_dir .. 'swap',
|
||||
cache_dir .. 'tags',
|
||||
cache_dir .. 'undo',
|
||||
}
|
||||
-- There only check once that If cache_dir exists
|
||||
-- Then I don't want to check subs dir exists
|
||||
if fn.isdirectory(cache_dir) == 0 then
|
||||
os.execute('mkdir -p ' .. cache_dir)
|
||||
for _, v in pairs(data_dir) do
|
||||
if fn.isdirectory(v) == 0 then
|
||||
os.execute('mkdir -p ' .. v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
createdir()
|
||||
|
||||
--disable_distribution_plugins
|
||||
g.loaded_gzip = 1
|
||||
g.loaded_tar = 1
|
||||
g.loaded_tarPlugin = 1
|
||||
g.loaded_zip = 1
|
||||
g.loaded_zipPlugin = 1
|
||||
g.loaded_getscript = 1
|
||||
g.loaded_getscriptPlugin = 1
|
||||
g.loaded_vimball = 1
|
||||
g.loaded_vimballPlugin = 1
|
||||
g.loaded_matchit = 1
|
||||
g.loaded_matchparen = 1
|
||||
g.loaded_2html_plugin = 1
|
||||
g.loaded_logiPat = 1
|
||||
g.loaded_rrhelper = 1
|
||||
g.loaded_netrw = 1
|
||||
g.loaded_netrwPlugin = 1
|
||||
g.loaded_netrwSettings = 1
|
||||
g.loaded_netrwFileHandlers = 1
|
||||
|
||||
require('core.pack'):boot_strap()
|
||||
require('core.options')
|
||||
require('keymap')
|
||||
115
home/base/desktop/neovim/lua/core/keymap.lua
Normal file
115
home/base/desktop/neovim/lua/core/keymap.lua
Normal file
@@ -0,0 +1,115 @@
|
||||
local keymap = {}
|
||||
local opts = {}
|
||||
|
||||
function opts:new(instance)
|
||||
instance = instance
|
||||
or {
|
||||
options = {
|
||||
silent = false,
|
||||
nowait = false,
|
||||
expr = false,
|
||||
noremap = false,
|
||||
},
|
||||
}
|
||||
setmetatable(instance, self)
|
||||
self.__index = self
|
||||
return instance
|
||||
end
|
||||
|
||||
function keymap.silent(opt)
|
||||
return function()
|
||||
opt.silent = true
|
||||
end
|
||||
end
|
||||
|
||||
function keymap.noremap(opt)
|
||||
return function()
|
||||
opt.noremap = true
|
||||
end
|
||||
end
|
||||
|
||||
function keymap.expr(opt)
|
||||
return function()
|
||||
opt.expr = true
|
||||
end
|
||||
end
|
||||
|
||||
function keymap.remap(opt)
|
||||
return function()
|
||||
opt.remap = true
|
||||
end
|
||||
end
|
||||
|
||||
function keymap.nowait(opt)
|
||||
return function()
|
||||
opt.nowait = true
|
||||
end
|
||||
end
|
||||
|
||||
function keymap.new_opts(...)
|
||||
local args = { ... }
|
||||
local o = opts:new()
|
||||
|
||||
if #args == 0 then
|
||||
return o.options
|
||||
end
|
||||
|
||||
for _, arg in pairs(args) do
|
||||
if type(arg) == 'string' then
|
||||
o.options.desc = arg
|
||||
else
|
||||
arg(o.options)()
|
||||
end
|
||||
end
|
||||
return o.options
|
||||
end
|
||||
|
||||
function keymap.cmd(str)
|
||||
return '<cmd>' .. str .. '<CR>'
|
||||
end
|
||||
|
||||
-- visual
|
||||
function keymap.cu(str)
|
||||
return '<C-u><cmd>' .. str .. '<CR>'
|
||||
end
|
||||
|
||||
--@private
|
||||
local keymap_set = function(mode, tbl)
|
||||
vim.validate({
|
||||
tbl = { tbl, 'table' },
|
||||
})
|
||||
local len = #tbl
|
||||
if len < 2 then
|
||||
vim.notify('keymap must has rhs')
|
||||
return
|
||||
end
|
||||
|
||||
local options = len == 3 and tbl[3] or keymap.new_opts()
|
||||
|
||||
vim.keymap.set(mode, tbl[1], tbl[2], options)
|
||||
end
|
||||
|
||||
local function map(mod)
|
||||
return function(tbl)
|
||||
vim.validate({
|
||||
tbl = { tbl, 'table' },
|
||||
})
|
||||
|
||||
if type(tbl[1]) == 'table' and type(tbl[2]) == 'table' then
|
||||
for _, v in pairs(tbl) do
|
||||
keymap_set(mod, v)
|
||||
end
|
||||
else
|
||||
keymap_set(mod, tbl)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
keymap.nmap = map('n')
|
||||
keymap.imap = map('i')
|
||||
keymap.cmap = map('c')
|
||||
keymap.vmap = map('v')
|
||||
keymap.xmap = map('x')
|
||||
keymap.tmap = map('t')
|
||||
|
||||
return keymap
|
||||
91
home/base/desktop/neovim/lua/core/options.lua
Normal file
91
home/base/desktop/neovim/lua/core/options.lua
Normal file
@@ -0,0 +1,91 @@
|
||||
local opt = vim.opt
|
||||
local cache_dir = vim.env.HOME .. '/.cache/nvim/'
|
||||
|
||||
opt.relativenumber = true
|
||||
opt.termguicolors = true
|
||||
opt.hidden = true
|
||||
opt.magic = true
|
||||
opt.virtualedit = 'block'
|
||||
|
||||
-- sync content between vim & system clipboard
|
||||
opt.clipboard = 'unnamedplus'
|
||||
|
||||
opt.wildignorecase = true
|
||||
opt.swapfile = false
|
||||
opt.directory = cache_dir .. 'swap/'
|
||||
opt.undodir = cache_dir .. 'undo/'
|
||||
opt.backupdir = cache_dir .. 'backup/'
|
||||
opt.viewdir = cache_dir .. 'view/'
|
||||
opt.spellfile = cache_dir .. 'spell/en.uft-8.add'
|
||||
opt.history = 2000
|
||||
opt.timeout = true
|
||||
opt.ttimeout = true
|
||||
opt.timeoutlen = 500
|
||||
opt.ttimeoutlen = 10
|
||||
opt.updatetime = 100
|
||||
opt.redrawtime = 1500
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.infercase = true
|
||||
|
||||
if vim.fn.executable('rg') == 1 then
|
||||
opt.grepformat = '%f:%l:%c:%m,%f:%l:%m'
|
||||
opt.grepprg = 'rg --vimgrep --no-heading --smart-case'
|
||||
end
|
||||
|
||||
opt.completeopt = 'menu,menuone,noselect'
|
||||
opt.showmode = false
|
||||
opt.shortmess = 'aoOTIcF'
|
||||
opt.scrolloff = 2
|
||||
opt.sidescrolloff = 5
|
||||
opt.ruler = false
|
||||
opt.showtabline = 0
|
||||
opt.winwidth = 30
|
||||
opt.pumheight = 15
|
||||
opt.showcmd = false
|
||||
|
||||
opt.cmdheight = 0
|
||||
opt.laststatus = 3
|
||||
opt.list = true
|
||||
opt.listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←'
|
||||
opt.pumblend = 10
|
||||
opt.winblend = 10
|
||||
opt.undofile = true
|
||||
|
||||
opt.smarttab = true
|
||||
opt.expandtab = true
|
||||
opt.autoindent = true
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
|
||||
-- wrap
|
||||
opt.linebreak = true
|
||||
opt.whichwrap = 'h,l,<,>,[,],~'
|
||||
opt.breakindentopt = 'shift:2,min:20'
|
||||
opt.showbreak = '↳ '
|
||||
|
||||
opt.foldlevelstart = 99
|
||||
opt.foldmethod = 'marker'
|
||||
|
||||
opt.number = true
|
||||
opt.signcolumn = 'yes'
|
||||
opt.spelloptions = 'camel'
|
||||
|
||||
opt.textwidth = 100
|
||||
opt.colorcolumn = '100'
|
||||
if vim.loop.os_uname().sysname == 'Darwin' then
|
||||
vim.g.clipboard = {
|
||||
name = 'macOS-clipboard',
|
||||
copy = {
|
||||
['+'] = 'pbcopy',
|
||||
['*'] = 'pbcopy',
|
||||
},
|
||||
paste = {
|
||||
['+'] = 'pbpaste',
|
||||
['*'] = 'pbpaste',
|
||||
},
|
||||
cache_enabled = 0,
|
||||
}
|
||||
vim.g.python_host_prog = '/usr/bin/python'
|
||||
vim.g.python3_host_prog = '/usr/local/bin/python3'
|
||||
end
|
||||
62
home/base/desktop/neovim/lua/core/pack.lua
Normal file
62
home/base/desktop/neovim/lua/core/pack.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
local uv, api, fn = vim.loop, vim.api, vim.fn
|
||||
|
||||
local pack = {}
|
||||
pack.__index = pack
|
||||
|
||||
function pack:load_modules_packages()
|
||||
local modules_dir = self.helper.path_join(self.config_path, 'lua', 'modules')
|
||||
self.repos = {}
|
||||
|
||||
local list = vim.fs.find('package.lua', { path = modules_dir, type = 'file', limit = 10 })
|
||||
if #list == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local disable_modules = {}
|
||||
|
||||
if fn.exists('g:disable_modules') == 1 then
|
||||
disable_modules = vim.split(vim.g.disable_modules, ',', { trimempty = true })
|
||||
end
|
||||
|
||||
for _, f in pairs(list) do
|
||||
local _, pos = f:find(modules_dir)
|
||||
f = f:sub(pos - 6, #f - 4)
|
||||
if not vim.tbl_contains(disable_modules, f) then
|
||||
require(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pack:boot_strap()
|
||||
self.helper = require('core.helper')
|
||||
self.data_path = self.helper.data_path()
|
||||
self.config_path = self.helper.config_path()
|
||||
local lazy_path = self.helper.path_join(self.data_path, 'lazy', 'lazy.nvim')
|
||||
local state = uv.fs_stat(lazy_path)
|
||||
if not state then
|
||||
local cmd = '!git clone https://github.com/folke/lazy.nvim ' .. lazy_path
|
||||
api.nvim_command(cmd)
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazy_path)
|
||||
local lazy = require('lazy')
|
||||
local opts = {
|
||||
lockfile = self.helper.path_join(self.data_path, 'lazy-lock.json'),
|
||||
}
|
||||
self:load_modules_packages()
|
||||
lazy.setup(self.repos, opts)
|
||||
|
||||
for k, v in pairs(self) do
|
||||
if type(v) ~= 'function' then
|
||||
self[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pack.package(repo)
|
||||
if not pack.repos then
|
||||
pack.repos = {}
|
||||
end
|
||||
table.insert(pack.repos, repo)
|
||||
end
|
||||
|
||||
return pack
|
||||
58
home/base/desktop/neovim/lua/keymap/init.lua
Normal file
58
home/base/desktop/neovim/lua/keymap/init.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
local keymap = require('core.keymap')
|
||||
local nmap, imap, cmap, xmap = keymap.nmap, keymap.imap, keymap.cmap, keymap.xmap
|
||||
local silent, noremap = keymap.silent, keymap.noremap
|
||||
local opts = keymap.new_opts
|
||||
local cmd = keymap.cmd
|
||||
|
||||
-- Use space as leader key
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
-- leaderkey
|
||||
nmap({ ' ', '', opts(noremap) })
|
||||
xmap({ ' ', '', opts(noremap) })
|
||||
|
||||
-- usage example
|
||||
nmap({
|
||||
-- noremal remap
|
||||
-- close buffer
|
||||
{ '<C-x>k', cmd('bdelete'), opts(noremap, silent) },
|
||||
-- save
|
||||
{ '<C-s>', cmd('write'), opts(noremap) },
|
||||
-- yank
|
||||
{ 'Y', 'y$', opts(noremap) },
|
||||
-- buffer jump
|
||||
{ ']b', cmd('bn'), opts(noremap) },
|
||||
{ '[b', cmd('bp'), opts(noremap) },
|
||||
-- remove trailing white space
|
||||
{ '<Leader>t', cmd('TrimTrailingWhitespace'), opts(noremap) },
|
||||
-- window jump
|
||||
{ '<C-h>', '<C-w>h', opts(noremap) },
|
||||
{ '<C-l>', '<C-w>l', opts(noremap) },
|
||||
{ '<C-j>', '<C-w>j', opts(noremap) },
|
||||
{ '<C-k>', '<C-w>k', opts(noremap) },
|
||||
})
|
||||
|
||||
imap({
|
||||
-- insert mode
|
||||
{ '<C-h>', '<Bs>', opts(noremap) },
|
||||
{ '<C-e>', '<End>', opts(noremap) },
|
||||
})
|
||||
|
||||
-- commandline remap
|
||||
cmap({ '<C-b>', '<Left>', opts(noremap) })
|
||||
-- usage of plugins
|
||||
nmap({
|
||||
-- plugin manager: Lazy.nvim
|
||||
{ '<Leader>pu', cmd('Lazy update'), opts(noremap, silent) },
|
||||
{ '<Leader>pi', cmd('Lazy install'), opts(noremap, silent) },
|
||||
-- dashboard
|
||||
{ '<Leader>n', cmd('DashboardNewFile'), opts(noremap, silent) },
|
||||
{ '<Leader>ss', cmd('SessionSave'), opts(noremap, silent) },
|
||||
{ '<Leader>sl', cmd('SessionLoad'), opts(noremap, silent) },
|
||||
-- nvimtree
|
||||
{ '<Leader>e', cmd('NvimTreeToggle'), opts(noremap, silent) },
|
||||
-- Telescope
|
||||
{ '<Leader>b', cmd('Telescope buffers'), opts(noremap, silent) },
|
||||
{ '<Leader>fa', cmd('Telescope live_grep'), opts(noremap, silent) },
|
||||
{ '<Leader>ff', cmd('Telescope find_files'), opts(noremap, silent) },
|
||||
})
|
||||
257
home/base/desktop/neovim/lua/modules/completion/config.lua
Normal file
257
home/base/desktop/neovim/lua/modules/completion/config.lua
Normal file
@@ -0,0 +1,257 @@
|
||||
local config = {}
|
||||
|
||||
-- config language servers in this function
|
||||
-- https://github.com/williamboman/nvim-lsp-installer#available-lsps
|
||||
function config.nvim_lsp()
|
||||
local nvim_lsp = require("lspconfig")
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
-- nvim hasn't added foldingRange to default capabilities, users must add it manually
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
|
||||
--Change diagnostic symbols in the sign column (gutter)
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = false,
|
||||
})
|
||||
|
||||
local on_attach = function(bufnr)
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "line",
|
||||
}
|
||||
vim.diagnostic.show()
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- nix
|
||||
-- nvim_lsp.nixd.setup({
|
||||
-- on_attach = on_attach(),
|
||||
-- capabilities = capabilities,
|
||||
-- })
|
||||
--nvim_lsp.rnix.setup({
|
||||
-- on_attach = on_attach(),
|
||||
-- capabilities = capabilities,
|
||||
--})
|
||||
nvim_lsp.nil_ls.setup({
|
||||
on_attach = on_attach(),
|
||||
settings = {
|
||||
["nil"] = {
|
||||
nix = {
|
||||
flake = {
|
||||
autoArchive = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- GoLang
|
||||
nvim_lsp["gopls"].setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
gopls = {
|
||||
experimentalPostfixCompletions = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
shadow = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
},
|
||||
})
|
||||
|
||||
nvim_lsp.clangd.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
--Python
|
||||
nvim_lsp.pyright.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = "workspace",
|
||||
useLibraryCodeForTypes = true,
|
||||
typeCheckingMode = "off",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
--sumneko_lua
|
||||
nvim_lsp.lua_ls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
nvim_lsp.rust_analyzer.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
nvim_lsp.html.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "vscode-html-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.cssls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "vscode-css-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.tsserver.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.bashls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "bash-language-server", "start" },
|
||||
})
|
||||
end
|
||||
|
||||
function config.nvim_cmp()
|
||||
local cmp = require('cmp')
|
||||
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
-- find more here: https://www.nerdfonts.com/cheat-sheet
|
||||
|
||||
cmp.setup({
|
||||
preselect = cmp.PreselectMode.Item,
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
|
||||
vim_item.menu = ({
|
||||
path = "[Path]",
|
||||
nvim_lua = "[NVIM_LUA]",
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function config.lua_snip()
|
||||
local ls = require('luasnip')
|
||||
local types = require('luasnip.util.types')
|
||||
ls.config.set_config({
|
||||
history = true,
|
||||
enable_autosnippets = true,
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = { { '<- choiceNode', 'Comment' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
require('luasnip.loaders.from_lua').lazy_load({ paths = vim.fn.stdpath('config') .. '/snippets' })
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
require('luasnip.loaders.from_vscode').lazy_load({
|
||||
paths = { './snippets/' },
|
||||
})
|
||||
end
|
||||
|
||||
function config.lspsaga()
|
||||
require('lspsaga').setup({})
|
||||
end
|
||||
return config
|
||||
105
home/base/desktop/neovim/lua/modules/completion/package.lua
Normal file
105
home/base/desktop/neovim/lua/modules/completion/package.lua
Normal file
@@ -0,0 +1,105 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.completion.config')
|
||||
|
||||
package({
|
||||
'neovim/nvim-lspconfig',
|
||||
-- used filetype to lazyload lsp
|
||||
-- config your language filetype in here
|
||||
ft = { 'lua', 'rust', 'c', 'cpp', 'go', 'py', 'nix', 'c', 'cpp', 'js' },
|
||||
config = conf.nvim_lsp,
|
||||
})
|
||||
|
||||
package({
|
||||
'glepnir/lspsaga.nvim',
|
||||
event = 'BufRead',
|
||||
dev = false,
|
||||
config = conf.lspsaga,
|
||||
})
|
||||
|
||||
package({
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = 'InsertEnter',
|
||||
config = conf.nvim_cmp,
|
||||
dependencies = {
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ 'hrsh7th/cmp-path' },
|
||||
{ 'hrsh7th/cmp-buffer' },
|
||||
{ 'saadparwaiz1/cmp_luasnip' },
|
||||
},
|
||||
})
|
||||
|
||||
package({ 'L3MON4D3/LuaSnip', event = 'InsertCharPre', config = conf.lua_snip })
|
||||
|
||||
-- Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
|
||||
package({
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
-- you must download code formatter by yourself!
|
||||
require("null-ls").builtins.formatting.stylua,
|
||||
require("null-ls").builtins.formatting.black, -- python
|
||||
require("null-ls").builtins.formatting.prettier,
|
||||
require("null-ls").builtins.formatting.gofmt, -- provide by go itself
|
||||
require("null-ls").builtins.formatting.nixpkgs_fmt,
|
||||
require("null-ls").builtins.formatting.beautysh,
|
||||
require("null-ls").builtins.formatting.rustfmt,
|
||||
},
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- A super powerful autopair plugin for Neovim that supports multiple characters.
|
||||
package({
|
||||
"windwp/nvim-autopairs",
|
||||
dependencies = { "hrsh7th/nvim-cmp" },
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
local status_ok, npairs = pcall(require, "nvim-autopairs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
npairs.setup({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
javascript = { "string", "template_string" },
|
||||
java = false,
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
fast_wrap = {
|
||||
map = "<M-e>",
|
||||
chars = { "{", "[", "(", '"', "'" },
|
||||
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
|
||||
offset = 0, -- Offset from pattern match
|
||||
end_key = "$",
|
||||
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
||||
check_comma = true,
|
||||
highlight = "PmenuSel",
|
||||
highlight_grey = "LineNr",
|
||||
},
|
||||
})
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
||||
end,
|
||||
})
|
||||
26
home/base/desktop/neovim/lua/modules/editor/config.lua
Normal file
26
home/base/desktop/neovim/lua/modules/editor/config.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local config = {}
|
||||
|
||||
function config.nvim_treesitter()
|
||||
vim.api.nvim_command('set foldmethod=expr')
|
||||
vim.api.nvim_command('set foldexpr=nvim_treesitter#foldexpr()')
|
||||
require('nvim-treesitter.configs').setup({
|
||||
ensure_installed = 'all',
|
||||
ignore_install = { 'phpdoc' },
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return config
|
||||
12
home/base/desktop/neovim/lua/modules/editor/package.lua
Normal file
12
home/base/desktop/neovim/lua/modules/editor/package.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.editor.config')
|
||||
|
||||
package({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
event = 'BufRead',
|
||||
run = ':TSUpdate',
|
||||
config = conf.nvim_treesitter,
|
||||
dependencies = {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
},
|
||||
})
|
||||
25
home/base/desktop/neovim/lua/modules/tools/config.lua
Normal file
25
home/base/desktop/neovim/lua/modules/tools/config.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local config = {}
|
||||
|
||||
function config.telescope()
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
layout_config = {
|
||||
horizontal = { prompt_position = 'top', results_width = 0.6 },
|
||||
vertical = { mirror = false },
|
||||
},
|
||||
sorting_strategy = 'ascending',
|
||||
file_previewer = require('telescope.previewers').vim_buffer_cat.new,
|
||||
grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new,
|
||||
qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new,
|
||||
},
|
||||
extensions = {
|
||||
fzy_native = {
|
||||
override_generic_sorter = false,
|
||||
override_file_sorter = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
require('telescope').load_extension('fzy_native')
|
||||
end
|
||||
|
||||
return config
|
||||
27
home/base/desktop/neovim/lua/modules/tools/package.lua
Normal file
27
home/base/desktop/neovim/lua/modules/tools/package.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.tools.config')
|
||||
|
||||
package({
|
||||
'nvim-telescope/telescope.nvim',
|
||||
cmd = 'Telescope',
|
||||
config = conf.telescope,
|
||||
dependencies = {
|
||||
{ 'nvim-lua/plenary.nvim' },
|
||||
{ 'nvim-telescope/telescope-fzy-native.nvim' },
|
||||
},
|
||||
})
|
||||
|
||||
package({
|
||||
'glepnir/hlsearch.nvim',
|
||||
event = 'BufRead',
|
||||
config = function()
|
||||
require('hlsearch').setup()
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Copilot AI Assistant
|
||||
-- have no options, but need to run `:Copilot setup` after start neovim to login.
|
||||
package({
|
||||
'github/copilot.vim',
|
||||
})
|
||||
67
home/base/desktop/neovim/lua/modules/ui/config.lua
Normal file
67
home/base/desktop/neovim/lua/modules/ui/config.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
local config = {}
|
||||
|
||||
function config.zephyr()
|
||||
vim.cmd('colorscheme zephyr')
|
||||
end
|
||||
|
||||
function config.dashboard()
|
||||
local db = require('dashboard')
|
||||
db.setup({
|
||||
theme = 'hyper',
|
||||
config = {
|
||||
week_header = {
|
||||
enable = true,
|
||||
},
|
||||
shortcut = {
|
||||
{ desc = ' Update', group = '@property', action = 'Lazy update', key = 'u' },
|
||||
{
|
||||
desc = ' Files',
|
||||
group = 'Label',
|
||||
action = 'Telescope find_files',
|
||||
key = 'f',
|
||||
},
|
||||
{
|
||||
desc = ' Apps',
|
||||
group = 'DiagnosticHint',
|
||||
action = 'Telescope app',
|
||||
key = 'a',
|
||||
},
|
||||
{
|
||||
desc = ' dotfiles',
|
||||
group = 'Number',
|
||||
action = 'Telescope dotfiles',
|
||||
key = 'd',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function config.nvim_bufferline()
|
||||
require('bufferline').setup({
|
||||
options = {
|
||||
modified_icon = '✥',
|
||||
buffer_close_icon = '',
|
||||
always_show_bufferline = true,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function config.indent_blankline()
|
||||
require('indent_blankline').setup({
|
||||
char = '│',
|
||||
use_treesitter_scope = true,
|
||||
show_first_indent_level = true,
|
||||
show_current_context = false,
|
||||
show_current_context_start = false,
|
||||
show_current_context_start_on_current_line = false,
|
||||
filetype_exclude = {
|
||||
'dashboard',
|
||||
'log',
|
||||
'TelescopePrompt',
|
||||
},
|
||||
buftype_exclude = { 'terminal', 'nofile', 'prompt' },
|
||||
})
|
||||
end
|
||||
|
||||
return config
|
||||
367
home/base/desktop/neovim/lua/modules/ui/package.lua
Normal file
367
home/base/desktop/neovim/lua/modules/ui/package.lua
Normal file
@@ -0,0 +1,367 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.ui.config')
|
||||
|
||||
package({ 'glepnir/zephyr-nvim', config = conf.zephyr })
|
||||
|
||||
package({ 'glepnir/dashboard-nvim', config = conf.dashboard })
|
||||
|
||||
package({
|
||||
'akinsho/nvim-bufferline.lua',
|
||||
config = conf.nvim_bufferline,
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
})
|
||||
|
||||
package({
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
event = 'BufRead',
|
||||
config = conf.indent_blankline,
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
package({
|
||||
'nvim-neo-tree/neo-tree.nvim',
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("neo-tree").setup({
|
||||
default_component_configs = {
|
||||
icon = {
|
||||
folder_empty = "",
|
||||
folder_empty_open = "",
|
||||
},
|
||||
git_status = {
|
||||
symbols = {
|
||||
renamed = "",
|
||||
unstaged = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
document_symbols = {
|
||||
kinds = {
|
||||
File = { icon = "", hl = "Tag" },
|
||||
Namespace = { icon = "", hl = "Include" },
|
||||
Package = { icon = "", hl = "Label" },
|
||||
Class = { icon = "", hl = "Include" },
|
||||
Property = { icon = "", hl = "@property" },
|
||||
Enum = { icon = "", hl = "@number" },
|
||||
Function = { icon = "", hl = "Function" },
|
||||
String = { icon = "", hl = "String" },
|
||||
Number = { icon = "", hl = "Number" },
|
||||
Array = { icon = "", hl = "Type" },
|
||||
Object = { icon = "", hl = "Type" },
|
||||
Key = { icon = "", hl = "" },
|
||||
Struct = { icon = "", hl = "Type" },
|
||||
Operator = { icon = "", hl = "Operator" },
|
||||
TypeParameter = { icon = "", hl = "Type" },
|
||||
StaticMethod = { icon = ' ', hl = 'Function' },
|
||||
}
|
||||
},
|
||||
-- Add this section only if you've configured source selector.
|
||||
source_selector = {
|
||||
sources = {
|
||||
{ source = "filesystem", display_name = " Files " },
|
||||
{ source = "git_status", display_name = " Git " },
|
||||
},
|
||||
},
|
||||
-- Other options ...
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
-- Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
|
||||
package({
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"rcarriga/nvim-notify",
|
||||
},
|
||||
config = function()
|
||||
require("noice").setup({
|
||||
routes = {
|
||||
{
|
||||
view = "notify",
|
||||
filter = { event = "msg_showmode" },
|
||||
},
|
||||
},
|
||||
views = {
|
||||
cmdline_popup = {
|
||||
position = {
|
||||
row = 5,
|
||||
col = "50%",
|
||||
},
|
||||
size = {
|
||||
width = 60,
|
||||
height = "auto",
|
||||
},
|
||||
},
|
||||
popupmenu = {
|
||||
relative = "editor",
|
||||
position = {
|
||||
row = 8,
|
||||
col = "50%",
|
||||
},
|
||||
size = {
|
||||
width = 60,
|
||||
height = 10,
|
||||
},
|
||||
border = {
|
||||
style = "rounded",
|
||||
padding = { 0, 1 },
|
||||
},
|
||||
win_options = {
|
||||
winhighlight = { Normal = "Normal", FloatBorder = "DiagnosticInfo" },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- bottom statusline
|
||||
package({
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "BufWinEnter",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
local lualine = require("lualine")
|
||||
|
||||
-- Color table for highlights
|
||||
-- stylua: ignore
|
||||
local colors = {
|
||||
-- Nordic - dark theme
|
||||
bg = '#3B4252',
|
||||
fg = '#D6DCE7',
|
||||
custom = '#B38DAC',
|
||||
|
||||
-- Catppuccin - dark pink theme
|
||||
-- bg = '#302D41',
|
||||
-- fg = '#bbc2cf',
|
||||
-- custom = '#b0c4de',
|
||||
|
||||
-- Light Theme
|
||||
-- bg = '#FAF4FC',
|
||||
-- fg = '#1E1E2E',
|
||||
-- custom = '#FF99CC',
|
||||
|
||||
yellow = '#ECBE7B',
|
||||
cyan = '#008080',
|
||||
darkblue = '#081633',
|
||||
green = '#98be65',
|
||||
orange = '#FF8800',
|
||||
violet = '#a9a1e1',
|
||||
magenta = '#c678dd',
|
||||
blue = '#51afef',
|
||||
red = '#ec5f67',
|
||||
}
|
||||
|
||||
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand("%:p:h")
|
||||
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
globalstatus = true,
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x ot right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- mode component
|
||||
function()
|
||||
return ""
|
||||
end,
|
||||
color = function()
|
||||
-- auto change color according to neovims mode
|
||||
local mode_color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.blue,
|
||||
[""] = colors.blue,
|
||||
V = colors.blue,
|
||||
c = colors.magenta,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[""] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
["r?"] = colors.cyan,
|
||||
["!"] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = mode_color[vim.fn.mode()] }
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- filesize component
|
||||
"filesize",
|
||||
cond = conditions.buffer_not_empty,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
"filename",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_left({ "location" })
|
||||
|
||||
ins_left({ "progress", color = { fg = colors.fg, gui = "bold" } })
|
||||
|
||||
ins_left({
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " " },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
})
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
function()
|
||||
return "%="
|
||||
end,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "No Active Lsp"
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = " LSP:",
|
||||
color = { fg = "#474E6D", gui = "bold" },
|
||||
})
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
"o:encoding", -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"fileformat",
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"branch",
|
||||
icon = "",
|
||||
color = { fg = colors.violet, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"diff",
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
})
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
end
|
||||
})
|
||||
116
home/base/desktop/neovim/snippets/lua.json
Normal file
116
home/base/desktop/neovim/snippets/lua.json
Normal file
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"_G": {
|
||||
"body": "_G(${0:...})",
|
||||
"description": "5.1,5.2,5.3\n\n_G",
|
||||
"prefix": "_G",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"assert": {
|
||||
"body": "assert(${1:v}${2:[, message]})",
|
||||
"description": "5.1,5.2,5.3\n\nassert()",
|
||||
"prefix": "assert",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"collectgarbage": {
|
||||
"body": "collectgarbage(${1:[opt]}${2:[, arg]})",
|
||||
"description": "5.1,5.2,5.3\n\ncollectgarbage()",
|
||||
"prefix": "collectgarbage",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.create": {
|
||||
"body": "coroutine.create( ${1:function} )",
|
||||
"description": "5.1,5.2,5.3\n\ncoroutine.create",
|
||||
"prefix": "coroutine.create",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.isyieldable": {
|
||||
"body": "coroutine.isyieldable( )",
|
||||
"description": "5.3\n\ncoroutine.isyieldable",
|
||||
"prefix": "coroutine.isyieldable",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.resume": {
|
||||
"body": "coroutine.resume( ${1:co}${2:[, val1, \u00b7\u00b7\u00b7]} )",
|
||||
"description": "5.1,5.2,5.3\n\ncoroutine.resume",
|
||||
"prefix": "coroutine.resume",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.running": {
|
||||
"body": "coroutine.running( )",
|
||||
"description": "5.1,5.2,5.3\n\ncoroutine.running",
|
||||
"prefix": "coroutine.running",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.status": {
|
||||
"body": "coroutine.status( ${1:co} )",
|
||||
"description": "5.1,5.2,5.3\n\ncoroutine.status",
|
||||
"prefix": "coroutine.status",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.wrap": {
|
||||
"body": "coroutine.wrap( ${1:function} )",
|
||||
"description": "5.1,5.2,5.3\n\ncoroutine.wrap",
|
||||
"prefix": "coroutine.wrap",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"coroutine.yield": {
|
||||
"body": "coroutine.yield( ${1:...} )",
|
||||
"description": "5.1,5.2,5.3\n\ncoroutine.yield",
|
||||
"prefix": "coroutine.yield",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"for": {
|
||||
"body": "for ${1:i}=${2:1},${3:10} do\n\t${0:print(i)}\nend",
|
||||
"description": "for i=1,10",
|
||||
"prefix": "for",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"fori": {
|
||||
"body": "for ${1:i},${2:v} in ipairs(${3:table_name}) do\n\t${0:print(i,v)}\nend",
|
||||
"description": "for i,v in ipairs()",
|
||||
"prefix": "fori",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"forp": {
|
||||
"body": "for ${1:k},${2:v} in pairs(${3:table_name}) do\n\t${0:print(k,v)}\nend",
|
||||
"description": "for k,v in pairs()",
|
||||
"prefix": "forp",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"fun": {
|
||||
"body": "function ${1:function_name}( ${2:...} )\n\t${0:-- body}\nend",
|
||||
"description": "function",
|
||||
"prefix": "fun",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"function": {
|
||||
"body": "function ${1:function_name}( ${2:...} )\n\t${0:-- body}\nend",
|
||||
"description": "function",
|
||||
"prefix": "function",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"getfenv": {
|
||||
"body": "getfenv(${0:...})",
|
||||
"description": "5.1\n\ngetfenv ([f])",
|
||||
"prefix": "getfenv",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"getmetatable": {
|
||||
"body": "getmetatable(${1:object})",
|
||||
"description": "5.1,5.2,5.3\n\ngetmetatable (object)",
|
||||
"prefix": "getmetatable",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"if": {
|
||||
"body": "if ${1:condition} then\n\t${0:-- body}\nend",
|
||||
"description": "if",
|
||||
"prefix": "if",
|
||||
"scope": "source.lua"
|
||||
},
|
||||
"ifel": {
|
||||
"body": "if ${1:condition} then\n\t${2:-- body}\nelse\n\t${0:-- body}\nend",
|
||||
"description": "ifel",
|
||||
"prefix": "ifel",
|
||||
"scope": "source.lua"
|
||||
}
|
||||
}
|
||||
13
home/base/desktop/neovim/snippets/lua.lua
Normal file
13
home/base/desktop/neovim/snippets/lua.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
return {
|
||||
-- e.g. local bar = require("foo.bar")
|
||||
s(
|
||||
'require',
|
||||
fmt([[local {} = require("{}")]], {
|
||||
d(2, function(args)
|
||||
local modules = vim.split(args[1][1], '%.')
|
||||
return sn(nil, { i(1, modules[#modules]) })
|
||||
end, { 1 }),
|
||||
i(1),
|
||||
})
|
||||
),
|
||||
}
|
||||
10
home/base/desktop/neovim/snippets/package.json
Normal file
10
home/base/desktop/neovim/snippets/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": "lua",
|
||||
"path": "./lua.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
12
home/base/desktop/neovim/static/neovim.cat
Normal file
12
home/base/desktop/neovim/static/neovim.cat
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
[48;5;0m [38;2;167;201;171m
|
||||
[38;2;31;107;152m███████████ [38;2;57;108;63m█████[38;2;167;201;171m ██
|
||||
[38;2;34;115;163m███████████ [38;2;61;116;68m█████
|
||||
[38;2;36;122;174m███████[48;5;0m██[38;2;20;69;110m[38;2;122;187;225m███████ ███[38;2;65;124;72m████████ [38;2;152;192;157m███ ███████
|
||||
[38;2;38;130;184m█████████[38;2;132;191;226m███████[48;5;0m ████[38;2;69;132;76m████████ [38;2;160;196;164m█████ ██████████████
|
||||
[38;2;40;138;195m█████████[38;2;142;196;228m█████[48;5;0m[38;2;20;69;110m██[38;2;142;196;228m██████[38;2;73;140;81m███████ [38;2;167;201;171m█████ █████ ████ █████
|
||||
[38;2;43;145;206m███████████[38;2;151;200;229m█████████████████[38;2;77;147;86m██████ [38;2;175;205;179m█████ █████ ████ █████
|
||||
[38;2;45;153;217m██████ ███ [38;2;160;204;231m█████████████████ [38;2;81;155;90m████ [38;2;183;209;186m█████ █████ ████ ██████
|
||||
[38;2;20;69;110m██████ ██ ███████████████ [38;2;46;78;42m██ █████████████████
|
||||
██████ ██ ███████████████ ██ █████████████████
|
||||
@@ -52,6 +52,13 @@
|
||||
];
|
||||
|
||||
programs = {
|
||||
# modern vim
|
||||
neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
vimAlias = true;
|
||||
};
|
||||
|
||||
# a cat(1) clone with syntax highlighting and Git integration.
|
||||
bat = {
|
||||
enable = true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./neovim
|
||||
./nushell
|
||||
./tmux
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
require("base")
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
local lazy_theme
|
||||
if os.getenv("GTK_THEME") == "Nordic" then
|
||||
lazy_theme = "nord"
|
||||
elseif os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink" then
|
||||
lazy_theme = "catppuccin-frappe"
|
||||
else
|
||||
lazy_theme = "catppuccin-latte"
|
||||
end
|
||||
local opts = {
|
||||
install = {
|
||||
colorscheme = { lazy_theme },
|
||||
},
|
||||
ui = {
|
||||
size = { width = 1.0, height = 1.0 },
|
||||
},
|
||||
}
|
||||
require("lazy").setup("plugins", opts)
|
||||
@@ -1,16 +0,0 @@
|
||||
--Revert to where the cursor was when the file was last closed
|
||||
vim.cmd([[autocmd BufReadPost *
|
||||
\ if line("'\"") > 1 && line("'\"") <= line("$") |
|
||||
\ exe "normal! g`\"" |
|
||||
\ endif]])
|
||||
|
||||
vim.cmd([[set iskeyword+=-]])
|
||||
|
||||
vim.cmd("set whichwrap+=<,>,[,],h,l")
|
||||
-- about fold
|
||||
vim.cmd("set foldmethod=expr")
|
||||
vim.cmd("set foldexpr=nvim_treesitter#foldexpr()")
|
||||
-- vim.cmd([[autocmd BufReadPost,FileReadPost * normal zR]])
|
||||
|
||||
-- set bg transparent
|
||||
--vim.cmd([[autocmd ColorScheme * highlight Normal guibg=NONE ctermbg=NONE]])
|
||||
@@ -1,3 +0,0 @@
|
||||
require("base.autocmd")
|
||||
require("base.mappings")
|
||||
require("base.options")
|
||||
@@ -1,86 +0,0 @@
|
||||
local opts = { noremap = true, silent = true }
|
||||
local term_opts = { silent = true }
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
|
||||
-- Remap space as leader key
|
||||
keymap("", "<Space>", "<Nop>", opts)
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- Modes
|
||||
-- normal_mode = "n",
|
||||
-- insert_mode = "i",
|
||||
-- visual_mode = "v",
|
||||
-- visual_block_mode = "x",
|
||||
-- term_mode = "t",
|
||||
-- command_mode = "c",
|
||||
|
||||
-- Better to save file & exit file --
|
||||
keymap("n", "Q", ":q<CR>", opts)
|
||||
keymap("n", "S", ":w<CR>", opts)
|
||||
|
||||
-- 'jk' key to exit insert mode --
|
||||
keymap("i", "jk", "<Esc>", opts)
|
||||
|
||||
-- Better window navigation --
|
||||
keymap("n", "<C-h>", "<C-w>h", opts)
|
||||
keymap("n", "<C-j>", "<C-w>j", opts)
|
||||
keymap("n", "<C-k>", "<C-w>k", opts)
|
||||
keymap("n", "<C-l>", "<C-w>l", opts)
|
||||
|
||||
-- Naviagate buffers --
|
||||
keymap("n", "<TAB>", ":bnext<CR>", opts)
|
||||
keymap("n", "<S-TAB>", ":bprevious<CR>", opts)
|
||||
|
||||
-- Stay in indent mode --
|
||||
keymap("v", "<", "<gv", opts)
|
||||
keymap("v", ">", ">gv", opts)
|
||||
|
||||
-- Move text up and down --
|
||||
keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
|
||||
keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
|
||||
keymap("v", "J", ":move '>+1<CR>gv-gv", opts)
|
||||
keymap("v", "K", ":move '<-2<CR>gv-gv", opts)
|
||||
|
||||
-- Better split screen --
|
||||
keymap("", "s", "<Nop>", opts)
|
||||
keymap("n", "sl", ":set splitright<CR>:vsplit<CR>", opts)
|
||||
keymap("n", "sh", ":set nosplitright<CR>:vsplit<CR>", opts)
|
||||
keymap("n", "sk", ":set nosplitbelow<CR>:split<CR>", opts)
|
||||
keymap("n", "sj", ":set splitbelow<CR>:split<CR>", opts)
|
||||
|
||||
-- Average adjustment window --
|
||||
keymap("n", "<C-=>", "<C-w>=", opts)
|
||||
-- Swap and move windows --
|
||||
keymap("n", "<Space>h", "<C-w>H", opts)
|
||||
keymap("n", "<Space>j", "<C-w>J", opts)
|
||||
keymap("n", "<Space>k", "<C-w>K", opts)
|
||||
keymap("n", "<Space>l", "<C-w>L", opts)
|
||||
|
||||
-- Adjust the direction of the split screen --
|
||||
keymap("n", ",", "<C-w>t<C-w>K", opts)
|
||||
keymap("n", ".", "<C-w>t<C-w>H", opts)
|
||||
|
||||
-- Resize the window --
|
||||
keymap("n", "<C-Down>", ":resize -2<CR>", opts)
|
||||
keymap("n", "<C-Up>", ":resize +2<CR>", opts)
|
||||
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
|
||||
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
|
||||
|
||||
-- Better viewing of search results --
|
||||
keymap("n", "<Space><CR>", ":nohlsearch<CR>", opts)
|
||||
keymap("n", "n", "nzz", opts)
|
||||
keymap("n", "N", "Nzz", opts)
|
||||
|
||||
-- tabnew
|
||||
keymap("n", "<C-n>", ":tabnew<CR>", opts)
|
||||
-- msic --
|
||||
keymap("n", "<C-u>", "5k", opts)
|
||||
keymap("n", "<C-d>", "5j", opts)
|
||||
keymap("n", "<C-.>", "$", opts)
|
||||
keymap("i", "<C-.>", "<ESC>$", opts)
|
||||
keymap("x", "<C-.>", "$", opts)
|
||||
keymap("v", "<C-.>", "$", opts)
|
||||
keymap("n", "<C-,>", "^", opts)
|
||||
keymap("i", "<C-,>", "<ESC>^", opts)
|
||||
keymap("x", "<C-,>", "^", opts)
|
||||
keymap("v", "<C-,>", "^", opts)
|
||||
@@ -1,32 +0,0 @@
|
||||
local options = {
|
||||
clipboard = "unnamedplus",
|
||||
mouse = "a",
|
||||
undofile = true,
|
||||
ignorecase = true,
|
||||
smartcase = true,
|
||||
showmode = false,
|
||||
showtabline = 2,
|
||||
smartindent = true,
|
||||
autoindent = true,
|
||||
swapfile = true,
|
||||
hidden = true, --default on
|
||||
expandtab = false,
|
||||
cmdheight = 1,
|
||||
shiftwidth = 4, --insert 4 spaces for each indentation
|
||||
tabstop = 4, --insert 4 spaces for a tab
|
||||
cursorline = false, --Highlight the line where the cursor is located
|
||||
cursorcolumn = false,
|
||||
number = true,
|
||||
numberwidth = 4,
|
||||
relativenumber = true,
|
||||
--[[ wrap = false, ]]
|
||||
scrolloff = 8,
|
||||
fileencodings = "utf-8,gbk",
|
||||
updatetime = 50, -- faster completion (4000ms default)
|
||||
foldenable = false,
|
||||
foldlevel = 99,
|
||||
}
|
||||
|
||||
for k, v in pairs(options) do
|
||||
vim.opt[k] = v
|
||||
end
|
||||
@@ -1,38 +0,0 @@
|
||||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
dependencies = { "hrsh7th/nvim-cmp" },
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
local status_ok, npairs = pcall(require, "nvim-autopairs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
npairs.setup({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
javascript = { "string", "template_string" },
|
||||
java = false,
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
fast_wrap = {
|
||||
map = "<M-e>",
|
||||
chars = { "{", "[", "(", '"', "'" },
|
||||
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
|
||||
offset = 0, -- Offset from pattern match
|
||||
end_key = "$",
|
||||
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
||||
check_comma = true,
|
||||
highlight = "PmenuSel",
|
||||
highlight_grey = "LineNr",
|
||||
},
|
||||
})
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
||||
end,
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
return {
|
||||
"akinsho/bufferline.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons", "glepnir/lspsaga.nvim" },
|
||||
config = function()
|
||||
local highlights
|
||||
if os.getenv("GTK_THEME") == "Nordic" then
|
||||
highlights = require("nord").bufferline.highlights({
|
||||
italic = true,
|
||||
bold = true,
|
||||
})
|
||||
elseif
|
||||
os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink" or os.getenv("GTK_THEME") == "Catppuccin-Latte-Green"
|
||||
then
|
||||
highlights = require("catppuccin.groups.integrations.bufferline").get()
|
||||
end
|
||||
require("bufferline").setup({
|
||||
highlights = highlights,
|
||||
options = {
|
||||
mode = "buffers", -- set to "tabs" to only show tabpages instead
|
||||
numbers = "buffer_id",
|
||||
--number_style = "superscript" | "subscript" | "" | { "none", "subscript" }, -- buffer_id at index 1, ordinal at index 2
|
||||
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
|
||||
indicator_style = "▎",
|
||||
buffer_close_icon = "x",
|
||||
modified_icon = "●",
|
||||
close_icon = "",
|
||||
left_trunc_marker = "",
|
||||
right_trunc_marker = "",
|
||||
max_name_length = 30,
|
||||
max_prefix_length = 30, -- prefix used when a buffer is de-duplicated
|
||||
tab_size = 21,
|
||||
diagnostics = false,
|
||||
diagnostics_update_in_insert = false,
|
||||
offsets = { { filetype = "NvimTree", text = "", padding = 1 } },
|
||||
show_buffer_icons = true, -- disable filetype icons for buffers
|
||||
show_buffer_close_icons = true,
|
||||
show_close_icon = true,
|
||||
show_tab_indicators = true,
|
||||
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
|
||||
-- can also be a table containing 2 custom separators
|
||||
-- [focused and unfocused]. eg: { '|', '|' }
|
||||
separator_style = { "", "" }, --"slant" | "thick" | "thin" | { 'any', 'any' },
|
||||
enforce_regular_tabs = true,
|
||||
always_show_bufferline = true,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-nvim-lua",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
},
|
||||
config = function()
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||
if not snip_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
require("luasnip/loaders/from_vscode").lazy_load()
|
||||
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
-- find more here: https://www.nerdfonts.com/cheat-sheet
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4), -- Up
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4), -- Down
|
||||
-- C-b (back) C-f (forward) for snippet placeholder navigation.
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
select = true,
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
|
||||
vim_item.menu = ({
|
||||
path = "[Path]",
|
||||
nvim_lua = "[NVIM_LUA]",
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
confirm_opts = {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = false,
|
||||
native_menu = false,
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
dependencies = { "JoosepAlviste/nvim-ts-context-commentstring" },
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
require("Comment").setup({
|
||||
pre_hook = function(ctx)
|
||||
local U = require("Comment.utils")
|
||||
|
||||
local location = nil
|
||||
if ctx.ctype == U.ctype.block then
|
||||
location = require("ts_context_commentstring.utils").get_cursor_location()
|
||||
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
|
||||
location = require("ts_context_commentstring.utils").get_visual_start_location()
|
||||
end
|
||||
|
||||
return require("ts_context_commentstring.internal").calculate_commentstring({
|
||||
key = ctx.ctype == U.ctype.line and "__default" or "__multiline",
|
||||
location = location,
|
||||
})
|
||||
end,
|
||||
padding = true,
|
||||
|
||||
---Whether the cursor should stay at its position
|
||||
---NOTE: This only affects NORMAL mode mappings and doesn't work with dot-repeat
|
||||
---@type boolean
|
||||
sticky = true,
|
||||
|
||||
---Lines to be ignored while comment/uncomment.
|
||||
---Could be a regex string or a function that returns a regex string.
|
||||
---Example: Use '^$' to ignore empty lines
|
||||
---@type string|fun():string
|
||||
ignore = nil,
|
||||
|
||||
---LHS of toggle mappings in NORMAL + VISUAL mode
|
||||
---@type table
|
||||
toggler = {
|
||||
---Line-comment toggle keymap
|
||||
line = "gcc",
|
||||
---Block-comment toggle keymap
|
||||
block = "gbc",
|
||||
},
|
||||
|
||||
---LHS of operator-pending mappings in NORMAL + VISUAL mode
|
||||
---@type table
|
||||
opleader = {
|
||||
---Line-comment keymap
|
||||
line = "gc",
|
||||
---Block-comment keymap
|
||||
block = "gb",
|
||||
},
|
||||
|
||||
---LHS of extra mappings
|
||||
---@type table
|
||||
extra = {
|
||||
---Add comment on the line above
|
||||
above = "gcO",
|
||||
---Add comment on the line below
|
||||
below = "gco",
|
||||
---Add comment at the end of line
|
||||
eol = "gcA",
|
||||
},
|
||||
|
||||
---Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode
|
||||
---@type table
|
||||
mappings = {
|
||||
---Operator-pending mapping
|
||||
---Includes `gcc`, `gbc`, `gc[count]{motion}` and `gb[count]{motion}`
|
||||
---NOTE: These mappings can be changed individually by `opleader` and `toggler` config
|
||||
basic = true,
|
||||
---Extra mapping
|
||||
---Includes `gco`, `gcO`, `gcA`
|
||||
extra = true,
|
||||
---Extended mapping
|
||||
---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
|
||||
extended = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
keys = {
|
||||
{ "<F6>", "<cmd>lua require('dapui').toggle()<CR>", desc = "dapui_toggle" },
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
dap.adapters.lldb = {
|
||||
type = "executable",
|
||||
command = "/etc/profiles/per-user/ruixi/bin/lldb-vscode", -- adjust as needed, must be absolute path
|
||||
name = "lldb",
|
||||
}
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "lldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
|
||||
-- 💀
|
||||
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
|
||||
--
|
||||
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
||||
--
|
||||
-- Otherwise you might get the following error:
|
||||
--
|
||||
-- Error on launch: Failed to attach to the target process
|
||||
--
|
||||
-- But you should be aware of the implications:
|
||||
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
|
||||
-- runInTerminal = false,
|
||||
},
|
||||
}
|
||||
|
||||
-- If you want to use this for Rust and C, add something like this:
|
||||
|
||||
dap.configurations.c = dap.configurations.cpp
|
||||
dap.configurations.rust = dap.configurations.cpp
|
||||
end,
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
return {
|
||||
"rcarriga/nvim-dap-ui",
|
||||
dependencies = { "mfussenegger/nvim-dap" },
|
||||
keys = {
|
||||
{ "<C-b>", "<cmd>lua require'dap'.toggle_breakpoint()<CR>", desc = "toggle_breakpoint" },
|
||||
},
|
||||
config = function()
|
||||
require("dapui").setup()
|
||||
local sign = vim.fn.sign_define
|
||||
|
||||
sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" })
|
||||
sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = "" })
|
||||
sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = "" })
|
||||
end,
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
return {
|
||||
"folke/flash.nvim",
|
||||
event = "VeryLazy",
|
||||
keys = {
|
||||
{
|
||||
"<c-f>",
|
||||
mode = { "n", "x", "o" },
|
||||
function()
|
||||
require("flash").jump()
|
||||
end,
|
||||
desc = "Flash",
|
||||
},
|
||||
{
|
||||
"<Leader>t",
|
||||
mode = { "n", "o", "x" },
|
||||
function()
|
||||
require("flash").treesitter()
|
||||
end,
|
||||
desc = "Flash Treesitter",
|
||||
},
|
||||
{
|
||||
"<Leader>r",
|
||||
mode = "o",
|
||||
function()
|
||||
require("flash").remote()
|
||||
end,
|
||||
desc = "Remote Flash",
|
||||
},
|
||||
{
|
||||
"<Leader>T",
|
||||
mode = { "o", "x" },
|
||||
function()
|
||||
require("flash").treesitter_search()
|
||||
end,
|
||||
desc = "Flash Treesitter Search",
|
||||
},
|
||||
{
|
||||
"<Leader>f",
|
||||
mode = { "c" },
|
||||
function()
|
||||
require("flash").toggle()
|
||||
end,
|
||||
desc = "Toggle Flash Search",
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
require("flash").setup({
|
||||
-- labels = "abcdefghijklmnopqrstuvwxyz",
|
||||
labels = "asdfghjklqwertyuiopzxcvbnm",
|
||||
search = {
|
||||
-- search/jump in all windows
|
||||
multi_window = true,
|
||||
-- search direction
|
||||
forward = true,
|
||||
-- when `false`, find only matches in the given direction
|
||||
wrap = true,
|
||||
---type Flash.Pattern.Mode
|
||||
-- Each mode will take ignorecase and smartcase into account.
|
||||
-- * exact: exact match
|
||||
-- * search: regular search
|
||||
-- * fuzzy: fuzzy search
|
||||
-- * fun(str): custom function that returns a pattern
|
||||
-- For example, to only match at the beginning of a word:
|
||||
-- mode = function(str)
|
||||
-- return "\\<" .. str
|
||||
-- end,
|
||||
mode = "fuzzy",
|
||||
-- behave like `incsearch`
|
||||
incremental = false,
|
||||
-- Excluded filetypes and custom window filters
|
||||
---type (string|fun(win:window))[]
|
||||
exclude = {
|
||||
"notify",
|
||||
"cmp_menu",
|
||||
"noice",
|
||||
"flash_prompt",
|
||||
function(win)
|
||||
-- exclude non-focusable windows
|
||||
return not vim.api.nvim_win_get_config(win).focusable
|
||||
end,
|
||||
},
|
||||
-- Optional trigger character that needs to be typed before
|
||||
-- a jump label can be used. It's NOT recommended to set this,
|
||||
-- unless you know what you're doing
|
||||
trigger = "",
|
||||
-- max pattern length. If the pattern length is equal to this
|
||||
-- labels will no longer be skipped. When it exceeds this length
|
||||
-- it will either end in a jump or terminate the search
|
||||
max_length = nil, ---type number?
|
||||
},
|
||||
jump = {
|
||||
-- save location in the jumplist
|
||||
jumplist = true,
|
||||
-- jump position
|
||||
pos = "start", ---type "start" | "end" | "range"
|
||||
-- add pattern to search history
|
||||
history = false,
|
||||
-- add pattern to search register
|
||||
register = false,
|
||||
-- clear highlight after jump
|
||||
nohlsearch = false,
|
||||
-- automatically jump when there is only one match
|
||||
autojump = false,
|
||||
-- You can force inclusive/exclusive jumps by setting the
|
||||
-- `inclusive` option. By default it will be automatically
|
||||
-- set based on the mode.
|
||||
inclusive = nil, ---type boolean?
|
||||
-- jump position offset. Not used for range jumps.
|
||||
-- 0: default
|
||||
-- 1: when pos == "end" and pos < current position
|
||||
offset = nil, ---type number
|
||||
},
|
||||
label = {
|
||||
-- allow uppercase labels
|
||||
uppercase = true,
|
||||
-- add any labels with the correct case here, that you want to exclude
|
||||
exclude = "",
|
||||
-- add a label for the first match in the current window.
|
||||
-- you can always jump to the first match with `<CR>`
|
||||
current = true,
|
||||
-- show the label after the match
|
||||
after = true, ---type boolean|number[]
|
||||
-- show the label before the match
|
||||
before = false, ---type boolean|number[]
|
||||
-- position of the label extmark
|
||||
style = "overlay", ---type "eol" | "overlay" | "right_align" | "inline"
|
||||
-- flash tries to re-use labels that were already assigned to a position,
|
||||
-- when typing more characters. By default only lower-case labels are re-used.
|
||||
reuse = "lowercase", ---type "lowercase" | "all"
|
||||
-- for the current window, label targets closer to the cursor first
|
||||
distance = true,
|
||||
-- minimum pattern length to show labels
|
||||
-- Ignored for custom labelers.
|
||||
min_pattern_length = 0,
|
||||
-- Enable this to use rainbow colors to highlight labels
|
||||
-- Can be useful for visualizing Treesitter ranges.
|
||||
rainbow = {
|
||||
enabled = false,
|
||||
-- number between 1 and 9
|
||||
shade = 5,
|
||||
},
|
||||
-- With `format`, you can change how the label is rendered.
|
||||
-- Should return a list of `[text, highlight]` tuples.
|
||||
---class Flash.Format
|
||||
---field state Flash.State
|
||||
---field match Flash.Match
|
||||
---field hl_group string
|
||||
---field after boolean
|
||||
---type fun(opts:Flash.Format): string[][]
|
||||
format = function(opts)
|
||||
return { { opts.match.label, opts.hl_group } }
|
||||
end,
|
||||
},
|
||||
highlight = {
|
||||
-- show a backdrop with hl FlashBackdrop
|
||||
backdrop = true,
|
||||
-- Highlight the search matches
|
||||
matches = true,
|
||||
-- extmark priority
|
||||
priority = 5000,
|
||||
groups = {
|
||||
match = "FlashMatch",
|
||||
current = "FlashCurrent",
|
||||
backdrop = "FlashBackdrop",
|
||||
label = "FlashLabel",
|
||||
},
|
||||
},
|
||||
-- action to perform when picking a label.
|
||||
-- defaults to the jumping logic depending on the mode.
|
||||
---type fun(match:Flash.Match, state:Flash.State)|nil
|
||||
action = nil,
|
||||
-- initial pattern to use when opening flash
|
||||
pattern = "",
|
||||
-- When `true`, flash will try to continue the last search
|
||||
continue = false,
|
||||
-- Set config to a function to dynamically change the config
|
||||
config = nil, ---type fun(opts:Flash.Config)|nil
|
||||
-- You can override the default options for a specific mode.
|
||||
-- Use it with `require("flash").jump({mode = "forward"})`
|
||||
---type table<string, Flash.Config>
|
||||
modes = {
|
||||
-- options used when flash is activated through
|
||||
-- a regular search with `/` or `?`
|
||||
search = {
|
||||
-- when `true`, flash will be activated during regular search by default.
|
||||
-- You can always toggle when searching with `require("flash").toggle()`
|
||||
enabled = true,
|
||||
highlight = { backdrop = false },
|
||||
jump = { history = true, register = true, nohlsearch = true },
|
||||
search = {
|
||||
-- `forward` will be automatically set to the search direction
|
||||
-- `mode` is always set to `search`
|
||||
-- `incremental` is set to `true` when `incsearch` is enabled
|
||||
},
|
||||
},
|
||||
-- options used when flash is activated through
|
||||
-- `f`, `F`, `t`, `T`, `;` and `,` motions
|
||||
char = {
|
||||
enabled = true,
|
||||
-- dynamic configuration for ftFT motions
|
||||
config = function(opts)
|
||||
-- autohide flash when in operator-pending mode
|
||||
opts.autohide = vim.fn.mode(true):find("no") and vim.v.operator == "y"
|
||||
|
||||
-- disable jump labels when enabled and when using a count
|
||||
opts.jump_labels = opts.jump_labels and vim.v.count == 0
|
||||
|
||||
-- Show jump labels only in operator-pending mode
|
||||
-- opts.jump_labels = vim.v.count == 0 and vim.fn.mode(true):find("o")
|
||||
end,
|
||||
-- hide after jump when not using jump labels
|
||||
autohide = false,
|
||||
-- show jump labels
|
||||
jump_labels = false,
|
||||
-- set to `false` to use the current line only
|
||||
multi_line = true,
|
||||
-- When using jump labels, don't use these keys
|
||||
-- This allows using those keys directly after the motion
|
||||
label = { exclude = "hjkliardc" },
|
||||
-- by default all keymaps are enabled, but you can disable some of them,
|
||||
-- by removing them from the list.
|
||||
-- If you rather use another key, you can map them
|
||||
-- to something else, e.g., { [";"] = "L", [","] = H }
|
||||
keys = { "f", "F", "t", "T" },
|
||||
---alias Flash.CharActions table<string, "next" | "prev" | "right" | "left">
|
||||
-- The direction for `prev` and `next` is determined by the motion.
|
||||
-- `left` and `right` are always left and right.
|
||||
char_actions = function(motion)
|
||||
return {
|
||||
[";"] = "next", -- set to `right` to always go right
|
||||
[","] = "prev", -- set to `left` to always go left
|
||||
-- clever-f style
|
||||
[motion:lower()] = "next",
|
||||
[motion:upper()] = "prev",
|
||||
-- jump2d style: same case goes next, opposite case goes prev
|
||||
-- [motion] = "next",
|
||||
-- [motion:match("%l") and motion:upper() or motion:lower()] = "prev",
|
||||
}
|
||||
end,
|
||||
search = { wrap = false },
|
||||
highlight = { backdrop = true },
|
||||
jump = { register = false },
|
||||
},
|
||||
-- options used for treesitter selections
|
||||
-- `require("flash").treesitter()`
|
||||
treesitter = {
|
||||
labels = "abcdefghijklmnopqrstuvwxyz",
|
||||
jump = { pos = "range" },
|
||||
search = { incremental = false },
|
||||
label = { before = true, after = true, style = "inline" },
|
||||
highlight = {
|
||||
backdrop = false,
|
||||
matches = false,
|
||||
},
|
||||
},
|
||||
treesitter_search = {
|
||||
jump = { pos = "range" },
|
||||
search = { multi_window = true, wrap = true, incremental = false },
|
||||
remote_op = { restore = true },
|
||||
label = { before = true, after = true, style = "inline" },
|
||||
},
|
||||
-- options used for remote flash
|
||||
remote = {
|
||||
remote_op = { restore = true, motion = true },
|
||||
},
|
||||
},
|
||||
-- options for the floating window that shows the prompt,
|
||||
-- for regular jumps
|
||||
prompt = {
|
||||
enabled = true,
|
||||
prefix = { { "🔎", "FlashPromptIcon" } },
|
||||
win_config = {
|
||||
relative = "editor",
|
||||
width = 1, -- when <=1 it's a percentage of the editor width
|
||||
height = 1,
|
||||
row = -1, -- when negative it's an offset from the bottom
|
||||
col = 0, -- when negative it's an offset from the right
|
||||
zindex = 1000,
|
||||
},
|
||||
},
|
||||
-- options for remote operator pending mode
|
||||
remote_op = {
|
||||
-- restore window views and cursor position
|
||||
-- after doing a remote operation
|
||||
restore = false,
|
||||
-- For `jump.pos = "range"`, this setting is ignored.
|
||||
-- `true`: always enter a new motion when doing a remote operation
|
||||
-- `false`: use the window's cursor position and jump target
|
||||
-- `nil`: act as `true` for remote windows, `false` for the current window
|
||||
motion = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
return {
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
|
||||
change = {
|
||||
hl = "GitSignsChange",
|
||||
text = "│",
|
||||
numhl = "GitSignsChangeNr",
|
||||
linehl = "GitSignsChangeLn",
|
||||
},
|
||||
delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
||||
topdelete = {
|
||||
hl = "GitSignsDelete",
|
||||
text = "‾",
|
||||
numhl = "GitSignsDeleteNr",
|
||||
linehl = "GitSignsDeleteLn",
|
||||
},
|
||||
changedelete = {
|
||||
hl = "GitSignsChange",
|
||||
text = "~",
|
||||
numhl = "GitSignsChangeNr",
|
||||
linehl = "GitSignsChangeLn",
|
||||
},
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000,
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = "single",
|
||||
style = "minimal",
|
||||
relative = "cursor",
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
yadm = {
|
||||
enable = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
return {
|
||||
"lukas-reineke/headlines.nvim",
|
||||
ft = { "norg", "markdown", "orgmode" },
|
||||
config = function()
|
||||
require("headlines").setup({
|
||||
markdown = {
|
||||
headline_highlights = {
|
||||
"Headline1",
|
||||
"Headline2",
|
||||
"Headline3",
|
||||
"Headline4",
|
||||
"Headline5",
|
||||
"Headline6",
|
||||
},
|
||||
codeblock_highlight = "CodeBlock",
|
||||
dash_highlight = "Dash",
|
||||
quote_highlight = "Quote",
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
return {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
config = function()
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars:append("space:⋅")
|
||||
vim.opt.listchars:append("eol:↴")
|
||||
|
||||
require("indent_blankline").setup({
|
||||
char = "▏",
|
||||
show_end_of_line = true,
|
||||
space_char_blankline = " ",
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
return {
|
||||
"kdheepak/lazygit.nvim",
|
||||
keys = {
|
||||
{ "<Leader>g", "<cmd>LazyGit<CR>", desc = "lazygit" },
|
||||
},
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
local nvim_lsp = require("lspconfig")
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
-- nvim hasn't added foldingRange to default capabilities, users must add it manually
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
|
||||
--Change diagnostic symbols in the sign column (gutter)
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = false,
|
||||
})
|
||||
|
||||
local on_attach = function(bufnr)
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "line",
|
||||
}
|
||||
vim.diagnostic.show()
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
end
|
||||
---------------------
|
||||
-- setup languages --
|
||||
---------------------
|
||||
-- nix
|
||||
nvim_lsp.nixd.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
-- GoLang
|
||||
nvim_lsp["gopls"].setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
gopls = {
|
||||
experimentalPostfixCompletions = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
shadow = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
},
|
||||
})
|
||||
--Rust
|
||||
-- require("rust-tools").setup({
|
||||
-- server = {
|
||||
-- capabilities = capabilities,
|
||||
-- on_attach = on_attach(),
|
||||
-- },
|
||||
-- }) -- C
|
||||
nvim_lsp.clangd.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
--Python
|
||||
nvim_lsp.pyright.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = "workspace",
|
||||
useLibraryCodeForTypes = true,
|
||||
typeCheckingMode = "off",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
--sumneko_lua
|
||||
nvim_lsp.lua_ls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
nvim_lsp.rust_analyzer.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
nvim_lsp.html.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "vscode-html-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.cssls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "vscode-css-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.zk.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "zk", "lsp" },
|
||||
})
|
||||
|
||||
nvim_lsp.tsserver.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.bashls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "bash-language-server", "start" },
|
||||
})
|
||||
|
||||
--nvim_lsp.rnix.setup({
|
||||
-- on_attach = on_attach(),
|
||||
-- capabilities = capabilities,
|
||||
--})
|
||||
--nvim_lsp.nil_ls.setup({
|
||||
-- on_attach = on_attach(),
|
||||
-- settings = {
|
||||
-- ["nil"] = {
|
||||
-- nix = {
|
||||
-- flake = {
|
||||
-- autoArchive = true,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
--})
|
||||
nvim_lsp.hls.setup({})
|
||||
|
||||
-- ebuild Syntastic(install dev-util/pkgcheck)
|
||||
vim.g.syntastic_ebuild_checkers = "pkgcheck"
|
||||
|
||||
--[[ -- Global mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist)
|
||||
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
-- Manual, triggered completion is provided by Nvim's builtin omnifunc. For autocompletion, a general purpose autocompletion plugin(.i.e nvim-cmp) is required
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<space>wl", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts)
|
||||
end,
|
||||
}) ]]
|
||||
|
||||
-- show diagnostics when InsertLeave
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "go", "rust", "nix", "c++" },
|
||||
callback = function(args)
|
||||
vim.api.nvim_create_autocmd("DiagnosticChanged", {
|
||||
buffer = args.buf,
|
||||
callback = function()
|
||||
vim.diagnostic.hide()
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "InsertLeave", "BufWritePost" }, {
|
||||
buffer = args.buf,
|
||||
callback = function()
|
||||
vim.diagnostic.show()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
-- 为特定语言开启 inlay_hint 功能
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "rust" },
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint(0, true)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
return {
|
||||
"glepnir/lspsaga.nvim",
|
||||
event = "BufRead",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
config = function()
|
||||
local colors, kind
|
||||
if os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink" or os.getenv("GTK_THEME") == "Catppuccin-Latte-Green" then
|
||||
colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors()
|
||||
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind()
|
||||
else
|
||||
colors = { normal_bg = "#3b4252" }
|
||||
end
|
||||
require("lspsaga").setup({
|
||||
ui = {
|
||||
colors = colors,
|
||||
kind = kind,
|
||||
border = "single",
|
||||
},
|
||||
outline = {
|
||||
win_width = 25,
|
||||
},
|
||||
})
|
||||
--Switch theme again after lspsaga loaded from
|
||||
if os.getenv("GTK_THEME") == "Nordic" then
|
||||
vim.cmd([[ colorscheme nord ]])
|
||||
elseif os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink" then
|
||||
vim.cmd([[colorscheme catppuccin-frappe ]])
|
||||
else
|
||||
vim.cmd([[colorscheme catppuccin-latte ]])
|
||||
end
|
||||
|
||||
local keymap = vim.keymap.set
|
||||
-- Lsp finder find the symbol definition implement reference
|
||||
-- if there is no implement it will hide
|
||||
-- when you use action in finder like open vsplit then you can
|
||||
-- use <C-t> to jump back
|
||||
keymap("n", "gh", "<cmd>Lspsaga lsp_finder<CR>")
|
||||
|
||||
-- Code action
|
||||
keymap({ "n", "v" }, "<leader>ca", "<cmd>Lspsaga code_action<CR>")
|
||||
|
||||
-- Rename
|
||||
keymap("n", "gr", "<cmd>Lspsaga rename<CR>")
|
||||
|
||||
-- Rename word in whole project
|
||||
keymap("n", "gr", "<cmd>Lspsaga rename ++project<CR>")
|
||||
|
||||
-- Peek Definition
|
||||
-- you can edit the definition file in this float window
|
||||
-- also support open/vsplit/etc operation check definition_action_keys
|
||||
-- support tagstack C-t jump back
|
||||
keymap("n", "gD", "<cmd>Lspsaga peek_definition<CR>")
|
||||
|
||||
-- Go to Definition
|
||||
keymap("n", "gd", "<cmd>Lspsaga goto_definition<CR>")
|
||||
|
||||
-- Show line diagnostics you can pass argument ++unfocus to make
|
||||
-- show_line_diagnostics float window unfocus
|
||||
keymap("n", "<leader>sl", "<cmd>Lspsaga show_line_diagnostics<CR>")
|
||||
|
||||
-- Show cursor diagnostic
|
||||
-- also like show_line_diagnostics support pass ++unfocus
|
||||
keymap("n", "<leader>sc", "<cmd>Lspsaga show_cursor_diagnostics<CR>")
|
||||
|
||||
-- Show buffer diagnostic
|
||||
keymap("n", "<leader>sb", "<cmd>Lspsaga show_buf_diagnostics<CR>")
|
||||
|
||||
-- Diagnostic jump can use `<c-o>` to jump back
|
||||
keymap("n", "[e", "<cmd>Lspsaga diagnostic_jump_prev<CR>")
|
||||
keymap("n", "]e", "<cmd>Lspsaga diagnostic_jump_next<CR>")
|
||||
|
||||
-- Diagnostic jump with filter like Only jump to error
|
||||
keymap("n", "[E", function()
|
||||
require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR })
|
||||
end)
|
||||
keymap("n", "]E", function()
|
||||
require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR })
|
||||
end)
|
||||
|
||||
-- Toggle Outline
|
||||
keymap("n", "<leader>o", "<cmd>Lspsaga outline<CR>")
|
||||
|
||||
-- Hover Doc
|
||||
-- if there has no hover will have a notify no information available
|
||||
-- to disable it just Lspsaga hover_doc ++quiet
|
||||
-- press twice it will jump into hover window
|
||||
--[[ keymap("n", "K", "<cmd>Lspsaga hover_doc<CR>") ]]
|
||||
-- if you want keep hover window in right top you can use ++keep arg
|
||||
-- notice if you use hover with ++keep you press this keymap it will
|
||||
-- close the hover window .if you want jump to hover window must use
|
||||
-- wincmd command <C-w>w
|
||||
keymap("n", "K", "<cmd>Lspsaga hover_doc ++keep<CR>")
|
||||
|
||||
-- Callhierarchy
|
||||
keymap("n", "<Leader>ci", "<cmd>Lspsaga incoming_calls<CR>")
|
||||
keymap("n", "<Leader>co", "<cmd>Lspsaga outgoing_calls<CR>")
|
||||
|
||||
-- Float terminal
|
||||
keymap({ "n", "t" }, "<A-d>", "<cmd>Lspsaga term_toggle<CR>")
|
||||
end,
|
||||
}
|
||||
@@ -1,670 +0,0 @@
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "BufWinEnter",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
if os.getenv("GTK_THEME") == "Nordic" then
|
||||
local lualine = require("lualine")
|
||||
-- Color table for highlights
|
||||
-- stylua: ignore
|
||||
local colors = {
|
||||
bg = '#3B4252', --nord:#3B4252 catppuccin:#302D41
|
||||
fg = '#D6DCE7',
|
||||
yellow = '#ECBE7B',
|
||||
cyan = '#008080',
|
||||
darkblue = '#081633',
|
||||
green = '#98be65',
|
||||
orange = '#FF8800',
|
||||
violet = '#a9a1e1',
|
||||
magenta = '#c678dd',
|
||||
blue = '#51afef',
|
||||
red = '#ec5f67',
|
||||
custom = '#B38DAC',
|
||||
}
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand("%:p:h")
|
||||
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
globalstatus = true,
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x ot right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- mode component
|
||||
function()
|
||||
return ""
|
||||
end,
|
||||
color = function()
|
||||
-- auto change color according to neovims mode
|
||||
local mode_color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.blue,
|
||||
[""] = colors.blue,
|
||||
V = colors.blue,
|
||||
c = colors.magenta,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[""] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
["r?"] = colors.cyan,
|
||||
["!"] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = mode_color[vim.fn.mode()] }
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- filesize component
|
||||
"filesize",
|
||||
cond = conditions.buffer_not_empty,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
"filename",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_left({ "location" })
|
||||
|
||||
ins_left({ "progress", color = { fg = colors.fg, gui = "bold" } })
|
||||
|
||||
ins_left({
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " " },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
})
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
function()
|
||||
return "%="
|
||||
end,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "No Active Lsp"
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = " LSP:",
|
||||
color = { fg = "#D8DEE9", gui = "bold" },
|
||||
})
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
"o:encoding", -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"fileformat",
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"branch",
|
||||
icon = "",
|
||||
color = { fg = colors.violet, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"diff",
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
})
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
elseif os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink" then
|
||||
local lualine = require("lualine")
|
||||
|
||||
-- Color table for highlights
|
||||
-- stylua: ignore
|
||||
local colors = {
|
||||
bg = '#302D41', --nord:#3B4252 catppuccin:#302D41
|
||||
fg = '#bbc2cf',
|
||||
yellow = '#ECBE7B',
|
||||
cyan = '#008080',
|
||||
darkblue = '#081633',
|
||||
green = '#98be65',
|
||||
orange = '#FF8800',
|
||||
violet = '#a9a1e1',
|
||||
magenta = '#c678dd',
|
||||
blue = '#51afef',
|
||||
red = '#ec5f67',
|
||||
custom = '#b0c4de',
|
||||
}
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand("%:p:h")
|
||||
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
globalstatus = true,
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x ot right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- mode component
|
||||
function()
|
||||
return ""
|
||||
end,
|
||||
color = function()
|
||||
-- auto change color according to neovims mode
|
||||
local mode_color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.blue,
|
||||
[""] = colors.blue,
|
||||
V = colors.blue,
|
||||
c = colors.magenta,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[""] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
["r?"] = colors.cyan,
|
||||
["!"] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = mode_color[vim.fn.mode()] }
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- filesize component
|
||||
"filesize",
|
||||
cond = conditions.buffer_not_empty,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
"filename",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_left({ "location" })
|
||||
|
||||
ins_left({ "progress", color = { fg = colors.fg, gui = "bold" } })
|
||||
|
||||
ins_left({
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " " },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
})
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
function()
|
||||
return "%="
|
||||
end,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "No Active Lsp"
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = " LSP:",
|
||||
color = { fg = "#ffffff", gui = "bold" },
|
||||
})
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
"o:encoding", -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"fileformat",
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"branch",
|
||||
icon = "",
|
||||
color = { fg = colors.violet, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"diff",
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
})
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
else
|
||||
local lualine = require("lualine")
|
||||
|
||||
-- Color table for highlights
|
||||
-- stylua: ignore
|
||||
local colors = {
|
||||
bg = '#FAF4FC', --nord:#3B4252 catppuccin:#302D41
|
||||
fg = '#1E1E2E',
|
||||
yellow = '#ECBE7B',
|
||||
cyan = '#008080',
|
||||
darkblue = '#081633',
|
||||
green = '#98be65',
|
||||
orange = '#FF8800',
|
||||
violet = '#a9a1e1',
|
||||
magenta = '#c678dd',
|
||||
blue = '#51afef',
|
||||
red = '#ec5f67',
|
||||
custom = '#FF99CC',
|
||||
}
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand("%:p:h")
|
||||
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
globalstatus = true,
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x ot right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- mode component
|
||||
function()
|
||||
return ""
|
||||
end,
|
||||
color = function()
|
||||
-- auto change color according to neovims mode
|
||||
local mode_color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.blue,
|
||||
[""] = colors.blue,
|
||||
V = colors.blue,
|
||||
c = colors.magenta,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[""] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
["r?"] = colors.cyan,
|
||||
["!"] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = mode_color[vim.fn.mode()] }
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- filesize component
|
||||
"filesize",
|
||||
cond = conditions.buffer_not_empty,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
"filename",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_left({ "location" })
|
||||
|
||||
ins_left({ "progress", color = { fg = colors.fg, gui = "bold" } })
|
||||
|
||||
ins_left({
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " " },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
})
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
function()
|
||||
return "%="
|
||||
end,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "No Active Lsp"
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = " LSP:",
|
||||
color = { fg = "#474E6D", gui = "bold" },
|
||||
})
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
"o:encoding", -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"fileformat",
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"branch",
|
||||
icon = "",
|
||||
color = { fg = colors.violet, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"diff",
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
})
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
end
|
||||
end,
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
return {
|
||||
"iamcco/markdown-preview.nvim",
|
||||
keys = {
|
||||
{ "mp", "<cmd>MarkdownPreview<CR>", desc = "MarkdownPreview" },
|
||||
},
|
||||
build = "cd app && npm install",
|
||||
init = function()
|
||||
vim.g.mkdp_filetypes = { "markdown" }
|
||||
end,
|
||||
ft = { "markdown" },
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
return {
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"rcarriga/nvim-notify",
|
||||
},
|
||||
config = function()
|
||||
require("noice").setup({
|
||||
routes = {
|
||||
{
|
||||
view = "notify",
|
||||
filter = { event = "msg_showmode" },
|
||||
},
|
||||
},
|
||||
views = {
|
||||
cmdline_popup = {
|
||||
position = {
|
||||
row = 5,
|
||||
col = "50%",
|
||||
},
|
||||
size = {
|
||||
width = 60,
|
||||
height = "auto",
|
||||
},
|
||||
},
|
||||
popupmenu = {
|
||||
relative = "editor",
|
||||
position = {
|
||||
row = 8,
|
||||
col = "50%",
|
||||
},
|
||||
size = {
|
||||
width = 60,
|
||||
height = 10,
|
||||
},
|
||||
border = {
|
||||
style = "rounded",
|
||||
padding = { 0, 1 },
|
||||
},
|
||||
win_options = {
|
||||
winhighlight = { Normal = "Normal", FloatBorder = "DiagnosticInfo" },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
return {
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
-- you must download code formatter by yourself!
|
||||
require("null-ls").builtins.formatting.stylua,
|
||||
require("null-ls").builtins.formatting.black,
|
||||
require("null-ls").builtins.formatting.prettier,
|
||||
require("null-ls").builtins.formatting.gofmt,
|
||||
require("null-ls").builtins.formatting.nixpkgs_fmt,
|
||||
require("null-ls").builtins.formatting.beautysh,
|
||||
require("null-ls").builtins.formatting.rustfmt,
|
||||
require("null-ls").builtins.formatting.stylish_haskell,
|
||||
},
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
return {
|
||||
"leoluz/nvim-dap-go",
|
||||
ft = { "go" },
|
||||
config = function()
|
||||
require("dap-go").setup()
|
||||
end,
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
return {
|
||||
"kylechui/nvim-surround",
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
require("nvim-surround").setup()
|
||||
end,
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
return {
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
keys = {
|
||||
{ "tt", "<cmd>NvimTreeToggle<cr>", desc = "NvimTree" },
|
||||
},
|
||||
config = function()
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.opt.termguicolors = true
|
||||
require("nvim-tree").setup({ -- BEGIN_DEFAULT_OPTS
|
||||
sort_by = "case_sensitive",
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = true,
|
||||
},
|
||||
view = {
|
||||
width = 25,
|
||||
--[[ height = 30, ]]
|
||||
side = "left",
|
||||
--[[ float = {
|
||||
enable = true,
|
||||
open_win_config = {
|
||||
relative = "editor",
|
||||
--border = "rounded",
|
||||
width = 65,
|
||||
height = 25,
|
||||
row = 6,
|
||||
col = 45,
|
||||
},
|
||||
}, ]]
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
keys = {
|
||||
{ "<Leader>e", "<cmd>Telescope<CR>", desc = "telescope" },
|
||||
},
|
||||
config = function()
|
||||
local status_ok, telescope = pcall(require, "telescope")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
prompt_prefix = " ",
|
||||
selection_caret = " ",
|
||||
path_display = { "smart" },
|
||||
color_devicons = true,
|
||||
sorting_strategy = "ascending",
|
||||
layout_config = {
|
||||
prompt_position = "top",
|
||||
horizontal = {
|
||||
width_padding = 0.04,
|
||||
height_padding = 0.1,
|
||||
preview_width = 0.6,
|
||||
},
|
||||
vertical = {
|
||||
width_padding = 0.05,
|
||||
height_padding = 1,
|
||||
preview_height = 0.5,
|
||||
},
|
||||
},
|
||||
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-n>"] = actions.cycle_history_next,
|
||||
["<C-p>"] = actions.cycle_history_prev,
|
||||
|
||||
["<C-j>"] = actions.move_selection_next,
|
||||
["<C-k>"] = actions.move_selection_previous,
|
||||
|
||||
["<C-c>"] = actions.close,
|
||||
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
|
||||
["<CR>"] = actions.select_default,
|
||||
["<C-x>"] = actions.select_horizontal,
|
||||
["<C-v>"] = actions.select_vertical,
|
||||
["<C-t>"] = actions.select_tab,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
|
||||
["<PageUp>"] = actions.results_scrolling_up,
|
||||
["<PageDown>"] = actions.results_scrolling_down,
|
||||
|
||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
["<C-l>"] = actions.complete_tag,
|
||||
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
|
||||
},
|
||||
|
||||
n = {
|
||||
["<esc>"] = actions.close,
|
||||
["<CR>"] = actions.select_default,
|
||||
["<C-x>"] = actions.select_horizontal,
|
||||
["<C-v>"] = actions.select_vertical,
|
||||
["<C-t>"] = actions.select_tab,
|
||||
|
||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
|
||||
["j"] = actions.move_selection_next,
|
||||
["k"] = actions.move_selection_previous,
|
||||
["H"] = actions.move_to_top,
|
||||
["M"] = actions.move_to_middle,
|
||||
["L"] = actions.move_to_bottom,
|
||||
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
["gg"] = actions.move_to_top,
|
||||
["G"] = actions.move_to_bottom,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
|
||||
["<PageUp>"] = actions.results_scrolling_up,
|
||||
["<PageDown>"] = actions.results_scrolling_down,
|
||||
|
||||
["?"] = actions.which_key,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
-- Default configuration for builtin pickers goes here:
|
||||
-- picker_name = {
|
||||
-- picker_config_key = value,
|
||||
-- ...
|
||||
-- }
|
||||
-- Now the picker_config_key will be applied every time you call this
|
||||
-- builtin picker
|
||||
},
|
||||
extensions = {
|
||||
-- Your extension configuration goes here:
|
||||
-- extension_name = {
|
||||
-- extension_config_key = value,
|
||||
-- }
|
||||
-- please take a look at the readme of the extension you want to configure
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"shaunsingh/nord.nvim",
|
||||
lazy = false, -- make sure we load this during startup if it is your main colorscheme
|
||||
cond = function()
|
||||
if os.getenv("GTK_THEME") == "Nordic" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
priority = 1000, -- make sure to load this before all the other start plugins
|
||||
config = function()
|
||||
vim.g.nord_contrast = false
|
||||
vim.g.nord_borders = true
|
||||
vim.g.nord_disable_background = false
|
||||
vim.g.nord_italic = true
|
||||
vim.g.nord_uniform_diff_background = true
|
||||
vim.g.nord_enable_sidebar_background = true
|
||||
vim.g.nord_bold = true
|
||||
vim.g.nord_cursorline_transparent = false
|
||||
require("nord").set()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
lazy = false, -- make sure we load this during startup if it is your main colorscheme
|
||||
name = "catppuccin",
|
||||
priority = 1000, -- make sure to load this before all the other start plugins
|
||||
cond = function()
|
||||
if
|
||||
os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink"
|
||||
or os.getenv("GTK_THEME") == "Catppuccin-Latte-Green"
|
||||
then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
config = function()
|
||||
require("catppuccin").setup({
|
||||
compile_path = vim.fn.stdpath("cache") .. "/catppuccin",
|
||||
transparent_background = true,
|
||||
term_colors = true,
|
||||
dim_inactive = {
|
||||
enabled = false,
|
||||
shade = "dark",
|
||||
percentage = 0.15,
|
||||
},
|
||||
styles = {
|
||||
comments = { "italic" },
|
||||
conditionals = { "italic" },
|
||||
loops = {},
|
||||
functions = {},
|
||||
keywords = {},
|
||||
strings = {},
|
||||
variables = {},
|
||||
numbers = {},
|
||||
booleans = {},
|
||||
properties = {},
|
||||
types = {},
|
||||
operators = {},
|
||||
},
|
||||
integrations = {
|
||||
cmp = true,
|
||||
gitsigns = true,
|
||||
nvimtree = true,
|
||||
telescope = true,
|
||||
treesitter = true,
|
||||
ts_rainbow = true,
|
||||
lsp_saga = true,
|
||||
lsp_trouble = true,
|
||||
dap = {
|
||||
enable = true,
|
||||
enable_ui = true,
|
||||
},
|
||||
native_lsp = {
|
||||
enabled = true,
|
||||
virtual_text = {
|
||||
errors = { "italic" },
|
||||
hints = { "italic" },
|
||||
warnings = { "italic" },
|
||||
information = { "italic" },
|
||||
},
|
||||
underlines = {
|
||||
errors = { "underline" },
|
||||
hints = { "underline" },
|
||||
warnings = { "underline" },
|
||||
information = { "underline" },
|
||||
},
|
||||
},
|
||||
indent_blankline = {
|
||||
enabled = true,
|
||||
colored_indent_levels = false,
|
||||
},
|
||||
|
||||
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
|
||||
},
|
||||
color_overrides = {},
|
||||
custom_highlights = {},
|
||||
})
|
||||
if os.getenv("GTK_THEME") == "Catppuccin-Frappe-Pink" then
|
||||
vim.cmd([[colorscheme catppuccin-frappe ]])
|
||||
else
|
||||
vim.cmd([[colorscheme catppuccin-latte ]])
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
return {
|
||||
"akinsho/toggleterm.nvim",
|
||||
config = function()
|
||||
require("toggleterm").setup({
|
||||
-- size can be a number or function which is passed the current terminal
|
||||
size = function(term)
|
||||
if term.direction == "horizontal" then
|
||||
return 15
|
||||
elseif term.direction == "vertical" then
|
||||
return vim.o.columns * 0.4
|
||||
end
|
||||
end,
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true, -- hide the number column in toggleterm buffers
|
||||
shade_filetypes = {},
|
||||
shade_terminals = false,
|
||||
-- shading_factor = "<number>", -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
|
||||
start_in_insert = true,
|
||||
insert_mappings = true, -- whether or not the open mapping applies in insert mode
|
||||
terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
|
||||
persist_size = true,
|
||||
direction = "horizontal", --'vertical' | 'horizontal' | 'window' | 'float',
|
||||
close_on_exit = true, -- close the terminal window when the process exits
|
||||
shell = vim.o.shell, -- change the default shell
|
||||
-- This field is only relevant if direction is set to 'float'
|
||||
float_opts = {
|
||||
-- The border key is *almost* the same as 'nvim_open_win'
|
||||
-- see :h nvim_open_win for details on borders however
|
||||
-- the 'curved' border is a custom border type
|
||||
-- not natively supported but implemented in this plugin.
|
||||
border = "single", --'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
|
||||
width = 80,
|
||||
height = 20,
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
winbar = {
|
||||
enabled = true,
|
||||
name_formatter = function(term) -- term: Terminal
|
||||
return term.name
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
function runFile()
|
||||
local ft = vim.bo.filetype
|
||||
local run_cmd = { go = "go run", rust = "cargo run" }
|
||||
if run_cmd[ft] then
|
||||
vim.cmd("TermExec cmd=" .. '\'clear;echo "Run current file..."; ' .. run_cmd[ft] .. " %'")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("n", "<space>r", "<cmd>lua runFile()<CR>", { noremap = true, silent = true })
|
||||
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = { buffer = 0 }
|
||||
vim.keymap.set("t", "<esc>", [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set("t", "jk", [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set("t", "<C-h>", [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-j>", [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-k>", [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-l>", [[<Cmd>wincmd l<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-w>", [[<C-\><C-n><C-w>]], opts)
|
||||
end
|
||||
|
||||
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
|
||||
vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()")
|
||||
end,
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
local configs = require("nvim-treesitter.configs")
|
||||
configs.setup({
|
||||
ensure_installed = "all",
|
||||
sync_install = false,
|
||||
auto_install = true,
|
||||
ignore_install = { "" }, -- List of parsers to ignore installing
|
||||
autopairs = {
|
||||
enable = true,
|
||||
},
|
||||
highlight = {
|
||||
enable = true, -- false will disable the whole extension
|
||||
disable = { "" }, -- list of language that will be disabled
|
||||
additional_vim_regex_highlighting = true,
|
||||
},
|
||||
indent = { enable = true, disable = { "" } },
|
||||
rainbow = {
|
||||
enable = true,
|
||||
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
|
||||
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
|
||||
max_file_lines = nil, -- Do not enable for files with more than n lines, int
|
||||
-- colors = {}, -- table of hex strings
|
||||
-- termcolors = {} -- table of colour name strings
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
enable_autocmd = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
return {
|
||||
"folke/trouble.nvim",
|
||||
keys = {
|
||||
{ "tr", "<cmd>TroubleToggle<cr>", desc = "trouble" },
|
||||
},
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
return {
|
||||
"p00f/nvim-ts-rainbow",
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
return {
|
||||
"mbbill/undotree",
|
||||
event = "InsertEnter",
|
||||
}
|
||||
Reference in New Issue
Block a user