This commit is contained in:
megit 2024-03-28 02:03:42 +08:00
commit f22207f3e2
16 changed files with 988 additions and 0 deletions

View file

@ -0,0 +1,5 @@
{
colorschemes.gruvbox ={
enable = true;
};
}

View file

@ -0,0 +1,59 @@
{
colorschemes.onedark = {
enable = true;
};
extraConfigLua = ''
----------------------------------
-- START custom setup for onedark
----------------------------------
-- https://github.com/navarasu/onedark.nvim
require('onedark').setup {
-- Main options --
style = 'darker', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
transparent = true, -- Show/hide background
term_colors = true, -- Change terminal color as per the selected theme style
ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
-- toggle theme style ---
-- toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
toggle_style_key = "<leader>ts", -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
-- toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between
toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer'}, -- List of styles to toggle between
-- Change code style ---
-- Options are italic, bold, underline, none
-- You can configure multiple style with comma seperated, For e.g., keywords = 'italic,bold'
code_style = {
comments = 'italic',
keywords = 'none',
functions = 'none',
strings = 'none',
variables = 'none'
},
-- Lualine options --
-- lualine = {
-- transparent = true, -- lualine center bar transparency
-- },
-- Custom Highlights --
colors = {}, -- Override default colors
highlights = {}, -- Override highlight groups
-- Plugins Config --
diagnostics = {
darker = true, -- darker colors for diagnostic
undercurl = true, -- use undercurl instead of underline for diagnostics
background = true, -- use background color for virtual text
},
}
require('onedark').load()
----------------------------------
-- END custom setup for onedark
----------------------------------
'';
}

24
config/default.nix Normal file
View file

@ -0,0 +1,24 @@
# The line beneath this is called `modeline`. See `:help modeline`
# vim: ts=4:sts=0:sw=0:tw=78:noet
{pkgs
, ...}:{
# Import all your configuration modules here
imports = [
./colorscheme/onedark.nix
# ./colorscheme/gruvbox.nix
./sets.nix
./keymaps.nix
./plugins/bufferline.nix
./plugins/comment.nix
./plugins/indent-blankline.nix
./plugins/leap.nix
./plugins/lsp/lsp.nix
# ./plugins/lsp/conform.nix
./plugins/lualine.nix
./plugins/nvim-tree.nix
./plugins/telescope.nix
# ./plugins/none-ls/none-ls.nix
];
}

21
config/keymaps.nix Normal file
View file

@ -0,0 +1,21 @@
# The line beneath this is called `modeline`. See `:help modeline`
# vim: ts=4:sts=0:sw=0:tw=78:noet
{
keymaps = [
{
# vim.keymap.set({ "n", "v" }, "\\y", '"+y', {noremap=true, silent=true})
mode = [ "n" "v" ];
key = "\\y";
action = "\"+y";
options = {
silent = true;
remap = false;
};
}
];
extraConfigLua = ''
-- see ":help default-mapping"
-- vim.cmd[[unmap Y]]
vim.keymap.del( "n", "Y" )
'';
}

View file

