making neovim use ide flake

This commit is contained in:
Ivan Dimitrov 2023-11-18 08:42:50 +02:00
parent 4bf193e9ab
commit b8dd418de0
14 changed files with 316 additions and 365 deletions

View File

@ -1,5 +1,125 @@
{ {
"nodes": { "nodes": {
"beautysh": {
"inputs": {
"nixpkgs": [
"ide",
"nixvim",
"nixpkgs"
],
"poetry2nix": "poetry2nix",
"utils": "utils"
},
"locked": {
"lastModified": 1680308980,
"narHash": "sha256-aUEHV0jk2qIFP3jlsWYWhBbm+w/N9gzH3e4I5DcdB5s=",
"owner": "lovesegfault",
"repo": "beautysh",
"rev": "9845efc3ea3e86cc0d41465d720a47f521b2799c",
"type": "github"
},
"original": {
"owner": "lovesegfault",
"repo": "beautysh",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": [
"ide",
"systems"
]
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"ide",
"nixvim",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -40,6 +160,29 @@
"type": "github" "type": "github"
} }
}, },
"ide": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"nixvim": "nixvim",
"systems": "systems_3"
},
"locked": {
"lastModified": 1700289697,
"narHash": "sha256-/erb3yK7dVsqnZ8ehcpmHeWTm6f0hdoBcBNtbYQTwpQ=",
"owner": "ivandimitrov8080",
"repo": "xin-ide",
"rev": "907a557f480e1311e5ee6b38b94a0d2cb0cd3d2f",
"type": "github"
},
"original": {
"owner": "ivandimitrov8080",
"repo": "xin-ide",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1699936420, "lastModified": 1699936420,
@ -55,12 +198,168 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"beautysh": "beautysh",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"ide",
"nixpkgs"
],
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1700216821,
"narHash": "sha256-c0W9HelclC4rACUAXTK8Q8+X0oKlLTTXnsheLJoA0iw=",
"owner": "ivandimitrov8080",
"repo": "nixvim",
"rev": "5b615804cc96dcbc42b17b38d33264ade00976cc",
"type": "github"
},
"original": {
"owner": "ivandimitrov8080",
"repo": "nixvim",
"type": "github"
}
},
"poetry2nix": {
"inputs": {
"flake-utils": [
"ide",
"nixvim",
"beautysh",
"utils"
],
"nixpkgs": [
"ide",
"nixvim",
"beautysh",
"nixpkgs"
]
},
"locked": {
"lastModified": 1658665240,
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_3",
"gitignore": "gitignore",
"nixpkgs": [
"ide",
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1698227354,
"narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager", "home-manager": "home-manager",
"hosts": "hosts", "hosts": "hosts",
"ide": "ide",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"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": 1680978846,
"narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
"owner": "nix-systems",
"repo": "x86_64-linux",
"rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "x86_64-linux",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1678901627,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -9,6 +9,10 @@
url = "github:StevenBlack/hosts"; url = "github:StevenBlack/hosts";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
ide = {
url = "github:ivandimitrov8080/xin-ide";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
@ -16,6 +20,7 @@
, nixpkgs , nixpkgs
, home-manager , home-manager
, hosts , hosts
, ide
, ... , ...
}: }:
let let
@ -42,6 +47,12 @@
./home/ivand ./home/ivand
./modules/programs ./modules/programs
./modules/packages ./modules/packages
(
import ./modules/programs/neovim
{
nvim = ide.homeManagerModules.${system}.nvim;
}
)
]; ];
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;

View File

@ -47,7 +47,6 @@
}; };
programs = { programs = {
nv.enable = true;
shell.enable = true; shell.enable = true;
common.enable = true; common.enable = true;
}; };

View File

@ -3,7 +3,7 @@ let
cfg = config.programs.common; cfg = config.programs.common;
in in
{ {
imports = [ ./neovim ./neomutt ./sway ./tmux.nix ./zsh.nix ./lf ]; imports = [ ./sway ./tmux.nix ./zsh.nix ./lf ];
options.programs.common = { options.programs.common = {
enable = lib.mkEnableOption "common"; enable = lib.mkEnableOption "common";

View File

@ -1,22 +0,0 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
bash
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
nodePackages_latest.bash-language-server
shfmt
shellcheck
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
bashls = {}
})
'';
};
}

View File

@ -1,56 +1,8 @@
{ pkgs, lib, config, ... }: { nvim, ... }:
let nvim
grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
diff
regex
vimdoc
comment
markdown
ungrammar
gitignore
gitcommit
git_rebase
git_config
gitattributes
dockerfile
];
cfg = config.programs.nv;
in
{ {
imports = [ ./firenvim.nix ./py.nix ./hs.nix ./bash.nix ./nix.nix ./lua.nix ./js.nix ./util.nix ]; enable = true;
plugins.lsp.servers = {
options.programs.nv = { bashls.enable = true;
enable = lib.mkEnableOption "nv";
};
config = lib.mkIf cfg.enable {
programs.neovim = {
enable = true;
viAlias = true;
extraPackages = with pkgs; [
ripgrep
];
plugins = with pkgs.vimPlugins; grammars ++ [
nvim-treesitter
nvim-surround
nvim-ts-autotag
autoclose-nvim
barbar-nvim
cmp-nvim-lsp
comment-nvim
gitsigns-nvim
luasnip
catppuccin-nvim
nvim-cmp
nvim-lspconfig
nvim-web-devicons
plenary-nvim
telescope-nvim
toggleterm-nvim
vim-vinegar
lualine-nvim
];
extraLuaConfig = lib.fileContents ./nvim/default.lua;
};
}; };
} }

