Compare commits

...

2 Commits

23 changed files with 4 additions and 1012 deletions

View File

@ -1,202 +1,3 @@
-------------------------------------------------------------------------------
--
-- Basic Settings
--
vim.cmd("filetype off")
-- Leaders
vim.g.mapleader = ","
vim.g.maplocalleader = "-"
-- Better Unix support
vim.opt.viewoptions = { "folds", "options", "cursor", "unix", "slash" }
vim.opt.encoding = "utf-8"
-- True color support
vim.opt.termguicolors = true
-- Other options
vim.cmd("syntax on")
vim.opt.backspace = { "indent", "eol", "start" }
vim.opt.laststatus = 2
vim.opt.showmode = false
-- Tabs as spaces
vim.opt.expandtab = true
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
-- Fixes broken cursor on Linux
vim.opt.guicursor = ""
-- Disable mouse / touchpad
vim.opt.mouse = ""
-- Incremental substitutin
vim.opt.inccommand = "split"
-------------------------------------------------------------------------------
--
-- General editor options
--
-- Hide files when leaving them.
vim.opt.hidden = true
-- Show line numbers.
vim.opt.number = true
-- Minimum line number column width.
vim.opt.numberwidth = 1
-- Number of screen lines to use for the commandline.
vim.opt.cmdheight = 2
-- Lines length limit (0 if no limit).
vim.opt.textwidth = 0
-- Don't cut lines in the middle of a work.
vim.opt.linebreak = true
-- Show matching parenthesis.
vim.opt.showmatch = true
-- Time during which the matching parenthesis is shown.
vim.opt.matchtime = 2
-- Sensible default line auto cutting and formatting.
vim.opt.formatoptions = "jtcrq"
-- Copy/Past to/from clipboard.
vim.opt.clipboard = "unnamedplus"
-- Highlight line cursor is currently on.
vim.opt.cursorline = true
-- Invisible characters representation when :set list
vim.opt.listchars = {
tab = "",
trail = "~",
nbsp = "",
eol = "¬",
}
-- Search
-- Incremental search.
vim.opt.incsearch = true
-- Case insensitive.
vim.opt.ignorecase = true
-- Case insensitive if no uppercase letter in pattern, case sensitive otherwise.
vim.opt.smartcase = true
-- Spell
vim.opt.spelllang = "en,ru"
-- Fold level
vim.opt.foldlevel = 99
vim.opt.foldlevelstart = 99
vim.opt.foldminlines = 3
vim.opt.foldnestmax = 5
-------------------------------------------------------------------------------
--
-- File type specified
--
local bufReadFile = { "BufNewFile", "BufRead" }
-- Set up a line limiter for each lang
local line_limiter_augroup = vim.api.nvim_create_augroup("line_limiter", {})
local function set_line_limiter(limit, patterns)
vim.api.nvim_create_autocmd(bufReadFile, {
pattern = patterns,
group = line_limiter_augroup,
callback = function()
vim.wo.colorcolumn = tostring(limit)
end,
})
end
set_line_limiter(101, {
"*.nix",
"*.vim",
"*.lua",
"*.ts",
"*.tsx",
"*.js",
"*.jsx",
"*.rs",
})
set_line_limiter(81, {
"*.json",
"*.yml",
"*.yaml",
"*.md",
"*.html",
"*.css",
})
-- Spell check for markdown files
local spell_check_augroup = vim.api.nvim_create_augroup("spell_check", {})
vim.api.nvim_create_autocmd(bufReadFile, {
pattern = { "*.md" },
group = spell_check_augroup,
callback = function()
vim.wo.spell = true
end,
})
-- Set up fold method for each lang
local folding_augroup = vim.api.nvim_create_augroup("folding", {})
vim.api.nvim_create_autocmd(bufReadFile, {
group = folding_augroup,
pattern = {
"*.js",
"*.jsx",
"*.ts",
"*.tsx",
},
callback = function()
vim.cmd("syntax on")
vim.wo.foldmethod = "syntax"
end,
})
-------------------------------------------------------------------------------
--
-- Bindings
--
local function clear_search_hl()
vim.opt.hlsearch = false
end
vim.keymap.set("n", "<C-z>", clear_search_hl, { desc = "Clear search highlighting" })
-- Enable fast navigation between windows
vim.keymap.set("n", "<C-h>", "<C-W>h")
vim.keymap.set("n", "<C-l>", "<C-W>l")
vim.keymap.set("n", "<C-j>", "<C-W>j")
vim.keymap.set("n", "<C-k>", "<C-W>k")
-- Disable the annoying and useless ex-mode
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "gQ", "<nop>")
-- Disable arrow keys
vim.keymap.set("n", "<Up>", "<nop>")
vim.keymap.set("n", "<Down>", "<nop>")
vim.keymap.set("n", "<Left>", "<nop>")
vim.keymap.set("n", "<Right>", "<nop>")
vim.keymap.set("v", "<Up>", "<nop>")
vim.keymap.set("v", "<Down>", "<nop>")
vim.keymap.set("v", "<Left>", "<nop>")
vim.keymap.set("v", "<Right>", "<nop>")
-- ... instead of insert mode for rus lang and popups
-- vim.keymap.set("i", "<Up>", "<nop>")
-- vim.keymap.set("i", "<Down>", "<nop>")
-- vim.keymap.set("i", "<Left>", "<nop>")
-- vim.keymap.set("i", "<Right>", "<nop>")
-- Disable page up / down
vim.keymap.set("n", "<PageUp>", "<nop>")
vim.keymap.set("n", "<PageDown>", "<nop>")
vim.keymap.set("v", "<PageUp>", "<nop>")
vim.keymap.set("v", "<PageDown>", "<nop>")
vim.keymap.set("i", "<PageUp>", "<nop>")
vim.keymap.set("i", "<PageDown>", "<nop>")
-------------------------------------------------------------------------------
--
-- Abbreviatures
--
vim.cmd("cabbrev bsp belowright split")
vim.cmd("cabbrev rvsp belowright vsplit")