@ -0,0 +1,7 @@
{
plugins = {
bufferline = {
enable = true;
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
comment = {
enable = true;
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
indent-blankline = {
enable = true;
};
};
}

27
config/plugins/leap.nix Normal file
View file

@ -0,0 +1,27 @@
{
plugins.leap = {
enable = true;
};
keymaps = [
{
mode = [ "n" "x" "o" ];
key = "<leader>ss";
action = "function() require('leap').leap { } end";
}
{
mode = [ "n" "x" "o" ];
key = "<leader>sS";
action = "<Plug>(leap-backward-to)";
}
{
mode = [ "n" "x" "o" ];
key = "<leader>sx";
action = "<Plug>(leap-forward-till)";
}
{
mode = [ "n" "x" "o" ];
key = "<leader>sX";
action = "<Plug>(leap-backward-till)";
}
];
}

View file

@ -0,0 +1,16 @@
{
lsp = {
enable = true;
servers = {
tsserver.enable = true;
lua-ls.enable = true;
rust-analyzer = {
enable = true;
installCargo = true;
installRustc = true;
};
};
};
}

168
config/plugins/lsp/lsp.nix Normal file
View file

@ -0,0 +1,168 @@
{
plugins = {
lsp-format = {
enable = false; # Enable it if you want lsp-format integration for none-ls
};
lsp = {
enable = true;
capabilities = "offsetEncoding = 'utf-16'";
servers = {
clangd = {enable = true;};
lua-ls = {
enable = true;
extraOptions = {
settings = {
Lua = {
completion = {
callSnippet = "Replace";
};
telemetry = {
enabled = false;
};
hint = {enable = true;};
};
};
};
};
nil_ls = {enable = true;};
tsserver = {
enable = false;
filetypes = ["javascript" "javascriptreact" "typescript" "typescriptreact"];
extraOptions = {
settings = {
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
};
typescript = {
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
};
};
};
};
eslint = {enable = true;};
pyright = {enable = true;};
ruff-lsp = {enable = true;};
texlab = {enable = true;};
rust-analyzer = {
enable = true;
installCargo = true;
installRustc = true;
settings = {
checkOnSave = true;
check = {
command = "clippy";
};
# inlayHints = {
# enable = true;
# showParameterNames = true;
# parameterHintsPrefix = "<- ";
# otherHintsPrefix = "=> ";
# };
procMacro = {
enable = true;
};
};
};
};
# keymaps = {
# silent = true;
# lspBuf = {
# gd = {
# action = "definition";
# desc = "Goto Definition";
# };
# gr = {
# action = "references";
# desc = "Goto References";
# };
# gD = {
# action = "declaration";
# desc = "Goto Declaration";
# };
# gI = {
# action = "implementation";
# desc = "Goto Implementation";
# };
# gT = {
# action = "type_definition";
# desc = "Type Definition";
# };
# K = {
# action = "hover";
# desc = "Hover";
# };
# "<leader>cw" = {
# action = "workspace_symbol";
# desc = "Workspace Symbol";
# };
# "<leader>cr" = {
# action = "rename";
# desc = "Rename";
# };
# "<leader>ca" = {
# action = "code_action";
# desc = "Code Action";
# };
# "<C-k>" = {
# action = "signature_help";
# desc = "Signature Help";
# };
# };
# diagnostic = {
# "<leader>cd" = {
# action = "open_float";
# desc = "Line Diagnostics";
# };
# "[d" = {
# action = "goto_next";
# desc = "Next Diagnostic";
# };
# "]d" = {
# action = "goto_prev";
# desc = "Previous Diagnostic";
# };
# };
# };
};
};
extraConfigLua = ''
local _border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, {
border = _border
}
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help, {
border = _border
}
)
vim.diagnostic.config{
float={border=_border}
};
require('lspconfig.ui.windows').default_options = {
border = _border
}
'';
}

View file

