Add a simple neovim config
This commit is contained in:
parent
9b210469ed
commit
45186dacb4
10 changed files with 302 additions and 36 deletions
|
@ -167,10 +167,14 @@ in {
|
|||
dnsutils
|
||||
graphviz
|
||||
fzf
|
||||
fd
|
||||
nixfmt
|
||||
my_emacs
|
||||
libreoffice
|
||||
gcc
|
||||
neovim
|
||||
go
|
||||
gopls
|
||||
#network-manager-applet
|
||||
(clang-tools.override {
|
||||
llvmPackages = llvmPackages_17;
|
||||
|
@ -377,6 +381,7 @@ in {
|
|||
fonts.fontDir.enable = true;
|
||||
fonts.packages = with pkgs; [
|
||||
dejavu_fonts
|
||||
(nerdfonts.override { fonts = [ "SourceCodePro" ]; })
|
||||
source-code-pro
|
||||
font-awesome # for waybar indicators
|
||||
];
|
||||
|
@ -505,6 +510,54 @@ in {
|
|||
|
||||
};
|
||||
|
||||
programs.neovim = let
|
||||
modus-themes = pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "modus-themes.nvim";
|
||||
version = "2024-05-06";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "miikanissi";
|
||||
repo = "modus-themes.nvim";
|
||||
rev = "705ea8debb9d9afe4e631166fcc6121782dd0b32";
|
||||
sha256 = "0hs2ylf1rj0655kpwr4blh399r8k7lg0r2a4nbnymy1pbkx1gh1i";
|
||||
};
|
||||
meta.homepage = "https://github.com/miikanissi/modus-themes.nvim/";
|
||||
};
|
||||
|
||||
in {
|
||||
enable = true;
|
||||
plugins = with pkgs; [
|
||||
vimPlugins.nvim-treesitter
|
||||
vimPlugins.nvim-treesitter.withAllGrammars
|
||||
pkgs.vimPlugins.nvim-treesitter-textobjects
|
||||
vimPlugins.nvim-lspconfig
|
||||
|
||||
vimPlugins.lualine-nvim
|
||||
vimPlugins.telescope-nvim
|
||||
vimPlugins.telescope-fzf-native-nvim
|
||||
vimPlugins.nvim-web-devicons
|
||||
|
||||
vimPlugins.nvim-cmp
|
||||
vimPlugins.cmp-nvim-lsp
|
||||
vimPlugins.cmp-buffer
|
||||
vimPlugins.cmp-cmdline
|
||||
vimPlugins.luasnip
|
||||
|
||||
modus-themes
|
||||
];
|
||||
extraConfig = ''
|
||||
lua << EOF
|
||||
${builtins.readFile nvim/basics.lua}
|
||||
${builtins.readFile nvim/treesitter.lua}
|
||||
${builtins.readFile nvim/lualine.lua}
|
||||
${builtins.readFile nvim/telescope.lua}
|
||||
${builtins.readFile nvim/completion.lua}
|
||||
${builtins.readFile nvim/luasnip.lua}
|
||||
${builtins.readFile nvim/lspconfig.lua}
|
||||
'';
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
};
|
||||
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
xwayland = true;
|
||||
|
@ -563,29 +616,27 @@ in {
|
|||
programs.foot = {
|
||||
enable = true;
|
||||
settings = {
|
||||
main = { font = "monospace:size=10"; };
|
||||
main = { font = "Source Code Pro:size=12"; };
|
||||
|
||||
colors = {
|
||||
background = "feffff";
|
||||
foreground = "333333";
|
||||
|
||||
regular0 = "333333";
|
||||
regular1 = "bd4436";
|
||||
regular2 = "008700";
|
||||
regular3 = "cdcc42";
|
||||
regular4 = "0017f5";
|
||||
regular5 = "b92cc6";
|
||||
regular6 = "5bbdf9";
|
||||
regular7 = "c7c7c7";
|
||||
|
||||
bright0 = "333333";
|
||||
bright1 = "bd4436";
|
||||
bright2 = "008700";
|
||||
bright3 = "cdcc42";
|
||||
bright4 = "0017f5";
|
||||
bright5 = "b92cc6";
|
||||
bright6 = "5bbdf9";
|
||||
bright7 = "feffff";
|
||||
background = "ffffff";
|
||||
foreground = "000000";
|
||||
regular0 = "000000";
|
||||
regular1 = "a60000";
|
||||
regular2 = "005e00";
|
||||
regular3 = "813e00";
|
||||
regular4 = "0031a9";
|
||||
regular5 = "721045";
|
||||
regular6 = "00538b";
|
||||
regular7 = "bfbfbf";
|
||||
bright0 = "595959";
|
||||
bright1 = "972500";
|
||||
bright2 = "315b00";
|
||||
bright3 = "70480f";
|
||||
bright4 = "2544bb";
|
||||
bright5 = "5317ac";
|
||||
bright6 = "005a5f";
|
||||
bright7 = "ffffff";
|
||||
};
|
||||
key-bindings = {
|
||||
clipboard-copy = "Control+Insert";
|
||||
|
|
24
emacs.el
24
emacs.el
|
@ -462,6 +462,10 @@ Enable org-roam
|
|||
org-gnus org-info org-irc org-mhe
|
||||
org-rmail org-checklist org-mu4e))
|
||||
|
||||
;; Enable line wrap by default in org buffers
|
||||
(setq org-startup-truncated nil)
|
||||
|
||||
|
||||
;; Sometimes I sit at night until 4 AM, and I still want org to treat it
|
||||
;; as "today"
|
||||
(setq org-extend-today-until 4)
|
||||
|
@ -973,6 +977,14 @@ window, unless BACKGROUND (prefix-argument) is non-nil.
|
|||
))
|
||||
)
|
||||
|
||||
(defun nix-gopls (int)
|
||||
(let ((curproj (project-current nil)))
|
||||
(if (and curproj (file-exists-p (format "%s/flake.nix" (project-root curproj))))
|
||||
(list "nix" "develop" (format "%s#" (project-root curproj)) "--command" "bash" "-c" "gopls")
|
||||
(list "gopls")
|
||||
))
|
||||
)
|
||||
|
||||
(with-eval-after-load 'eglot
|
||||
(add-hook
|
||||
'eglot-managed-mode-hook
|
||||
|
@ -990,11 +1002,17 @@ window, unless BACKGROUND (prefix-argument) is non-nil.
|
|||
`(c++-ts-mode . ,#'nix-clangd))
|
||||
(add-to-list 'eglot-server-programs
|
||||
`(c-ts-mode . ,#'nix-clanngd))
|
||||
(add-to-list 'eglot-server-programs
|
||||
`(go-ts-mode . ,#'nix-gopls))
|
||||
(add-to-list 'eglot-server-programs
|
||||
`(go-mode . ,#'nix-gopls))
|
||||
)
|
||||
|
||||
(add-hook 'c++-mode-hook 'eglot-ensure)
|
||||
(add-hook 'c++-ts-mode-hook 'eglot-ensure)
|
||||
(add-hook 'c-ts-mode-hook 'eglot-ensure)
|
||||
(add-hook 'go-ts-mode-hook 'eglot-ensure)
|
||||
(add-hook 'go-mode-hook 'eglot-ensure)
|
||||
|
||||
(use-package clang-format)
|
||||
(use-package clang-format+)
|
||||
|
@ -1017,6 +1035,12 @@ window, unless BACKGROUND (prefix-argument) is non-nil.
|
|||
(and (file-exists-p try)
|
||||
(cons (file-truename try) 'lcov))))))
|
||||
|
||||
;; Go
|
||||
|
||||
(add-hook 'before-save-hook #'gofmt-before-save)
|
||||
|
||||
(use-package go-mode)
|
||||
|
||||
;; Zig
|
||||
|
||||
(use-package zig-mode)
|
||||
|
|
30
flake.lock
30
flake.lock
|
@ -11,11 +11,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1712108714,
|
||||
"narHash": "sha256-QzrcwGuuAP1octIcUw/d+Yi5BEXYt1NOwNLpeUrqKTk=",
|
||||
"lastModified": 1714669473,
|
||||
"narHash": "sha256-LuwvRYxFw8bE3b75oun2HjdbnwGArYEDzRdhtxkx95o=",
|
||||
"owner": "nix-community",
|
||||
"repo": "emacs-overlay",
|
||||
"rev": "5d0a10938c32f3cb95d1f1f18127948d239c6720",
|
||||
"rev": "8f77253911c7dc3ac829781ac7f37d1d35447c5a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -69,11 +69,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710888565,
|
||||
"narHash": "sha256-s9Hi4RHhc6yut4EcYD50sZWRDKsugBJHSbON8KFwoTw=",
|
||||
"lastModified": 1714043624,
|
||||
"narHash": "sha256-Xn2r0Jv95TswvPlvamCC46wwNo8ALjRCMBJbGykdhcM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "f33900124c23c4eca5831b9b5eb32ea5894375ce",
|
||||
"rev": "86853e31dc1b62c6eeed11c667e8cdd0285d4411",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -105,11 +105,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1712159163,
|
||||
"narHash": "sha256-dOQAAr9adh00rlCg/eq6GwXo+pH0VC7RyE5uWzzAFLo=",
|
||||
"lastModified": 1714679241,
|
||||
"narHash": "sha256-Ufz2WBGCcqeXkVgD7bdc+JCrnyPt6G28Xpq2ussqygs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "67e2bc037137e4fdcf6b3132a4f54c165726500b",
|
||||
"rev": "a6f8947d5a77b88ff43625408e2685c0be100a9b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -120,11 +120,11 @@
|
|||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1711668574,
|
||||
"narHash": "sha256-u1dfs0ASQIEr1icTVrsKwg2xToIpn7ZXxW3RHfHxshg=",
|
||||
"lastModified": 1714531828,
|
||||
"narHash": "sha256-ILsf3bdY/hNNI/Hu5bSt2/KbmHaAVhBbNUOdGztTHEg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "219951b495fc2eac67b1456824cc1ec1fd2ee659",
|
||||
"rev": "0638fe2715d998fa81d173aad264eb671ce2ebc1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -198,11 +198,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1711855048,
|
||||
"narHash": "sha256-HxegAPnQJSC4cbEbF4Iq3YTlFHZKLiNTk8147EbLdGg=",
|
||||
"lastModified": 1713892811,
|
||||
"narHash": "sha256-uIGmA2xq41vVFETCF1WW4fFWFT2tqBln+aXnWrvjGRE=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "99b1e37f9fc0960d064a7862eb7adfb92e64fa10",
|
||||
"rev": "f1b0adc27265274e3b0c9b872a8f476a098679bd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
17
nvim/basics.lua
Normal file
17
nvim/basics.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
vim.opt.termguicolors = true
|
||||
vim.cmd[[colorscheme modus_operandi]]
|
||||
|
||||
HOME = os.getenv("HOME")
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.scrolloff=10
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.clipboard = 'unnamedplus'
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
|
||||
vim.opt.shortmess :append("I")
|
84
nvim/completion.lua
Normal file
84
nvim/completion.lua
Normal file
|
@ -0,0 +1,84 @@
|
|||
local luasnip = require("luasnip")
|
||||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-k>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<C-j>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
formatting = {
|
||||
},
|
||||
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require'luasnip'.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
experimental = {
|
||||
native_menu = false,
|
||||
ghost_text = true
|
||||
},
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
4
nvim/lspconfig.lua
Normal file
4
nvim/lspconfig.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
require'lspconfig'.gopls.setup{capabilities=capabilities}
|
||||
require'lspconfig'.rnix.setup{capabilities=capabilities}
|
3
nvim/lualine.lua
Normal file
3
nvim/lualine.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
require('lualine').setup({options = {
|
||||
theme = "onelight"
|
||||
}})
|
1
nvim/luasnip.lua
Normal file
1
nvim/luasnip.lua
Normal file
|
@ -0,0 +1 @@
|
|||
local ls = require("luasnip")
|
21
nvim/telescope.lua
Normal file
21
nvim/telescope.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
require('telescope').setup{
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true,
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
},
|
||||
project = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require('telescope').load_extension('fzf')
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
61
nvim/treesitter.lua
Normal file
61
nvim/treesitter.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
require'nvim-treesitter.configs'.setup {
|
||||
sync_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn", -- set to `false` to disable one of the mappings
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
},
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
['aa'] = '@parameter.outer',
|
||||
['ia'] = '@parameter.inner',
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
},
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
goto_next_start = {
|
||||
[']m'] = '@function.outer',
|
||||
[']]'] = '@class.outer',
|
||||
},
|
||||
goto_next_end = {
|
||||
[']M'] = '@function.outer',
|
||||
[']['] = '@class.outer',
|
||||
},
|
||||
goto_previous_start = {
|
||||
['[m'] = '@function.outer',
|
||||
['[['] = '@class.outer',
|
||||
},
|
||||
goto_previous_end = {
|
||||
['[M'] = '@function.outer',
|
||||
['[]'] = '@class.outer',
|
||||
},
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
['<leader>a'] = '@parameter.inner',
|
||||
},
|
||||
swap_previous = {
|
||||
['<leader>A'] = '@parameter.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
indent = { enable = true }
|
||||
}
|
Loading…
Reference in a new issue