View File

@ -20,19 +20,7 @@ let
callPlugins = list: builtins.map callPlugin list;
plugins = callPlugins [
./plugins/config
(import ./plugins/syntax {
inherit tree-sitter;
})
./plugins/git
./plugins/explorer
(import ./plugins/theme {
inherit enableDevIcons enableTabby;
inherit theme;
})
./plugins/lsp
./plugins/formatter
./plugins/ux
];
basePlugins = [ vimPlugins.plenary-nvim ];

1
example.nix Normal file
View File

@ -0,0 +1 @@
let is-hello-world = true; in { }

View File

@ -1,73 +1,5 @@
{
"nodes": {
"cmp-luasnip": {
"flake": false,
"locked": {
"lastModified": 1651433493,
"narHash": "sha256-8ocJY5qeAJXFSuTnavXX6NvZyAB0EEn2Y+amrWp8B1Y=",
"owner": "saadparwaiz1",
"repo": "cmp_luasnip",
"rev": "a9de941bcbda508d0a45d28ae366bb3f08db2e36",
"type": "github"
},
"original": {
"owner": "saadparwaiz1",
"repo": "cmp_luasnip",
"rev": "a9de941bcbda508d0a45d28ae366bb3f08db2e36",
"type": "github"
}
},
"cmp-nvim-lsp": {
"flake": false,
"locked": {
"lastModified": 1652705110,
"narHash": "sha256-19Ka4EQhqo//IMjJ/DnXiHsevVWFy2M90oSjmBFfCO0=",
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"rev": "affe808a5c56b71630f17aa7c38e15c59fd648a8",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "cmp-nvim-lsp",
"rev": "affe808a5c56b71630f17aa7c38e15c59fd648a8",
"type": "github"
}
},
"editorconfig-nvim": {
"flake": false,
"locked": {
"lastModified": 1663509832,
"narHash": "sha256-+eLoPckZdsXqsyBGeM726P9WtR/pu0q7IEhKufulOxM=",
"owner": "gpanders",
"repo": "editorconfig.nvim",
"rev": "7d10fe6bc340fd783c0b61cf627dd235100284db",
"type": "github"
},
"original": {
"owner": "gpanders",
"repo": "editorconfig.nvim",
"rev": "7d10fe6bc340fd783c0b61cf627dd235100284db",
"type": "github"
}
},
"gitsigns-nvim": {
"flake": false,
"locked": {
"lastModified": 1663543397,
"narHash": "sha256-FgNSwvW7Bk+eKutMj0zqEorJ3+ijCALtOXs2OYiSX1I=",
"owner": "lewis6991",
"repo": "gitsigns.nvim",
"rev": "f98c85e7c3d65a51f45863a34feb4849c82f240f",
"type": "github"
},
"original": {
"owner": "lewis6991",
"repo": "gitsigns.nvim",
"rev": "f98c85e7c3d65a51f45863a34feb4849c82f240f",
"type": "github"
}
},
"lspsaga-nvim": {
"flake": false,
"locked": {
@ -85,74 +17,6 @@
"type": "github"
}
},
"lualine-lsp-progress": {
"flake": false,
"locked": {
"lastModified": 1634947677,
"narHash": "sha256-8HMtydFDzTxsuKvce+bIra9vZ9zHfEBHyR346W635b8=",
"owner": "arkav",
"repo": "lualine-lsp-progress",
"rev": "56842d097245a08d77912edf5f2a69ba29f275d7",
"type": "github"
},
"original": {
"owner": "arkav",
"repo": "lualine-lsp-progress",
"rev": "56842d097245a08d77912edf5f2a69ba29f275d7",
"type": "github"
}
},
"lualine-nvim": {
"flake": false,
"locked": {
"lastModified": 1662921346,
"narHash": "sha256-bGVozEoffFxjiLACTfnDGX11yIHGhLawQWn80Nbd6TM=",
"owner": "nvim-lualine",
"repo": "lualine.nvim",
"rev": "a52f078026b27694d2290e34efa61a6e4a690621",
"type": "github"
},
"original": {
"owner": "nvim-lualine",
"repo": "lualine.nvim",
"rev": "a52f078026b27694d2290e34efa61a6e4a690621",
"type": "github"
}
},
"luaship": {
"flake": false,
"locked": {
"lastModified": 1663664003,
"narHash": "sha256-56x4Eke/7Cdn4/8T0SM73WpDqBSFq1vFY5VdkNlUBwI=",
"owner": "L3MON4D3",
"repo": "LuaSnip",
"rev": "d36c063b7f6e701852f7880f1314656592a61b4f",
"type": "github"
},
"original": {
"owner": "L3MON4D3",
"repo": "LuaSnip",
"rev": "d36c063b7f6e701852f7880f1314656592a61b4f",
"type": "github"
}
},
"neoformat": {
"flake": false,
"locked": {
"lastModified": 1661997045,
"narHash": "sha256-x+TDVvH0DgmCCjOjhbE2/YaxnjCd4fcPxuQD6bhwVNs=",
"owner": "sbdchd",
"repo": "neoformat",
"rev": "0ae951121da29a157d80db70c32679b428afffdc",
"type": "github"
},
"original": {
"owner": "sbdchd",
"repo": "neoformat",
"rev": "0ae951121da29a157d80db70c32679b428afffdc",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1663146586,
@ -169,23 +33,6 @@
"type": "github"
}
},
"nvim-cmp": {
"flake": false,
"locked": {
"lastModified": 1663990701,
"narHash": "sha256-gpkPMlOUMfTlef5WRFHLkmKEDZ9TRA/yRPqb6UXnKOA=",
"owner": "hrsh7th",
"repo": "nvim-cmp",
"rev": "17a55b3d5498c617855d015bbcad0c872d10c879",
"type": "github"
},
"original": {
"owner": "hrsh7th",
"repo": "nvim-cmp",
"rev": "17a55b3d5498c617855d015bbcad0c872d10c879",
"type": "github"
}
},
"nvim-lspconfig": {
"flake": false,
"locked": {
@ -203,57 +50,6 @@
"type": "github"
}
},
"nvim-tree-lua": {
"flake": false,
"locked": {
"lastModified": 1663823703,
"narHash": "sha256-QY60TDUVmKcFzCAojReZEAbQcyEYgCG4nhgsx74OtVM=",
"owner": "kyazdani42",
"repo": "nvim-tree.lua",
"rev": "0417d9148b6546bf4883b6e9750f992f980afbfe",
"type": "github"
},
"original": {
"owner": "kyazdani42",
"repo": "nvim-tree.lua",
"rev": "0417d9148b6546bf4883b6e9750f992f980afbfe",
"type": "github"
}
},
"nvim-treesitter": {
"flake": false,
"locked": {
"lastModified": 1664008557,
"narHash": "sha256-hZqZkXrIw9OfXLqioSqagmEPoIz8gcT+WpEhVURdeHw=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "a60aa7b2e1dd9219c6356f65ba48bdbd50090abd",
"type": "github"
},
"original": {
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "a60aa7b2e1dd9219c6356f65ba48bdbd50090abd",
"type": "github"
}
},
"nvim-web-devicons": {
"flake": false,
"locked": {
"lastModified": 1663532214,
"narHash": "sha256-e8FP68mEmPAEbk+rYEKKGi0ZTJHDCPxrulnivkzInXk=",
"owner": "kyazdani42",
"repo": "nvim-web-devicons",
"rev": "969728506c0175644a1d448f55e311ccdada7eaf",
"type": "github"
},
"original": {
"owner": "kyazdani42",
"repo": "nvim-web-devicons",
"rev": "969728506c0175644a1d448f55e311ccdada7eaf",
"type": "github"
}
},
"plenary-nvim": {
"flake": false,
"locked": {
@ -272,97 +68,13 @@
},
"root": {
"inputs": {
"cmp-luasnip": "cmp-luasnip",
"cmp-nvim-lsp": "cmp-nvim-lsp",
"editorconfig-nvim": "editorconfig-nvim",
"gitsigns-nvim": "gitsigns-nvim",
"lspsaga-nvim": "lspsaga-nvim",
"lualine-lsp-progress": "lualine-lsp-progress",
"lualine-nvim": "lualine-nvim",
"luaship": "luaship",
"neoformat": "neoformat",
"nixpkgs": "nixpkgs",
"nvim-cmp": "nvim-cmp",
"nvim-lspconfig": "nvim-lspconfig",
"nvim-tree-lua": "nvim-tree-lua",
"nvim-treesitter": "nvim-treesitter",
"nvim-web-devicons": "nvim-web-devicons",
"plenary-nvim": "plenary-nvim",
"tabby-nvim": "tabby-nvim",
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",
"telescope-nvim": "telescope-nvim",
"theme": "theme",
"utils": "utils"
}
},
"tabby-nvim": {
"flake": false,
"locked": {
"lastModified": 1663040953,
"narHash": "sha256-QmqRKFuukm4Vn531TEoejxX3yx0ofzymExOp9c9ybDg=",
"owner": "nanozuki",
"repo": "tabby.nvim",
"rev": "916c9e56d043906a441cd9f905e2ca1f5c4dddb0",
"type": "github"
},
"original": {
"owner": "nanozuki",
"repo": "tabby.nvim",
"rev": "916c9e56d043906a441cd9f905e2ca1f5c4dddb0",
"type": "github"
}
},
"telescope-live-grep-args-nvim": {
"flake": false,
"locked": {
"lastModified": 1661594012,
"narHash": "sha256-T5j2qgoDtVkk1uCLjoNeyw4eTu6eLbTXQHUuvHs3Tls=",
"owner": "nvim-telescope",
"repo": "telescope-live-grep-args.nvim",
"rev": "32b633b062d1168a2d18ad27994e5b4ef97f0a74",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope-live-grep-args.nvim",
"rev": "32b633b062d1168a2d18ad27994e5b4ef97f0a74",
"type": "github"
}
},
"telescope-nvim": {
"flake": false,
"locked": {
"lastModified": 1663402536,
"narHash": "sha256-hIOg0rFAek9p6/k2USBAPQwIoVdSJ+Tw6A0jrup9xto=",
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "30e2dc5232d0dd63709ef8b44a5d6184005e8602",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "30e2dc5232d0dd63709ef8b44a5d6184005e8602",
"type": "github"
}
},
"theme": {
"flake": false,
"locked": {
"lastModified": 1663990749,
"narHash": "sha256-EdmZ5qXY10jkYBgtd/qe23Ccl5qwFm3bwXNQIG8Qn5A=",
"owner": "catppuccin",
"repo": "nvim",
"rev": "9ac18414f0446478024b19018d73b7ea14f6fc96",
"type": "github"
},
"original": {
"owner": "catppuccin",
"repo": "nvim",
"rev": "9ac18414f0446478024b19018d73b7ea14f6fc96",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1659877975,

130
flake.nix
View File

@ -9,50 +9,6 @@
flake = false;
};
# config
# https://github.com/gpanders/editorconfig.nvim
editorconfig-nvim = {
url = "github:gpanders/editorconfig.nvim?rev=7d10fe6bc340fd783c0b61cf627dd235100284db";
flake = false;
};
# explorer
# https://github.com/kyazdani42/nvim-tree.lua
nvim-tree-lua = {
url = "github:kyazdani42/nvim-tree.lua?rev=0417d9148b6546bf4883b6e9750f992f980afbfe";
flake = false;
};
# https://github.com/nvim-telescope/telescope.nvim
telescope-nvim = {
url = "github:nvim-telescope/telescope.nvim?rev=30e2dc5232d0dd63709ef8b44a5d6184005e8602";
flake = false;
};
# https://github.com/nvim-telescope/telescope-live-grep-args.nvim
telescope-live-grep-args-nvim = {
url = "github:nvim-telescope/telescope-live-grep-args.nvim?rev=32b633b062d1168a2d18ad27994e5b4ef97f0a74";
flake = false;
};
# formatter
# https://github.com/sbdchd/neoformat
neoformat = {
url = "github:sbdchd/neoformat?rev=0ae951121da29a157d80db70c32679b428afffdc";
flake = false;
};
# git
# https://github.com/lewis6991/gitsigns.nvim
gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim?rev=f98c85e7c3d65a51f45863a34feb4849c82f240f";
flake = false;
};
# lsp
# https://github.com/neovim/nvim-lspconfig
@ -66,101 +22,15 @@
url = "github:glepnir/lspsaga.nvim?rev=381900d932db058aa3236ba66cc9f45747c0df71";
flake = false;
};
# https://github.com/L3MON4D3/LuaSnip
luaship = {
url = "github:L3MON4D3/LuaSnip?rev=d36c063b7f6e701852f7880f1314656592a61b4f";
flake = false;
};
# https://github.com/hrsh7th/nvim-cmp
nvim-cmp = {
url = "github:hrsh7th/nvim-cmp?rev=17a55b3d5498c617855d015bbcad0c872d10c879";
flake = false;
};
# https://github.com/hrsh7th/cmp-nvim-lsp
cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp?rev=affe808a5c56b71630f17aa7c38e15c59fd648a8";
flake = false;
};
# https://github.com/saadparwaiz1/cmp_luasnip
cmp-luasnip = {
url = "github:saadparwaiz1/cmp_luasnip?rev=a9de941bcbda508d0a45d28ae366bb3f08db2e36";
flake = false;
};
# syntax
# https://github.com/nvim-treesitter/nvim-treesitter
nvim-treesitter = {
url = "github:nvim-treesitter/nvim-treesitter?rev=a60aa7b2e1dd9219c6356f65ba48bdbd50090abd";
flake = false;
};
# theme
# https://github.com/nanozuki/tabby.nvim
tabby-nvim = {
url = "github:nanozuki/tabby.nvim?rev=916c9e56d043906a441cd9f905e2ca1f5c4dddb0";
flake = false;
};
# https://github.com/nvim-lualine/lualine.nvim
lualine-nvim = {
url = "github:nvim-lualine/lualine.nvim?rev=a52f078026b27694d2290e34efa61a6e4a690621";
flake = false;
};
# https://github.com/arkav/lualine-lsp-progress
lualine-lsp-progress = {
url = "github:/arkav/lualine-lsp-progress?rev=56842d097245a08d77912edf5f2a69ba29f275d7";
flake = false;
};
# https://github.com/kyazdani42/nvim-web-devicons
nvim-web-devicons = {
url = "github:kyazdani42/nvim-web-devicons?rev=969728506c0175644a1d448f55e311ccdada7eaf";
flake = false;
};
# https://github.com/catppuccin/nvim
theme = {
url = "github:catppuccin/nvim?rev=9ac18414f0446478024b19018d73b7ea14f6fc96";
flake = false;
};
};
outputs = inputs @ { self, nixpkgs, utils, ... }:
let
inputPlugins = [
"plenary-nvim"
# config
"editorconfig-nvim"
# explorer
"nvim-tree-lua"
"telescope-nvim"
"telescope-live-grep-args-nvim"
# formatter
"neoformat"
# git
"gitsigns-nvim"
# lsp
"nvim-lspconfig"
"lspsaga-nvim"
"luaship"
"nvim-cmp"
"cmp-nvim-lsp"
"cmp-luasnip"
# syntax
"nvim-treesitter"
# theme
"tabby-nvim"
"lualine-nvim"
"lualine-lsp-progress"
"nvim-web-devicons"
"theme"
];
mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }:

