chore: initial commit
This commit is contained in:
commit
cc4f3398ff
37 changed files with 2210 additions and 0 deletions
16
modules/editors/nvim/config/init.lua
Normal file
16
modules/editors/nvim/config/init.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
vim.opt.expandtab = true
|
||||
vim.opt.hidden = true
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.mouse = "a"
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
vim.opt.signcolumn = "yes:3"
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.timeoutlen = 0
|
||||
vim.wo.wrap = false
|
||||
vim.opt.exrc = true
|
||||
vim.cmd("syntax on")
|
||||
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
28
modules/editors/nvim/config/lspconfig.lua
Normal file
28
modules/editors/nvim/config/lspconfig.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
local lspc = require'lspconfig'
|
||||
|
||||
lspc.nil_ls.setup{}
|
||||
lspc.clangd.setup{}
|
||||
|
||||
local buf_map = function(bufnr, mode, lhs, rhs, opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts or {
|
||||
silent = true,
|
||||
})
|
||||
end
|
||||
|
||||
lspc.tsserver.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
client.resolved_capabilities.document_range_formatting = false
|
||||
|
||||
local ts_utils = require("nvim-lsp-ts-utils")
|
||||
ts_utils.setup({})
|
||||
ts_utils.setup_client(client)
|
||||
|
||||
buf_map(bufnr, "n", "gs", ":TSLspOrganize<CR>")
|
||||
buf_map(bufnr, "n", "gi", ":TSLspRenameFile<CR>")
|
||||
buf_map(bufnr, "n", "go", ":TSLspImportAll<CR>")
|
||||
|
||||
on_attach(client, bufnr)
|
||||
end,
|
||||
})
|
||||
|
||||
73
modules/editors/nvim/config/nvim-cmp.lua
Normal file
73
modules/editors/nvim/config/nvim-cmp.lua
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||
end
|
||||
|
||||
local cmp = require("cmp")
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "cmp_tabnine" },
|
||||
{ name = "treesitter" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
{ name = "vsnip" },
|
||||
-- { name = "copilot" },
|
||||
},
|
||||
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
with_text = true,
|
||||
menu = {
|
||||
buffer = "[Buf]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
latex_symbols = "[Latex]",
|
||||
treesitter = "[TS]",
|
||||
cmp_tabnine = "[TN]",
|
||||
vsnip = "[Snip]",
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
mapping = {
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
})
|
||||
20
modules/editors/nvim/config/theming.lua
Normal file
20
modules/editors/nvim/config/theming.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- set colorscheme
|
||||
vim.cmd 'set termguicolors'
|
||||
|
||||
vim.g.catppuccin_flavour = "mocha"
|
||||
|
||||
require("catppuccin").setup()
|
||||
|
||||
vim.cmd [[colorscheme catppuccin]]
|
||||
|
||||
-- enable colorizer
|
||||
require'colorizer'.setup()
|
||||
|
||||
-- set sign
|
||||
vim.cmd 'sign define DiagnosticSignError text= linehl= texthl=DiagnosticSignError numhl='
|
||||
vim.cmd 'sign define DiagnosticSignHint text= linehl= texthl=DiagnosticSignHint numhl='
|
||||
vim.cmd 'sign define DiagnosticSignInfo text= linehl= texthl=DiagnosticSignInfo numhl='
|
||||
vim.cmd 'sign define DiagnosticSignWarn text= linehl= texthl=DiagnosticSignWarn numhl='
|
||||
|
||||
-- set lightline theme to horizon
|
||||
vim.g.lightline = { colorscheme = "catppuccin" }
|
||||
14
modules/editors/nvim/config/treesitter-textobjects.lua
Normal file
14
modules/editors/nvim/config/treesitter-textobjects.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require'nvim-treesitter.configs'.setup {
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
30
modules/editors/nvim/config/treesitter.lua
Normal file
30
modules/editors/nvim/config/treesitter.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- breaks highlight
|
||||
-- vim.cmd([[set foldmethod=expr]])
|
||||
-- vim.cmd([[set foldlevel=10]])
|
||||
-- vim.cmd([[set foldexpr=nvim_treesitter#foldexpr()]])
|
||||
29
modules/editors/nvim/config/utils.lua
Normal file
29
modules/editors/nvim/config/utils.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- telescope
|
||||
require('telescope').load_extension('fzy_native')
|
||||
|
||||
-- null-ls
|
||||
local nb = require('null-ls').builtins
|
||||
|
||||
require('null-ls').setup({
|
||||
sources = {
|
||||
nb.formatting.alejandra,
|
||||
nb.code_actions.statix,
|
||||
nb.diagnostics.cppcheck,
|
||||
nb.diagnostics.deadnix,
|
||||
nb.diagnostics.statix,
|
||||
nb.diagnostics.eslint,
|
||||
nb.completion.spell,
|
||||
},
|
||||
})
|
||||
|
||||
require("gitsigns").setup()
|
||||
|
||||
-- autopairs
|
||||
require('nvim-autopairs').setup{}
|
||||
|
||||
-- copy to system clipboard
|
||||
vim.api.nvim_set_keymap( 'v', '<Leader>y', '"+y', {noremap = true})
|
||||
vim.api.nvim_set_keymap( 'n', '<Leader>y', ':%+y<CR>', {noremap = true})
|
||||
|
||||
-- paste from system clipboard
|
||||
vim.api.nvim_set_keymap( 'n', '<Leader>p', '"+p', {noremap = true})
|
||||
39
modules/editors/nvim/config/which-key.lua
Normal file
39
modules/editors/nvim/config/which-key.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
vim.g.mapleader = " "
|
||||
|
||||
local wk = require("which-key")
|
||||
|
||||
wk.setup({})
|
||||
|
||||
wk.register({
|
||||
["<leader>"] = {
|
||||
b = { "<cmd>Telescope buffers<cr>", "Buffers" },
|
||||
["/"] = { "<cmd>Telescope live_grep<cr>", "Live Grep" },
|
||||
f = { "<cmd>Telescope find_files<cr>", "Find File" },
|
||||
g = {
|
||||
name = "Git / VCS",
|
||||
i = { "<cmd>lua require('telescope').extensions.gh.issues()<cr>", "Github Issues" },
|
||||
p = { "<cmd>lua require('telescope').extensions.gh.pull_request()<cr>", "Github PRs" },
|
||||
b = { "<cmd>ToggleBlameLine<cr>", "Toggle BlameLine" },
|
||||
c = { "<cmd>Neogit commit<cr>", "Commit" },
|
||||
s = { "<cmd>Neogit kind=split<cr>", "Staging" },
|
||||
},
|
||||
a = { "<cmd>lua require('telescope.builtin').lsp_code_actions()<cr>", "Code Actions" },
|
||||
d = { "<cmd>lua require('telescope.builtin').lsp_document_diagnostics()<cr>", "LSP Diagnostics" },
|
||||
k = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "Signature Help" },
|
||||
l = {
|
||||
name = "LSP",
|
||||
f = { "<cmd>lua vim.lsp.buf.formatting_sync()<cr>", "Format file"},
|
||||
q = { "<cmd>lua vim.lsp.diagnostic.set_loclist()<cr>", "Set Loclist" },
|
||||
e = { "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<cr>", "Show Line Diagnostics" },
|
||||
},
|
||||
p = { "\"+p", "Paste from clipboard" },
|
||||
P = { "\"+P", "Paste from clipboard before cursor" },
|
||||
y = { "\"+y", "Yank to clipboard" },
|
||||
},
|
||||
g = {
|
||||
l = { "$", "Line end" },
|
||||
h = { "0", "Line start" },
|
||||
s = { "^", "First non-blank in line" },
|
||||
e = { "G", "Bottom" },
|
||||
},
|
||||
})
|
||||
65
modules/editors/nvim/home.nix
Normal file
65
modules/editors/nvim/home.nix
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{ pkgs, ... }: {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
|
||||
vimAlias = true;
|
||||
viAlias = true;
|
||||
vimdiffAlias = true;
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
catppuccin-nvim
|
||||
cmp-buffer
|
||||
cmp-nvim-lsp
|
||||
cmp-path
|
||||
cmp-spell
|
||||
cmp-treesitter
|
||||
cmp-vsnip
|
||||
friendly-snippets
|
||||
gitsigns-nvim
|
||||
lightline-vim
|
||||
lspkind-nvim
|
||||
neogit
|
||||
null-ls-nvim
|
||||
nvim-autopairs
|
||||
nvim-cmp
|
||||
nvim-colorizer-lua
|
||||
nvim-lspconfig
|
||||
nvim-tree-lua
|
||||
nvim-ts-rainbow
|
||||
(nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars))
|
||||
plenary-nvim
|
||||
telescope-fzy-native-nvim
|
||||
telescope-nvim
|
||||
telescope-github-nvim
|
||||
vim-floaterm
|
||||
vim-sneak
|
||||
vim-vsnip
|
||||
which-key-nvim
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [ gcc ripgrep fd deadnix ];
|
||||
|
||||
extraConfig =
|
||||
let
|
||||
luaRequire = module:
|
||||
builtins.readFile (builtins.toString
|
||||
./config
|
||||
+ "/${module}.lua");
|
||||
luaConfig = builtins.concatStringsSep "\n" (map luaRequire [
|
||||
"init"
|
||||
"lspconfig"
|
||||
"nvim-cmp"
|
||||
"theming"
|
||||
"treesitter"
|
||||
"treesitter-textobjects"
|
||||
"utils"
|
||||
"which-key"
|
||||
]);
|
||||
in
|
||||
''
|
||||
lua <<
|
||||
${luaConfig}
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue