mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-21 00:11:26 +02:00
feat: migrate to astronvim
This commit is contained in:
@@ -128,3 +128,4 @@ Other dotfiles && docs that inspired me:
|
||||
- [davidtwco/veritas](https://github.com/davidtwco/veritas)
|
||||
- [gvolpe/nix-config](https://github.com/gvolpe/nix-config)
|
||||
- [Ruixi-rebirth/flakes](https://github.com/Ruixi-rebirth/flakes)
|
||||
- [maxbrunet/dotfiles](https://github.com/maxbrunet/dotfiles): astronvim with nix flakes.
|
||||
|
||||
66
flake.lock
generated
66
flake.lock
generated
@@ -21,6 +21,23 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"astronvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1689088588,
|
||||
"narHash": "sha256-nsUcYhBF0tBY71lFbOLM6TrxK4AF6w+CB5jfEKLB2yk=",
|
||||
"owner": "AstroNvim",
|
||||
"repo": "AstroNvim",
|
||||
"rev": "43d458135a534beead8f32158c1d9293adb202dc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "AstroNvim",
|
||||
"ref": "v3.32.0",
|
||||
"repo": "AstroNvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -50,11 +67,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688999459,
|
||||
"narHash": "sha256-b0rFzeHWXGq2rrx+W93I1Lpb0HFq0T5Pfx7QLVcZ/jE=",
|
||||
"lastModified": 1689116343,
|
||||
"narHash": "sha256-eaYfwQTSEbuB7rs5/W227SbVeDP9cbcoT1TEbnmOgOk=",
|
||||
"owner": "lnl7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "83620edf499ba8033ad43d4f5edc50fdf3eeee5f",
|
||||
"rev": "eb22022ba8faeeb7a9be8afe925511b88ad12ca5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -105,11 +122,11 @@
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687709756,
|
||||
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
|
||||
"lastModified": 1689068808,
|
||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
|
||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -209,11 +226,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688904595,
|
||||
"narHash": "sha256-ZEEDxrc7WSa3A1CBY6M+gwdnybYWBlu2Dhd7jLiTaUs=",
|
||||
"lastModified": 1689077483,
|
||||
"narHash": "sha256-BltnzGstbdUSq2KXFtclcPysFd5mZUq9ry0OJXWlXsk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "lib-aggregate",
|
||||
"rev": "f451e910531a7dd731ab4c25174b23a2d320fe4d",
|
||||
"rev": "3d7aa88dc86f7500d13b891204261ab290c361f9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -295,11 +312,11 @@
|
||||
},
|
||||
"nixpkgs-darwin": {
|
||||
"locked": {
|
||||
"lastModified": 1688939073,
|
||||
"narHash": "sha256-jYhYjeK5s6k8QS3i+ovq9VZqBJaWbxm7awTKNhHL9d0=",
|
||||
"lastModified": 1689048911,
|
||||
"narHash": "sha256-pODI2CkjWbSLo5nPMZoLtkRNJU/Nr3VSITXZqqmNtIk=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b",
|
||||
"rev": "8163a64662b43848802092d52015ef60777d6129",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -326,11 +343,11 @@
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1688918189,
|
||||
"narHash": "sha256-f8ZlJ67LgEUDnN7ZsAyd1/Fyby1VdOXWg4XY/irSGrQ=",
|
||||
"lastModified": 1689008574,
|
||||
"narHash": "sha256-VFMgyHDiqsGDkRg73alv6OdHJAqhybryWHv77bSCGIw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "408c0e8c15a1c9cf5c3226931b6f283c9867c484",
|
||||
"rev": "4a729ce4b1fe5ec4fffc71c67c96aa5184ebb462",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -348,11 +365,11 @@
|
||||
"nixpkgs": "nixpkgs_5"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688987658,
|
||||
"narHash": "sha256-hKvYJwjbo3JtJzX0X8bUGWmiDmGBlnL8Lln+YRXmjF8=",
|
||||
"lastModified": 1689102834,
|
||||
"narHash": "sha256-V+KktXbks2Z3FGuGcxc90NdKmKgAU53CHPSZ7OFm1P0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "d78e947b1770490bac0d6dfaa89bd62314e91d73",
|
||||
"rev": "98aac0e8605837c4544707296680e94716bd0d20",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -379,11 +396,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1688939073,
|
||||
"narHash": "sha256-jYhYjeK5s6k8QS3i+ovq9VZqBJaWbxm7awTKNhHL9d0=",
|
||||
"lastModified": 1689048911,
|
||||
"narHash": "sha256-pODI2CkjWbSLo5nPMZoLtkRNJU/Nr3VSITXZqqmNtIk=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b",
|
||||
"rev": "8163a64662b43848802092d52015ef60777d6129",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -411,11 +428,11 @@
|
||||
},
|
||||
"nixpkgs_5": {
|
||||
"locked": {
|
||||
"lastModified": 1688918189,
|
||||
"narHash": "sha256-f8ZlJ67LgEUDnN7ZsAyd1/Fyby1VdOXWg4XY/irSGrQ=",
|
||||
"lastModified": 1689008574,
|
||||
"narHash": "sha256-VFMgyHDiqsGDkRg73alv6OdHJAqhybryWHv77bSCGIw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "408c0e8c15a1c9cf5c3226931b6f283c9867c484",
|
||||
"rev": "4a729ce4b1fe5ec4fffc71c67c96aa5184ebb462",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -428,6 +445,7 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"astronvim": "astronvim",
|
||||
"darwin": "darwin_2",
|
||||
"home-manager": "home-manager_2",
|
||||
"hyprland": "hyprland",
|
||||
|
||||
@@ -71,6 +71,9 @@
|
||||
|
||||
# secrets management, lock with git commit at 2023/5/15
|
||||
agenix.url = "github:ryantm/agenix/db5637d10f797bb251b94ef9040b237f4702cde3";
|
||||
|
||||
# AstroNvim is an aesthetic and feature-rich neovim config.
|
||||
astronvim = { url = "github:AstroNvim/AstroNvim/v3.32.0"; flake = false; };
|
||||
};
|
||||
|
||||
# The `outputs` function will return all the build results of the flake.
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
# 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
|
||||
151
home/base/desktop/neovim/astronvim_user_init.lua
Normal file
151
home/base/desktop/neovim/astronvim_user_init.lua
Normal file
@@ -0,0 +1,151 @@
|
||||
return {
|
||||
colorscheme = "catppuccin",
|
||||
|
||||
options = {
|
||||
opt = {
|
||||
cmdheight = 1, -- Always display cmd line
|
||||
foldcolumn = "0", -- Hide foldcolumn
|
||||
guicursor = "", -- Disable Nvim GUI cursor
|
||||
mouse = "", -- Disable mouse support
|
||||
number = false, -- Hide numberline
|
||||
relativenumber = false, -- Hide relative numberline
|
||||
signcolumn = "auto", -- Show sign column when used only
|
||||
spell = true, -- Enable spell checking
|
||||
},
|
||||
},
|
||||
|
||||
highlights = {
|
||||
-- Fix Gruvbox highlight groups
|
||||
-- https://github.com/ellisonleao/gruvbox.nvim/blob/main/lua/gruvbox/palette.lua
|
||||
gruvbox = {
|
||||
-- Hard-code reversed colors
|
||||
-- https://github.com/AstroNvim/AstroNvim/issues/1147
|
||||
StatusLine = { fg = "#ebdbb2", bg = "#504945" }, -- colors.light1 / colors.dark2
|
||||
},
|
||||
},
|
||||
|
||||
plugins = {
|
||||
-- colorscheme - catppuccin
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
config = function()
|
||||
require("catppuccin").setup {}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"rebelot/heirline.nvim",
|
||||
opts = function(_, opts)
|
||||
local status = require("astronvim.utils.status")
|
||||
opts.statusline = vim.tbl_deep_extend("force", opts.statusline, {
|
||||
-- add mode component
|
||||
status.component.mode { mode_text = { padding = { left = 1, right = 1 } } },
|
||||
})
|
||||
return opts
|
||||
end
|
||||
},
|
||||
{
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
config = function()
|
||||
local dap = require('dap')
|
||||
local adapters = require('mason-nvim-dap.mappings.adapters')
|
||||
local configurations = require('mason-nvim-dap.mappings.configurations')
|
||||
|
||||
dap.adapters.delve = adapters.delve
|
||||
dap.configurations.go = configurations.delve
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
opts = {
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
hide_dotfiles = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
opts = function(_, opts)
|
||||
local null_ls = require "null-ls"
|
||||
-- Include code and source with diagnostics message
|
||||
opts.diagnostics_format = "[#{c}] #{m} (#{s})"
|
||||
opts.sources = {
|
||||
null_ls.builtins.diagnostics.golangci_lint,
|
||||
null_ls.builtins.diagnostics.hadolint,
|
||||
null_ls.builtins.diagnostics.ruff,
|
||||
null_ls.builtins.formatting.black,
|
||||
null_ls.builtins.formatting.gofumpt.with({
|
||||
extra_args = { "-extra" },
|
||||
}),
|
||||
null_ls.builtins.formatting.goimports,
|
||||
null_ls.builtins.formatting.prettier,
|
||||
null_ls.builtins.formatting.ruff,
|
||||
null_ls.builtins.formatting.shfmt.with({
|
||||
extra_args = { "-i", "2", "-ci", "-bn"},
|
||||
}),
|
||||
}
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"go",
|
||||
"gomod",
|
||||
"hcl",
|
||||
"jsonnet",
|
||||
"nix",
|
||||
"python",
|
||||
"regex",
|
||||
"rust",
|
||||
"terraform",
|
||||
"typescript",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
lsp = {
|
||||
servers = {
|
||||
"bashls",
|
||||
"clangd", -- c/c++ language server
|
||||
"cmake",
|
||||
"cssls",
|
||||
"eslint",
|
||||
"gopls",
|
||||
"html",
|
||||
"jsonls",
|
||||
"jsonnet_ls",
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"nil_ls", -- nix language server
|
||||
"rust_analyzer",
|
||||
"sqlls", -- sql language server
|
||||
"terraformls",
|
||||
"tsserver",
|
||||
"yamlls",
|
||||
},
|
||||
formatting = {
|
||||
disabled = {
|
||||
-- use null-ls' gofumpt/goimports instead
|
||||
-- https://github.com/golang/tools/pull/410
|
||||
"gopls",
|
||||
-- use null-ls' prettier instead
|
||||
"tsserver",
|
||||
},
|
||||
format_on_save = {
|
||||
enabled = true,
|
||||
allow_filetypes = {
|
||||
"go",
|
||||
"jsonnet",
|
||||
"rust",
|
||||
"terraform",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
#!/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,18 +1,25 @@
|
||||
{ config, lib, inputs, pkgs, ... }:
|
||||
{ pkgs, astronvim, ... }:
|
||||
|
||||
# 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`
|
||||
# related folders:
|
||||
# nvim's config: `~/.config/nvim`
|
||||
# astronvim's user configuration: `$XDG_CONFIG_HOME/astronvim/lua/user`
|
||||
# all plugins will be installed into(by lazy.nvim): `~/.local/share/nvim/`
|
||||
# for details: https://astronvim.com/
|
||||
{
|
||||
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;
|
||||
xdg.configFile = {
|
||||
# base config
|
||||
"nvim" = {
|
||||
# update AstroNvim
|
||||
onChange = "${pkgs.neovim}/bin/nvim --headless +quitall";
|
||||
source = astronvim;
|
||||
};
|
||||
# my cusotom astronvim config, astronvim will load it after base config
|
||||
# https://github.com/AstroNvim/AstroNvim/blob/v3.32.0/lua/astronvim/bootstrap.lua#L15-L16
|
||||
"astronvim/lua/user/init.lua" = {
|
||||
# update AstroNvim
|
||||
onChange = "${pkgs.neovim}/bin/nvim --headless +quitall";
|
||||
source = ./astronvim_user_init.lua;
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.config = {
|
||||
@@ -33,12 +40,9 @@
|
||||
withNodeJs = true;
|
||||
extraPackages = [];
|
||||
|
||||
#-- Plugins --#
|
||||
# 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
|
||||
# ];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
require('core')
|
||||
@@ -1,193 +0,0 @@
|
||||
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
|
||||
@@ -1,97 +0,0 @@
|
||||
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
|
||||
@@ -1,51 +0,0 @@
|
||||
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')
|
||||
@@ -1,115 +0,0 @@
|
||||
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
|
||||
@@ -1,91 +0,0 @@
|
||||
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
|
||||
@@ -1,62 +0,0 @@
|
||||
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
|
||||
@@ -1,58 +0,0 @@
|
||||
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) },
|
||||
})
|
||||
@@ -1,247 +0,0 @@
|
||||
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,
|
||||
})
|
||||
|
||||
--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
|
||||
@@ -1,105 +0,0 @@
|
||||
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,
|
||||
})
|
||||
@@ -1,26 +0,0 @@
|
||||
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
|
||||
@@ -1,12 +0,0 @@
|
||||
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',
|
||||
},
|
||||
})
|
||||
@@ -1,25 +0,0 @@
|
||||
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
|
||||
@@ -1,27 +0,0 @@
|
||||
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',
|
||||
})
|
||||
@@ -1,61 +0,0 @@
|
||||
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 = ' Find Files',
|
||||
group = 'Label',
|
||||
action = 'Telescope find_files',
|
||||
key = 'f',
|
||||
},
|
||||
{
|
||||
desc = ' File Tree',
|
||||
group = 'DiagnosticHint',
|
||||
action = 'Neotree',
|
||||
key = 't',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
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
|
||||
@@ -1,375 +0,0 @@
|
||||
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,
|
||||
})
|
||||
|
||||
|
||||
-- file tree sidebar
|
||||
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 " },
|
||||
},
|
||||
},
|
||||
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
visible = true, -- when true, they will just be displayed differently than normal items
|
||||
hide_dotfiles = false,
|
||||
hide_gitignored = false,
|
||||
},
|
||||
},
|
||||
-- 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
|
||||
})
|
||||
@@ -1,116 +0,0 @@
|
||||
{
|
||||
"_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"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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),
|
||||
})
|
||||
),
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": "lua",
|
||||
"path": "./lua.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
[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██ █████████████████
|
||||
██████ ██ ███████████████ ██ █████████████████
|
||||
2
home/linux/i3/bin/bright
Normal file
2
home/linux/i3/bin/bright
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
xrandr --output DP-2 --brightness $@
|
||||
@@ -6,31 +6,38 @@
|
||||
./x11-apps.nix
|
||||
];
|
||||
|
||||
# wallpaper, binary file
|
||||
home.file.".config/i3/wallpaper.png".source = ../wallpapers/wallpaper.png;
|
||||
home.file.".config/i3/config".source = ./config;
|
||||
home.file.".config/i3/i3blocks.conf".source = ./i3blocks.conf;
|
||||
home.file.".config/i3/keybindings".source = ./keybindings;
|
||||
home.file.".config/i3/scripts" = {
|
||||
source = ./scripts;
|
||||
# copy the scripts directory recursively
|
||||
recursive = true;
|
||||
executable = true; # make all scripts executable
|
||||
};
|
||||
home.file.".config/i3/layouts" = {
|
||||
source = ./layouts;
|
||||
recursive = true;
|
||||
};
|
||||
home.file = {
|
||||
# wallpaper, binary file
|
||||
".config/i3/wallpaper.png".source = ../wallpapers/wallpaper.png;
|
||||
".config/i3/config".source = ./config;
|
||||
".config/i3/i3blocks.conf".source = ./i3blocks.conf;
|
||||
".config/i3/keybindings".source = ./keybindings;
|
||||
".config/i3/scripts" = {
|
||||
source = ./scripts;
|
||||
# copy the scripts directory recursively
|
||||
recursive = true;
|
||||
executable = true; # make all scripts executable
|
||||
};
|
||||
".config/i3/layouts" = {
|
||||
source = ./layouts;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
# rofi is a application launcher and dmenu replacement
|
||||
home.file.".config/rofi" = {
|
||||
source = ./rofi-conf;
|
||||
# copy the scripts directory recursively
|
||||
recursive = true;
|
||||
};
|
||||
# rofi is a application launcher and dmenu replacement
|
||||
".config/rofi" = {
|
||||
source = ./rofi-conf;
|
||||
# copy the scripts directory recursively
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
# xrandr - set primary screen
|
||||
home.file.".screenlayout/monitor.sh".source = ./dual-monitor-4k-1080p.sh;
|
||||
".local/bin/bright" = {
|
||||
source = ./bin/bright;
|
||||
executable = true;
|
||||
};
|
||||
|
||||
# xrandr - set primary screen
|
||||
".screenlayout/monitor.sh".source = ./dual-monitor-4k-1080p.sh;
|
||||
};
|
||||
|
||||
# allow fontconfig to discover fonts and configurations installed through home.packages
|
||||
fonts.fontconfig.enable = true;
|
||||
|
||||
Reference in New Issue
Block a user