View File

@ -1,5 +0,0 @@
{ editorconfig-nvim, ... }:
{
plugins = [ editorconfig-nvim ];
}

View File

@ -1,9 +0,0 @@
{ nvim-tree-lua, telescope-nvim, telescope-live-grep-args-nvim, ... }:
{
luaConfig = (builtins.readFile ./nvim-tree.lua)
+ (builtins.readFile ./telescope-nvim.lua);
plugins = [ nvim-tree-lua ]
++ [ telescope-nvim telescope-live-grep-args-nvim ];
}

View File

@ -1,11 +0,0 @@
-- See: https://github.com/kyazdani42/nvim-tree.lua/blob/master/doc/nvim-tree-lua.txt
-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded = 1
vim.g.loaded_netrwPlugin = 1
-- empty setup using defaults
require("nvim-tree").setup()
vim.keymap.set("n", "<leader>nt", "<Cmd>NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", "<Cmd>NvimTreeFindFile<CR>")

View File

@ -1,13 +0,0 @@
-- See: https://github.com/nvim-telescope/telescope.nvim
local telescope = require("telescope")
telescope.setup({})
vim.keymap.set("n", "<leader>ff", "<Cmd>Telescope find_files hidden=true<CR>")
vim.keymap.set("n", "<leader>fb", "<Cmd>Telescope buffers<CR>")
vim.keymap.set("n", "<leader>fh", "<Cmd>Telescope help_tags<CR>")
-- required telescope-live-grep-args-nvim plugin
vim.keymap.set("n", "<leader>fg", function()
telescope.extensions.live_grep_args.live_grep_args()
end)

