1
Fork 0

feat: no more using nix to install nvim plugins

This commit is contained in:
Matei Adriel 2022-05-15 21:56:19 +03:00
parent 400794b28c
commit 92caa088aa
16 changed files with 182 additions and 135 deletions

View file

@ -12,3 +12,6 @@ My flake based nixos configuration. To use this, just rebuild your system using
- automatically save/restore state using continuum - automatically save/restore state using continuum
- customize status bar - customize status bar
- clean out the mess I made for installing fish themes - clean out the mess I made for installing fish themes
- customize picom
- vim:
- configure lualine more

View file

@ -1,5 +0,0 @@
-- Import my other files
require("my.options").setup()
require('my.keymaps').setup()
require('my.plugins').setup()
require("telescope.extensions.unicode").setupAbbreviations()

View file

@ -0,0 +1,13 @@
local M = {}
function M.setup()
-- Import my other files
require("my.paq").setup()
require("my.theme").setup()
require("my.options").setup()
require('my.keymaps').setup()
require('my.plugins').setup()
require("telescope.extensions.unicode").setupAbbreviations()
end
return M

View file

@ -10,7 +10,6 @@ function M.setup()
"setf " .. syntax) "setf " .. syntax)
end end
end) end)
end end
return M return M

View file

@ -0,0 +1,49 @@
local M = {}
function M.setup()
local paq = require("paq")
local themePackages = require("my.theme").deps
local base = {
"neovim/nvim-lspconfig", -- configures lsps for me
"windwp/nvim-autopairs", -- closes pairs for me (should look for a better one)
"nvim-lua/plenary.nvim", -- async utility lib it seems?
"nvim-telescope/telescope.nvim", -- fuzzy search for say opening files
"purescript-contrib/purescript-vim", -- purescript support
"terrortylor/nvim-comment", -- allows toggling line comments
{"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}, -- use treesitter for syntax highlighting
{"nvim-treesitter/nvim-treesitter-textobjects", run = ":TSUpdate"}, -- the lean plugin wants me to install this, lol
"startup-nvim/startup.nvim", -- splash screen
"kyazdani42/nvim-web-devicons", -- nice looking icons
"nvim-lualine/lualine.nvim", -- customizable status line
"kyazdani42/nvim-tree.lua", -- file tree
"lervag/vimtex", -- latex support
"jose-elias-alvarez/null-ls.nvim", -- generic language server
"nvim-telescope/telescope-file-browser.nvim", -- file creation/deletion menu
"onsails/lspkind.nvim", -- show icons in lsp completion menus
"preservim/vimux", -- interact with tmux from within vim
"christoomey/vim-tmux-navigator", -- easly switch between tmux and vim panes
"kana/vim-arpeggio", -- chord support, let"s fucking goooo
{"andweeb/presence.nvim", run = ":DownloadUnicode"}, -- discord rich presence
"Julian/lean.nvim", -- lean support
"kmonad/kmonad-vim", -- kmonad config support
"LucHermitte/lh-vim-lib", -- dependency for lh-brackets
"LucHermitte/lh-brackets", -- kinda useless bruh
-- Cmp related stuff
"hrsh7th/cmp-nvim-lsp", -- lsp completion
"hrsh7th/cmp-buffer", -- idr what this is
"hrsh7th/cmp-path", -- path completion ig?
"hrsh7th/cmp-cmdline", -- cmdline completion perhaps?
"hrsh7th/nvim-cmp", -- completion engine
"L3MON4D3/LuaSnip", -- snippeting engine
"saadparwaiz1/cmp_luasnip" -- snippet support for cmp
}
for _, v in ipairs(themePackages) do
-- append package in the base list
table.insert(base, v)
end
paq(base)
end
return M

View file

@ -3,6 +3,7 @@ local A = require("my.plugins.arpeggio")
local M = {} local M = {}
local function map(buf, mode, lhs, rhs, opts) local function map(buf, mode, lhs, rhs, opts)
local options = {noremap = true, silent = true} local options = {noremap = true, silent = true}
if opts then options = vim.tbl_extend('force', options, opts) end if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options) vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options)
@ -12,7 +13,8 @@ function M.on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
if client.resolved_capabilities.document_formatting then if client.server_capabilities.documentFormattingProvider then
print("Initializing formatter...")
vim.cmd([[ vim.cmd([[
augroup LspFormatting augroup LspFormatting
autocmd! * <buffer> autocmd! * <buffer>
@ -21,36 +23,39 @@ function M.on_attach(client, bufnr)
]]) ]])
end end
print("Setting up keybinds...")
-- Go to declaration / definition / implementation -- Go to declaration / definition / implementation
map(bufnr, "n", 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>') map(bufnr, "n", 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>')
map(bufnr, "n", 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>') map(bufnr, "n", 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>')
map(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>') map(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>')
-- Hover -- Hover
map(bufnr, 'n', 'J', map(bufnr, 'n', 'J', "<cmd>lua vim.diagnostic.open_float()<CR>")
"<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>")
map(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>') map(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>')
map(bufnr, 'n', 'L', '<cmd>lua vim.lsp.buf.signature_help()<CR>') map(bufnr, 'n', 'L', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
-- Workspace stuff -- Workspace stuff
map(bufnr, 'n', '<leader>wa', -- map(bufnr, 'n', '<leader>wa',
'<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>') -- '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
map(bufnr, 'n', '<leader>wr', -- map(bufnr, 'n', '<leader>wr',
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>') -- '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
map(bufnr, 'n', '<leader>wl', -- map(bufnr, 'n', '<leader>wl',
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>') -- '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
-- Code actions -- Code actions
map(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>') map(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
map(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>') map(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>')
-- map(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>') map(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>')
map(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>') map(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>')
map(bufnr, 'n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>') map(bufnr, 'n', '<leader>f',
'<cmd>lua vim.lsp.buf.format({async = true})<CR>')
print("Initialized language server!")
end end
local function on_attach_typescript(client, bufnr) local function on_attach_typescript(client, bufnr)
client.resolved_capabilities.document_formatting = false -- We handle formatting using null-ls and prettierd
client.resolved_capabilities.document_range_formatting = false client.server_capabilities.documentFormattingProvider = false
M.on_attach(client, bufnr) M.on_attach(client, bufnr)
end end

View file

@ -12,9 +12,7 @@ local bindings = {
live_grep = "<c-F>", live_grep = "<c-F>",
-- See diagnostics with space + d -- See diagnostics with space + d
lsp_document_diagnostics = "<Leader>d", diagnostics = "<Leader>d",
lsp_workspace_diagnostics = "<Leader>wd",
lsp_code_actions = "<Leader>ca",
-- Open a list with all the pickers -- Open a list with all the pickers
builtin = "<Leader>t", builtin = "<Leader>t",

View file

@ -2,10 +2,16 @@ local M = {}
function M.setup() function M.setup()
require'nvim-treesitter.configs'.setup { require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained", ensure_installed = {
"bash", "javascript", "typescript", "c", "cpp", "css", "dockerfile",
"elixir", "fish", "html", "json", "latex", "python", "rust", "scss",
"toml", "tsx", "vim", "yaml", "nix"
},
sync_install = false, sync_install = false,
indent = {enable = true},
highlight = { highlight = {
enable = true, enable = true,
disable = {"lua"}, -- WHY TF DOES THIS NOT WORK
-- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).

View file

@ -40,4 +40,4 @@ set-option -g @fastcopy-action 'tmux load-buffer -w -'
set-option -g @fastcopy-key a set-option -g @fastcopy-key a
# Keep state around using resurrect # Keep state around using resurrect
set -g @resurrect-processes '"./result/bin/qkm ./myConfig.json"' set -g @resurrect-processes '"~python3"'

View file

@ -1,101 +1,69 @@
{ pkgs, lib, ... }: { pkgs, lib, paths, ... }:
let let
paq = pkgs.fetchFromGitHub {
owner = "savq";
repo = "paq-nvim";
rev = "cbbb8a550e35b1e6c9ddf7b098b25e6c2d8b1e86";
sha256 = "0fsbww2kqwayi1azhglsjal6mwh68n03ylxxqzq17v7sar17vx4c";
};
theme = pkgs.myThemes.current; theme = pkgs.myThemes.current;
# config-nvim = "/etc/nixos/configuration/dotfiles/neovim"; extraPackages = with pkgs; [
config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { # Language servers
name = "config-nvim"; # haskellPackages.agda-language-server # agda
src = ../../dotfiles/neovim; nodePackages.typescript-language-server # typescript
}; easy-purescript-nix.purescript-language-server # purescript
sumneko-lua-language-server # lua
rnix-lsp # nix
haskell-language-server # haskell
# Lua code for importing a theme # Formatters
loadTheme = (theme: '' luaformatter # lua
${theme.neovim.theme} ormolu # haskell
prettierd # prettier but faster
# Others
fd # file finder
ripgrep # grep rewrite (I think?)
nodePackages.typescript # typescript language
update-nix-fetchgit # useful for nix stuff
tree-sitter # syntax highlighting
texlive.combined.scheme-full # latex stuff
python38Packages.pygments # required for latex syntax highlighting
];
myConfig = ''
vim.g.lualineTheme = ${theme.neovim.lualineTheme} vim.g.lualineTheme = ${theme.neovim.lualineTheme}
''); vim.opt.runtimepath:append("${paths.dotfiles}/neovim")
-- dofile("${paths.dotfiles}/neovim/my/init.lua").setup()
require("my.init").setup()
'';
base = pkgs.neovim-nightly;
neovim =
pkgs.symlinkJoin {
inherit (base) name meta;
paths = [ base ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/nvim \
--prefix PATH : ${lib.makeBinPath extraPackages}
'';
};
# Wrap a piece of lua code
lua = (code: ''
lua << EOF
${code}
EOF
'');
in in
{ {
home-manager.users.adrielus.programs.neovim = { home-manager.users.adrielus =
enable = true; {
package = pkgs.neovim-nightly; home.file.".local/share/nvim/site/pack/paqs/start/paq-nvim".source = paq;
xdg.configFile."nvim/init.lua".text = myConfig;
xdg.configFile."nvim/lua/my/theme.lua".source = theme.neovim.theme;
home.packages = [ neovim ];
extraConfig = '' programs.neovim = {
${lua (loadTheme theme)} enable = false;
luafile ${config-nvim}/init.lua };
''; };
extraPackages = with pkgs; [
# Language servers
# haskellPackages.agda-language-server # agda
nodePackages.typescript-language-server # typescript
easy-purescript-nix.purescript-language-server # purescript
sumneko-lua-language-server # lua
rnix-lsp # nix
haskell-language-server # haskell
# Formatters
luaformatter # lua
ormolu # haskell
prettierd # prettier but faster
# Others
fd # file finder
ripgrep # grep rewrite (I think?)
nodePackages.typescript # typescript language
update-nix-fetchgit # useful for nix stuff
texlive.combined.scheme-full # latex stuff
python38Packages.pygments # required for latex syntax highlighting
];
plugins = with pkgs.vimPlugins;
with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; theme.neovim.plugins ++ [
config-nvim # my neovim config
nvim-lspconfig # configures lsps for me
nvim-autopairs # close pairs for me
telescope-nvim # fuzzy search for say opening files
purescript-vim # purescript syntax highlighting
nvim-comment # allows toggling line-comments
nvim-treesitter # use treesitter for syntax highlighting
nvim-treesitter-textobjects # the lean plugin told me to add this
startup-nvim # splash screen
vim-devicons # nice looking icons
nvim-web-devicons # fork of vim-devicons?
plenary-nvim # async utility lib it seems?
lualine-nvim # customizable status line
nvim-tree-lua # file tree
vimtex # latex plugin
null-ls-nvim # generic language server
telescope-file-browser-nvim # file creation/deletion using telescope
lspkind-nvim # show icons in lsp completion menus
# symbols-outline-nvim # tree view for symbols in document
vimux # interact with tmux from within vim
vim-tmux-navigator # easly switch between tmux and vim panes
arpeggio # allows me to setup chord keybinds (keybinds where all the keys are pressed at the same time)
presence-nvim # discord rich presence
agda-nvim # agda support
unicode-vim # better unicode support
lean-nvim # lean support
kmonad # support for the kmonad config language
lh-vim-lib # dependency for lh-brackets
lh-brackets # bracket customization
# Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp
cmp-nvim-lsp
cmp-buffer
cmp-path
cmp-cmdline
cmp_luasnip
nvim-cmp # completion engine
luasnip # snippet engine
];
};
} }

View file

@ -4,6 +4,7 @@
./applications ./applications
./themes ./themes
./overlays ./overlays
./meta
./network.nix ./network.nix
./xserver.nix ./xserver.nix

3
modules/meta/default.nix Normal file
View file

@ -0,0 +1,3 @@
{ pkgs, ... }: {
home-manager.sharedModules = [ ./simlink.nix ];
}

13
modules/meta/simlink.nix Normal file
View file

@ -0,0 +1,13 @@
# This is a home-manager config!!!
{ pkgs, lib, config, ... }: with lib; {
options.home.sfile = mkOption {
description = "Attribute set of files to link into the user home without placing them into the store first";
default = { };
type = types.attrsOf types.string;
};
config.systemd.user.tmpfiles.rules = mapAttrsToList
(name: value:
"L+ ${name} - - - - ${value}"
)
config.home.sfile;
}

View file

@ -9,16 +9,8 @@ in
wallpaper = wallpaper.foreign or "${foreign.wallpapers}/${wallpaper}"; wallpaper = wallpaper.foreign or "${foreign.wallpapers}/${wallpaper}";
neovim = { neovim = {
theme = builtins.readFile ./nvim.lua; theme = ./nvim.lua;
lualineTheme = "catppuccin"; lualineTheme = "catppuccin";
plugins = [
(
pkgs.vimUtils.buildVimPluginFrom2Nix {
name = "catppuccin";
src = foreign.nvim;
}
)
];
}; };
# grub.path = "${foreign.grub}/catppuccin-grub-theme/theme.txt"; # grub.path = "${foreign.grub}/catppuccin-grub-theme/theme.txt";

View file

@ -1,10 +1,4 @@
{ fetchFromGitHub, ... }: { { fetchFromGitHub, ... }: {
nvim = fetchFromGitHub {
owner = "catppuccin";
repo = "nvim";
sha256 = "1w96rvpbm7lk9lcc5i13d6dyb5b10vkjh1902xmklqvpzy1wya19";
rev = "8a67df6da476cba68ecf26a519a5279686edbd2e";
};
tmux = fetchFromGitHub { tmux = fetchFromGitHub {
owner = "catppuccin"; owner = "catppuccin";
repo = "tmux"; repo = "tmux";

View file

@ -1,8 +1,16 @@
local catppuccin = require("catppuccin") local M = {}
catppuccin.setup({ M.deps = {{"catppuccin/nvim", as = "catppuccin"}}
transparent_background = true,
integrations = {nvimtree = {transparent_panel = true}}
})
vim.cmd [[colorscheme catppuccin]] function M.setup()
local catppuccin = require("catppuccin")
catppuccin.setup({
transparent_background = true,
integrations = {nvimtree = {transparent_panel = true}}
})
vim.cmd [[colorscheme catppuccin]]
end
return M