View File

@ -1,20 +0,0 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
haskell
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
haskell-language-server
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
hls = {}
})
'';
};
}

View File

@ -1,43 +0,0 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
tsx
jsdoc
json
json5
jsonnet
http
html
astro
svelte
prisma
graphql
typescript
javascript
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
nodePackages_latest.prettier
nodePackages_latest.typescript
nodePackages_latest.typescript-language-server
nodePackages_latest."@tailwindcss/language-server"
nodePackages_latest."@prisma/language-server"
nodePackages_latest.vscode-html-languageserver-bin
];
plugins = with pkgs.vimPlugins; grammars ++ [
vim-prisma
];
extraLuaConfig = ''
addServers({
tsserver = {},
tailwindcss = {},
prismals = {},
html = {
cmd = { "html-languageserver", "--stdio" }
},
})
'';
};
}

View File

@ -1,25 +0,0 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
lua
luadoc
luau
luap
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
lua
lua-language-server
stylua
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
lua_ls = {}
})
'';
};
}

View File

@ -1,21 +0,0 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
nix
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
nixd
nixpkgs-fmt
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
nixd = {}
})
'';
};
}

View File

@ -1,126 +0,0 @@
vim.wo.number = true
vim.o.scrolloff = 15
vim.o.hlsearch = false
vim.o.updatetime = 20
vim.o.autoread = true
vim.o.tabstop = 4
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true }) -- nop leader
local nmap = function(keys, cmd)
vim.keymap.set("n", keys, cmd, { noremap = true, silent = true })
end
local vmap = function(keys, cmd)
vim.keymap.set("v", keys, cmd, { noremap = true, silent = true })
end
local tmap = function(keys, cmd)
vim.keymap.set("t", keys, cmd, { noremap = true, silent = true })
end
nmap("<leader>/", require("Comment.api").toggle.linewise.current)
vmap("<leader>/", "<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>")
nmap("<Tab>", "<cmd>BufferNext<cr>")
nmap("<S-Tab>", "<cmd>BufferPrevious<cr>")
nmap("<leader>x", "<cmd>BufferClose<cr>")
nmap("<leader>h", "<cmd>ToggleTerm<cr>")
tmap("<leader>h", "<cmd>ToggleTerm<cr>")
nmap("<leader>r", "<cmd>!%:p<cr>")
nmap("<leader>ff", require("telescope.builtin").find_files)
nmap("<leader>fw", require("telescope.builtin").live_grep)
nmap("<leader>e", vim.diagnostic.open_float)
local cmp = require("cmp")
local lspconfig = require("lspconfig")
local cmp_capabilities = require("cmp_nvim_lsp").default_capabilities()
local on_attach = function(client, bufnr)
nmap("<leader>ca", vim.lsp.buf.code_action)
nmap("<leader>lr", vim.lsp.buf.rename)
nmap("gd", vim.lsp.buf.definition)
nmap("<leader>lf", function()
vim.lsp.buf.format()
end)
nmap("K", vim.lsp.buf.hover)
nmap("gr", require("telescope.builtin").lsp_references)
if client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
vim.lsp.buf.document_highlight()
end,
})
vim.api.nvim_create_autocmd("CursorMoved", {
buffer = bufnr,
callback = function()
vim.lsp.buf.clear_references()
end,
})
end
end
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" } }, { { name = "buffer" } }),
})
for server, cfg in pairs(servers) do
lspconfig[server].setup({
cmd = cfg.cmd,
settings = cfg.settings,
capabilities = cmp_capabilities,
on_attach = on_attach,
})
end
require 'nvim-treesitter.configs'.setup {
autotag = {
enable = true,
}
}
require("Comment").setup()
require("toggleterm").setup()
require("autoclose").setup()
require("gitsigns").setup()
require("nvim-surround").setup()
require("telescope").setup {
defaults = {
file_ignore_patterns = { "hosts" },
}
}
require("lualine").setup({
options = {
theme = "catppuccin"
}
})
require("catppuccin").setup({
flavour = "mocha",
transparent_background = true,
integrations = {
cmp = true,
gitsigns = true,
treesitter = true,
telescope = {
enabled = true,
},
markdown = true
},
})
vim.cmd.colorscheme("catppuccin")

View File

@ -1,27 +0,0 @@
local servers = {}
local addServers = function(srv)
servers = vim.tbl_deep_extend("force", servers, srv)
end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k, v in pairs(o) do
if type(k) ~= 'number' then k = '"' .. k .. '"' end
s = s .. '[' .. k .. '] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local function log(o)
local file = io.open("./.nvim.log", "a+")
if file then
file:write(os.date("%Y/%m/%d %H:%M:%S") .. " || " .. dump(o) .. "\n")
file:write("---\n")
file:close()
end
end

View File

@ -1,20 +0,0 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
python
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
python311Packages.python-lsp-server
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
pylsp = {},
})
'';
};
}

View File

@ -1,6 +0,0 @@
{ pkgs, lib, ... }:
{
programs.neovim = {
extraLuaConfig = lib.fileContents ./nvim/util.lua;
};
}