View File

@ -1,7 +0,0 @@
{ neoformat, ... }:
{
luaConfig = builtins.readFile ./neoformat.lua;
plugins = [ neoformat ];
}

View File

@ -1,10 +0,0 @@
vim.g.neoformat_try_node_exe = 1
vim.g.neoformat_only_msg_on_error = 1
vim.g.neoformat_enabled_markdown = { "denofmt" }
vim.cmd([[
aug fmt
au!
au BufWritePre * try | undojoin | Neoformat | catch /E790/ | Neoformat | endtry
aug END
]])

View File

@ -1,7 +0,0 @@
{ gitsigns-nvim, ... }:
{
luaConfig = builtins.readFile ./gitsigns-nvim.lua;
plugins = [ gitsigns-nvim ];
}

View File

@ -1,52 +0,0 @@
function on_attach(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map("n", "]h", function()
if vim.wo.diff then
return "]h"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map("n", "[h", function()
if vim.wo.diff then
return "[h"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
-- Actions
map({ "n", "v" }, "<leader>gs", ":Gitsigns stage_hunk<CR>")
map({ "n", "v" }, "<leader>gr", ":Gitsigns reset_hunk<CR>")
map("n", "<leader>gu", gs.undo_stage_hunk)
map("n", "<leader>gp", gs.preview_hunk)
map("n", "<leader>gb", function()
gs.blame_line({ full = true })
end)
map("n", "<leader>gtb", gs.toggle_current_line_blame)
map("n", "<leader>gd", gs.diffthis)
map("n", "<leader>gD", function()
gs.diffthis("~")
end)
-- Text object
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
end
-- See: https://github.com/lewis6991/gitsigns.nvim
require("gitsigns").setup({
on_attach = on_attach,
})

View File

@ -1,26 +1,13 @@
{ nvim-lspconfig
, lspsaga-nvim
, luasnip
, nvim-cmp
, cmp-nvim-lsp
, cmp_luasnip
, ...
}:
let
lsp = [ nvim-lspconfig lspsaga-nvim ];
snippets = [ luasnip ];
completions = [
nvim-cmp # Autocompletion
cmp-nvim-lsp # LSP source for nvim-cmp
cmp_luasnip # Snippets source for nvim-cmp
];
in
{
luaConfig = (builtins.readFile ./lspconfig.lua)
+ (builtins.readFile ./nvim-cmp.lua);
luaConfig = (builtins.readFile ./lspconfig.lua);
plugins = lsp
++ snippets
++ completions;
plugins = lsp;
}

View File

@ -3,59 +3,21 @@ local saga = require("lspsaga")
-- See: https://github.com/glepnir/lspsaga.nvim#configuration
saga.init_lsp_saga({
border_style = "rounded",
code_action_lightbulb = { enable = false },
code_action_keys = { quit = "<Esc>" },
definition_action_keys = { quit = "<Esc>" },
rename_action_quit = "<Esc>",
symbol_in_winbar = { enable = false },
})
-- always show signcolumns
vim.opt.signcolumn = "yes"
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true }
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", "<Cmd>Lspsaga diagnostic_jump_prev<CR>", opts)
vim.keymap.set("n", "]d", "<Cmd>Lspsaga diagnostic_jump_next<CR>", opts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
-- Only jump to error
vim.keymap.set("n", "[e", function()
require("lspsaga.diagnostic").goto_prev({ severity = vim.diagnostic.severity.ERROR })
end, opts)
vim.keymap.set("n", "]e", function()
require("lspsaga.diagnostic").goto_next({ severity = vim.diagnostic.severity.ERROR })
end, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
-- vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "gy", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
-- vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
-- vim.keymap.set("n", "<localleader>f", vim.lsp.buf.formatting, bufopts)
vim.keymap.set("n", "<localleader>n", "<Cmd>Lspsaga rename<CR>", bufopts)
vim.keymap.set({ "n", "v" }, "<localleader>a", "<Cmd>Lspsaga code_action<CR>", bufopts)
vim.keymap.set("n", "K", "<Cmd>Lspsaga hover_doc<CR>", bufopts)
vim.keymap.set("n", "co", "<Cmd>LSoutlineToggle<CR>", bufopts)
vim.keymap.set('n', '<localleader>rn', vim.lsp.buf.rename, bufopts)
end
-- nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
-------------------------------------------------------------------------------
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
--
@ -63,27 +25,7 @@ capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
-- Override the default configuration to be applied to all servers
lsp_config.util.default_config = vim.tbl_extend("force", lsp_config.util.default_config, {
on_attach = on_attach,
capabilities = capabilities,
})
-- nix
lsp_config.nil_ls.setup({})
-- js,ts
lsp_config.tsserver.setup({})
lsp_config.eslint.setup({})
-- rust
lsp_config.rust_analyzer.setup({
-- Server-specific settings...
settings = {
["rust-analyzer"] = {
["server.path"] = "rust-analyzer",
["updates.prompt"] = false,
["updates.checkOnStartup"] = false,
["checkOnSave.enable"] = true,
["checkOnSave.command"] = "clippy",
["cargo.autoreload"] = true,
},
},
})

View File

@ -1,43 +0,0 @@
local luasnip = require("luasnip")
local cmp = require("cmp")
vim.opt.completeopt = { "menu", "menuone", "noselect" }
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
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" }),
}),
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
},
})