@ -0,0 +1,7 @@
{
plugins = {
lualine = {
enable = true;
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
nvim-tree = {
enable = true;
};
};
}

View file

@ -0,0 +1,190 @@
{
plugins.telescope = {
enable = true;
extensions = {
fzf-native = {
enable = true;
};
# project-nvim = {
# enable = true;
# };
# ui-select = {
# settings = {
# specific_opts = {
# codeactions = true;
# };
# };
# };
undo = {
enable = true;
mappings = {
i = {
"<cr>" = "yank_additions";
"<s-cr>" = "yank_deletions";
"<c-cr>" = "restore";
};
n = {
"y" = "yank_additions";
"Y" = "yank_deletions";
"u" = "restore";
};
};
};
};
# If you'd prefer Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map <Esc> to do so via:
defaults = {
mappings = {
i = {
"<esc>" = {
__raw = ''
function(...)
return require("telescope.actions").close(...)
end'';
};
};
};
};
keymaps = {
"<leader><space>" = {
action = "find_files, {}";
desc = "Find project files";
};
"<leader>/" = {
action = "live_grep";
desc = "Grep (root dir)";
};
"<leader>:" = {
action = "command_history, {}";
desc = "Command History";
};
"<leader>b" = {
action = "buffers, {}";
desc = "+buffer";
};
"<leader>ff" = {
action = "find_files, {}";
desc = "Find project files";
};
"<leader>fr" = {
action = "oldfiles, {}";
desc = "Recent";
};
"<leader>fb" = {
action = "buffers, {}";
desc = "Buffers";
};
"<C-p>" = {
action = "git_files, {}";
desc = "Search git files";
};
"<leader>gc" = {
action = "git_commits, {}";
desc = "Commits";
};
"<leader>gs" = {
action = "git_status, {}";
desc = "Status";
};
"<leader>sa" = {
action = "autocommands, {}";
desc = "Auto Commands";
};
"<leader>sb" = {
action = "current_buffer_fuzzy_find, {}";
desc = "Buffer";
};
"<leader>sc" = {
action = "command_history, {}";
desc = "Command History";
};
"<leader>sC" = {
action = "commands, {}";
desc = "Commands";
};
"<leader>sD" = {
action = "diagnostics, {}";
desc = "Workspace diagnostics";
};
"<leader>sh" = {
action = "help_tags, {}";
desc = "Help pages";
};
"<leader>sH" = {
action = "highlights, {}";
desc = "Search Highlight Groups";
};
"<leader>sk" = {
action = "keymaps, {}";
desc = "Keymaps";
};
"<leader>sM" = {
action = "man_pages, {}";
desc = "Man pages";
};
"<leader>sm" = {
action = "marks, {}";
desc = "Jump to Mark";
};
"<leader>so" = {
action = "vim_options, {}";
desc = "Options";
};
"<leader>sR" = {
action = "resume, {}";
desc = "Resume";
};
"<leader>uC" = {
action = "colorscheme, {}";
desc = "Colorscheme preview";
};
};
};
keymaps = [
{
mode = "n";
key = "<leader>fp";
action = "<cmd>Telescope projects<CR>";
options = {
desc = "Projects";
};
}
{
mode = "n";
key = "<leader>sd";
action = "<cmd>Telescope diagnostics bufnr=0<cr>";
options = {
desc = "Document diagnostics";
};
}
{
mode = "n";
key = "<leader>st";
action = "<cmd>TodoTelescope<cr>";
options = {
silent = true;
desc = "Todo (Telescope)";
};
}
# {
# mode = "n";
# key = "<leader>,";
# action = "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>";
# options = {
# desc = "Switch Buffer";
# };
# }
];
extraConfigLua = ''
local telescope = require('telescope')
telescope.setup{
pickers = {
colorscheme = {
enable_preview = true
}
}
}
'';
}

66
config/sets.nix Normal file
View file

@ -0,0 +1,66 @@
# The line beneath this is called `modeline`. See `:help modeline`
# vim: ts=4:sts=0:sw=0:tw=78:noet
{
options = {
relativenumber = true;
splitbelow = true;
redrawtime = 5000;
# new split to the right
splitright = true;
# show hidden characters
list = true;
# don't break words on the edge
linebreak = true;
wrap = true;
# length of an actual \t character:
# https://stackoverflow.com/questions/191201/indenting-comments-to-match-code-in-vim
smartindent = false;
# length to use when shifting text (eg. <<, >> and == commands)
tabstop=4;
shiftwidth = 0;
expandtab = false;
autoindent = true;
# Set highlight on search
hlsearch = false;
# Make line numbers default
number = true;
# Enable mouse mode
mouse = "a";
# Sync clipboard between OS and Neovim.
# Remove this option if you want your OS clipboard to remain independent.
# See `:help 'clipboard'`
# vim.o.clipboard = 'unnamedplus' -- REMOVED BY ME
# Enable break indent
breakindent = true;
# Save undo history
# vim.o.undofile = true -- REMOVED BY ME
# Case insensitive searching UNLESS /C or capital in search
ignorecase = true;
smartcase = true;
# Keep signcolumn on by default
signcolumn = "yes";
# Decrease update time
updatetime = 250;
timeout = true;
timeoutlen = 300;
# Set completeopt to have a better completion experience
completeopt = "menuone,noselect";
# NOTE: You should make sure your terminal supports this
termguicolors = true;
};
}

331
flake.lock generated Normal file
View file

@ -0,0 +1,331 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1711099426,
"narHash": "sha256-HzpgM/wc3aqpnHJJ2oDqPBkNsqWbW0WfWUO8lKu8nGk=",
"owner": "numtide",
"repo": "devshell",
"rev": "2d45b54ca4a183f2fdcf4b19c895b64fbf620ee8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709336216,
"narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"nixvim",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1711133180,
"narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1710717205,
"narHash": "sha256-Wf3gHh5uV6W1TV/A8X8QJf99a5ypDSugY4sNtdJDe0A=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "bcc8afd06e237df060c85bad6af7128e05fd61a3",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1711401922,
"narHash": "sha256-QoQqXoj8ClGo0sqD/qWKFWezgEwUL0SUh37/vY2jNhc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "07262b18b97000d16a4bdb003418bd2fb067a932",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1711333969,
"narHash": "sha256-5PiWGn10DQjMZee5NXzeA6ccsv60iLu+Xtw+mfvkUAs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "57e6b3a9e4ebec5aa121188301f04a6b8c354c9b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs_2",
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1711545203,
"narHash": "sha256-PPXcH/pIbxr8awgC+q+rrIgRRH8uYeWoK5Af3kFhjEc=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "d248bf587cdb86b661ca54f16fe2f3263018b985",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"gitignore": "gitignore",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1711409088,
"narHash": "sha256-+rTCra8TY4vuSNTtQ0tcex1syCRPoKyb8vyHmoxkga4=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "db656fc3e34907000df26e8bc5cc3c94fb27f353",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"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"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

46
flake.nix Normal file
View file

@ -0,0 +1,46 @@
{
description = "Menixvim flake";
inputs = {
nixvim.url = "github:nix-community/nixvim";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
nixvim,
flake-utils,
...
} @ inputs: let
config = import ./config; # import the module directly
in
flake-utils.lib.eachDefaultSystem (system: let
nixvimLib = nixvim.lib.${system};
pkgs = import nixpkgs {inherit system;};
nixvim' = nixvim.legacyPackages.${system};
nvim = nixvim'.makeNixvimWithModule {
inherit pkgs;
module = config;
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
inherit self;
};
};
in {
checks = {
# Run `nix flake check .` to verify that your config is not broken
default = nixvimLib.check.mkTestDerivationFromNvim {
inherit nvim;
name = "Menixvim";
};
};
packages = {
# Lets you run `nix run .` to start nixvim
default = nvim;
};
# formatter = pkgs.alejandra;
});
}