View File

@ -1,35 +0,0 @@
{ tree-sitter, ... }:
{ nvim-treesitter, ... }:
let
treesitterGrammars = tree-sitter.withPlugins
(grammars: with grammars; [
tree-sitter-nix
tree-sitter-lua
tree-sitter-ledger
tree-sitter-yaml
tree-sitter-json
tree-sitter-typescript
tree-sitter-javascript
tree-sitter-rust
tree-sitter-haskell
tree-sitter-bash
]);
nvim-treesitter-with-grammars = nvim-treesitter.overrideAttrs (oldAttrs: {
postPatch = ''
rm -r parser
ln -s ${treesitterGrammars} parser
'';
});
in
{
luaConfig = builtins.readFile ./treesitter.lua;
plugins = [
nvim-treesitter-with-grammars
];
}

View File

@ -1,12 +0,0 @@
require("nvim-treesitter.configs").setup({
ensure_installed = {},
sync_install = false,
highlight = {
enable = true,
},
indent = {
enable = true,
},
})

View File

@ -1,36 +0,0 @@
{ enableDevIcons ? false
, enableTabby ? false
, theme ? { }
}:
{ lib
, theme
, lualine-nvim
, lualine-lsp-progress
, nvim-web-devicons
, tabby-nvim
, ...
}:
let
inherit (builtins) readFile isString;
themeFlavour = if isString (lib.getAttrOpt "flavour" theme) then theme.flavour else "frappe";
themeConfig = if isString (lib.getAttrOpt "config" theme) then theme.config else ''
vim.g.catppuccin_flavour = "${themeFlavour}"
require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]])
'';
lualinePlugins = [ lualine-nvim lualine-lsp-progress ];
in
{
luaConfig = themeConfig
+ (readFile ./lualine.lua)
+ (lib.optional enableTabby (readFile ./tabby-nvim.lua));
plugins = [ theme ]
++ lualinePlugins
++ (lib.optional enableDevIcons [ nvim-web-devicons ])
++ (lib.optional enableTabby [ tabby-nvim ]);
}

View File

@ -1,16 +0,0 @@
-- See: https://github.com/nvim-lualine/lualine.nvim#default-configuration
require("lualine").setup({
options = {
ignore_focus = { "NvimTree" },
},
sections = {
lualine_a = {
{ "filename", path = 1 },
},
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "lsp_progress" },
lualine_x = { "filesize", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location", "mode" },
},
})

View File

@ -1,5 +0,0 @@
-- always display tabline
-- vim.o.showtabline = 2
-- See: https://github.com/nanozuki/tabby.nvim
require("tabby.tabline").use_preset("tab_only")

View File

@ -1,7 +0,0 @@
{ hop-nvim, ... }:
{
luaConfig = builtins.readFile ./hop-nvim.lua;
plugins = [ hop-nvim ];
}

View File

@ -1,41 +0,0 @@
-- See: https://github.com/phaazon/hop.nvim/wiki/Configuration
local hop = require("hop")
require("hop").setup({})
-------------------------------------------------------------------------------
-- Keybindings
local hint = require("hop.hint")
vim.keymap.set("", "<leader>hf", function()
hop.hint_char1({
direction = hint.HintDirection.AFTER_CURSOR,
current_line_only = true,
})
end)
vim.keymap.set("", "<leader>hF", function()
hop.hint_char1({
direction = hint.HintDirection.BEFORE_CURSOR,
current_line_only = true,
})
end)
vim.keymap.set("", "<leader>ht", function()
hop.hint_char1({
direction = hint.HintDirection.AFTER_CURSOR,
current_line_only = true,
hint_offset = -1,
})
end)
vim.keymap.set("", "<leader>hT", function()
hop.hint_char1({
direction = hint.HintDirection.BEFORE_CURSOR,
current_line_only = true,
hint_offset = 1,
})
end)
vim.keymap.set("", "<leader>hc", "<Cmd>HopChar1<CR>")
vim.keymap.set("", "<leader>hw", "<Cmd>HopWord<CR>")
vim.keymap.set("", "<leader>hp", "<Cmd>HopPattern<CR>")
vim.keymap.set("", "<leader>hl", "<Cmd>HopLine<CR>")
vim.keymap.set("", "<leader>hv", "<Cmd>HopVertical<CR>")