2024-08-03 18:17:31 +02:00
|
|
|
{ pkgs, ... }:
|
2023-08-30 03:00:47 +02:00
|
|
|
|
2023-06-11 15:33:54 +02:00
|
|
|
{
|
2024-11-18 09:01:44 +01:00
|
|
|
stylix.targets.neovim.plugin = "base16-nvim";
|
|
|
|
|
2023-06-16 14:19:22 +02:00
|
|
|
programs.neovim = {
|
|
|
|
enable = true;
|
2024-04-18 19:43:49 +02:00
|
|
|
defaultEditor = true;
|
2024-04-18 18:48:34 +02:00
|
|
|
|
|
|
|
extraPackages = with pkgs; [
|
|
|
|
nodePackages.typescript-language-server
|
|
|
|
nodePackages."@astrojs/language-server"
|
|
|
|
nodePackages."@prisma/language-server"
|
|
|
|
emmet-language-server
|
2024-05-15 23:39:06 +02:00
|
|
|
markdown-oxide
|
2024-04-18 18:48:34 +02:00
|
|
|
tailwindcss-language-server
|
|
|
|
vscode-langservers-extracted
|
|
|
|
rust-analyzer
|
|
|
|
texlab
|
2024-08-03 03:10:35 +02:00
|
|
|
nixd
|
2024-05-20 19:12:54 +02:00
|
|
|
universal-ctags
|
2024-04-18 18:48:34 +02:00
|
|
|
];
|
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
extraConfig = # vim
|
|
|
|
''
|
|
|
|
filetype plugin indent on
|
2024-10-13 23:55:58 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
set undofile
|
|
|
|
set spell
|
|
|
|
set number
|
|
|
|
set linebreak
|
|
|
|
set clipboard=unnamedplus
|
2024-08-09 17:11:31 +02:00
|
|
|
set fileencoding=utf-8
|
|
|
|
set fileencodings=utf-8,sjis
|
|
|
|
set spelllang=en_us,cjk
|
|
|
|
set noshowmode
|
2024-08-03 20:22:47 +02:00
|
|
|
set mouse=a
|
2024-08-09 17:11:31 +02:00
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
|
|
|
set scrolloff=1
|
|
|
|
set sidescrolloff=5
|
2024-08-03 20:22:47 +02:00
|
|
|
|
|
|
|
set foldmethod=indent
|
|
|
|
set foldlevelstart=99
|
|
|
|
|
|
|
|
map <MiddleMouse> <Nop>
|
|
|
|
imap <MiddleMouse> <Nop>
|
|
|
|
map <2-MiddleMouse> <Nop>
|
|
|
|
imap <2-MiddleMouse> <Nop>
|
|
|
|
map <3-MiddleMouse> <Nop>
|
|
|
|
imap <3-MiddleMouse> <Nop>
|
|
|
|
map <4-MiddleMouse> <Nop>
|
|
|
|
imap <4-MiddleMouse> <Nop>
|
|
|
|
|
|
|
|
highlight Search ctermbg=240 ctermfg=255
|
|
|
|
highlight IncSearch ctermbg=255 ctermfg=240
|
2024-08-10 00:09:02 +02:00
|
|
|
highlight Folded ctermbg=NONE guibg=NONE
|
2024-08-03 20:22:47 +02:00
|
|
|
|
|
|
|
let mapleader = ' '
|
2024-10-13 23:55:58 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
nnoremap <silent> <leader>e :set nu!<CR>
|
|
|
|
nnoremap <silent> <leader>o :GitBlameToggle<CR>
|
|
|
|
nnoremap <silent> <leader>a :NvimTreeFocus<CR>
|
|
|
|
nnoremap <silent> <leader>d :bp\|bd #<CR>
|
|
|
|
nnoremap <silent> <leader>f :Files<CR>
|
|
|
|
nnoremap <silent> <leader>g :set hlsearch!<CR>
|
|
|
|
nnoremap <silent> <leader>j :Buffers<CR>
|
|
|
|
nnoremap <silent> <leader>l :Rg<CR>
|
|
|
|
nnoremap <silent> <leader>; :NvimTreeToggle<CR>
|
|
|
|
nnoremap <silent> <leader>b :Vista!!<CR>
|
|
|
|
|
|
|
|
autocmd BufWritePre,FileWritePre * silent! call mkdir(expand('<afile>:p:h'), 'p')
|
|
|
|
autocmd VimEnter * silent! :cd `git rev-parse --show-toplevel`
|
|
|
|
|
|
|
|
tnoremap <C-space> <C-\><C-n>
|
|
|
|
'';
|
2023-06-27 00:35:00 +02:00
|
|
|
|
2024-04-18 16:48:15 +02:00
|
|
|
plugins = with pkgs.vimPlugins; [
|
2023-06-16 14:19:22 +02:00
|
|
|
{
|
|
|
|
plugin = nvim-tree-lua;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
2024-09-09 03:53:31 +02:00
|
|
|
require("nvim-tree").setup {
|
|
|
|
update_focused_file = {
|
|
|
|
enable = true
|
|
|
|
}
|
|
|
|
}
|
2023-06-06 13:18:59 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
vim.api.nvim_create_autocmd({"QuitPre"}, {
|
|
|
|
callback = function()
|
|
|
|
vim.cmd("NvimTreeClose")
|
|
|
|
end
|
|
|
|
})
|
2023-06-06 13:27:04 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
local function open_nvim_tree(data)
|
|
|
|
local real_file = vim.fn.filereadable(data.file) == 1
|
|
|
|
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
2023-06-06 13:27:04 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
if not real_file and not no_name then
|
|
|
|
return
|
|
|
|
end
|
2023-06-06 13:27:04 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
require("nvim-tree.api").tree.toggle({ focus = false, find_file = true })
|
|
|
|
end
|
2023-06-06 13:27:04 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = indent-blankline-nvim;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require("ibl").setup()
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = gitsigns-nvim;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require('gitsigns').setup()
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = nvim-web-devicons;
|
|
|
|
type = "lua";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = nvim-scrollbar;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require("scrollbar").setup()
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = nvim-lspconfig;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
local lspconfig = require('lspconfig')
|
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
2024-03-30 16:30:33 +01:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
lspconfig.eslint.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
|
|
buffer = bufnr,
|
|
|
|
command = "EslintFixAll",
|
|
|
|
})
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
lspconfig.tailwindcss.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
require("tailwindcss-colors").buf_attach(bufnr)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2024-10-15 22:47:31 +02:00
|
|
|
lspconfig.nixd.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
offset_encoding = 'utf-8'
|
|
|
|
}
|
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
|
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
|
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
|
|
|
|
|
|
|
callback = function(ev)
|
|
|
|
local opts = { buffer = ev.buf }
|
|
|
|
|
|
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
|
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
|
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
|
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
|
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
|
|
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
|
|
|
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
|
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
|
|
|
vim.lsp.handlers.hover, { border = "single" }
|
|
|
|
)
|
|
|
|
|
|
|
|
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
|
|
|
vim.lsp.handlers.signature_help, { border = "single" }
|
|
|
|
)
|
|
|
|
|
|
|
|
vim.diagnostic.config {
|
|
|
|
float = { border = "single" }
|
|
|
|
}
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
2023-12-03 13:59:48 +01:00
|
|
|
{
|
|
|
|
plugin = nvim-cmp;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
|
|
local lspconfig = require('lspconfig')
|
|
|
|
|
|
|
|
local servers = {
|
|
|
|
'rust_analyzer',
|
|
|
|
'markdown_oxide',
|
|
|
|
'html',
|
|
|
|
'texlab',
|
|
|
|
'prismals',
|
|
|
|
'jsonls',
|
|
|
|
'emmet_language_server',
|
|
|
|
'astro',
|
|
|
|
'cssls',
|
2024-10-06 13:28:00 +02:00
|
|
|
'ts_ls',
|
2023-12-03 13:59:48 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
lspconfig[lsp].setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
}
|
|
|
|
end
|
2023-12-03 13:59:48 +01:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
local luasnip = require('luasnip')
|
|
|
|
local cmp = require('cmp')
|
|
|
|
|
|
|
|
cmp.setup {
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
luasnip.lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
2024-09-01 20:11:59 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
['<CR>'] = cmp.mapping.confirm {
|
|
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
|
|
select = true,
|
|
|
|
},
|
2024-09-01 20:11:59 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
['<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' }),
|
2024-09-01 20:11:59 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
['<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' }),
|
|
|
|
}),
|
2024-09-01 20:11:59 +02:00
|
|
|
|
2024-08-03 20:22:47 +02:00
|
|
|
sources = {
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'luasnip' },
|
2023-12-03 13:59:48 +01:00
|
|
|
},
|
2024-08-03 20:22:47 +02:00
|
|
|
}
|
|
|
|
'';
|
2023-12-03 13:59:48 +01:00
|
|
|
}
|
|
|
|
cmp-nvim-lsp
|
|
|
|
cmp_luasnip
|
2023-12-03 21:39:14 +01:00
|
|
|
{
|
|
|
|
plugin = luasnip;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
|
|
'';
|
2023-12-03 21:39:14 +01:00
|
|
|
}
|
|
|
|
friendly-snippets
|
2023-06-16 14:19:22 +02:00
|
|
|
{
|
|
|
|
plugin = lualine-nvim;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
local theme = require("lualine.themes.base16")
|
|
|
|
theme.normal.b.bg = nil
|
|
|
|
theme.normal.c.bg = nil
|
|
|
|
theme.replace.b.bg = nil
|
|
|
|
theme.insert.b.bg = nil
|
|
|
|
theme.visual.b.bg = nil
|
|
|
|
theme.inactive.a.bg = nil
|
|
|
|
theme.inactive.b.bg = nil
|
|
|
|
theme.inactive.c.bg = nil
|
|
|
|
|
|
|
|
require('lualine').setup {
|
|
|
|
options = {
|
|
|
|
theme = theme,
|
|
|
|
disabled_filetypes = {'NvimTree', 'tagbar'}
|
|
|
|
},
|
|
|
|
sections = { lualine_c = {'%f'} }
|
|
|
|
}
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = git-blame-nvim;
|
|
|
|
type = "lua";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = comment-nvim;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require('Comment').setup {
|
|
|
|
pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook()
|
|
|
|
}
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
2023-07-20 00:19:22 +02:00
|
|
|
{
|
|
|
|
plugin = nvim-autopairs;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require("nvim-autopairs").setup()
|
|
|
|
'';
|
2023-07-26 16:00:42 +02:00
|
|
|
}
|
2023-06-16 14:19:22 +02:00
|
|
|
{
|
|
|
|
plugin = auto-save-nvim;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require("auto-save").setup()
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = vimtex;
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # vim
|
|
|
|
''
|
|
|
|
let g:vimtex_mappings_enabled = 0
|
|
|
|
let g:vimtex_imaps_enabled = 0
|
|
|
|
let g:vimtex_view_method = 'zathura'
|
|
|
|
let g:vimtex_compiler_latexmk = {'out_dir': '/tmp/vimtex'}
|
|
|
|
|
|
|
|
nnoremap <localleader>f <plug>(vimtex-view)
|
|
|
|
nnoremap <localleader>g <plug>(vimtex-compile)
|
|
|
|
nnoremap <localleader>d <plug>(vimtex-env-delete)
|
|
|
|
nnoremap <localleader>c <plug>(vimtex-env-change)
|
|
|
|
'';
|
2023-06-16 14:19:22 +02:00
|
|
|
}
|
2023-12-03 21:44:56 +01:00
|
|
|
{
|
|
|
|
plugin = nvim-ts-autotag;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require('nvim-ts-autotag').setup()
|
|
|
|
'';
|
2023-12-03 21:44:56 +01:00
|
|
|
}
|
2023-12-21 00:19:10 +01:00
|
|
|
{
|
|
|
|
plugin = nvim-surround;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require('nvim-surround').setup()
|
|
|
|
'';
|
2023-12-21 00:19:10 +01:00
|
|
|
}
|
2023-12-30 01:44:28 +01:00
|
|
|
{
|
|
|
|
plugin = tailwindcss-colors-nvim;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require('tailwindcss-colors').setup()
|
|
|
|
'';
|
2023-12-30 01:44:28 +01:00
|
|
|
}
|
2023-12-30 23:36:13 +01:00
|
|
|
{
|
|
|
|
plugin = nvim-ts-context-commentstring;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
|
|
|
require('ts_context_commentstring').setup {
|
|
|
|
enable_autocmd = false,
|
|
|
|
}
|
|
|
|
'';
|
2023-12-30 23:36:13 +01:00
|
|
|
}
|
2024-01-12 10:26:01 +01:00
|
|
|
{
|
|
|
|
plugin = nvim-treesitter.withAllGrammars;
|
|
|
|
type = "lua";
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # lua
|
|
|
|
''
|
2024-08-22 22:44:11 +02:00
|
|
|
require('nvim-treesitter.configs').setup {
|
2024-08-03 20:22:47 +02:00
|
|
|
highlight = {
|
|
|
|
enable = true,
|
|
|
|
disable = function(lang)
|
|
|
|
return lang ~= "javascript"
|
|
|
|
and lang ~= "tsx"
|
|
|
|
and lang ~= "typescript"
|
|
|
|
and lang ~= "astro"
|
|
|
|
and lang ~= "css"
|
|
|
|
and lang ~= "glsl"
|
|
|
|
and lang ~= "nix"
|
|
|
|
and lang ~= "prisma"
|
2024-10-16 08:25:55 +02:00
|
|
|
and lang ~= "markdown"
|
2024-08-03 20:22:47 +02:00
|
|
|
end,
|
|
|
|
additional_vim_regex_highlighting = true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
'';
|
2024-01-12 10:26:01 +01:00
|
|
|
}
|
2024-03-09 17:45:33 +01:00
|
|
|
{
|
|
|
|
plugin = vista-vim;
|
2024-08-03 20:22:47 +02:00
|
|
|
config = # vim
|
|
|
|
''
|
|
|
|
let g:vista_default_executive = 'nvim_lsp'
|
|
|
|
let g:vista_executive_for = {
|
|
|
|
\ 'rust': 'ctags',
|
|
|
|
\ }
|
|
|
|
|
|
|
|
autocmd QuitPre * silent! :Vista!
|
|
|
|
'';
|
2024-03-09 17:45:33 +01:00
|
|
|
}
|
2023-06-16 14:19:22 +02:00
|
|
|
fzf-vim
|
|
|
|
vim-graphql
|
|
|
|
vim-javascript
|
2024-04-29 19:38:29 +02:00
|
|
|
vim-jsx-pretty
|
2023-06-16 14:19:22 +02:00
|
|
|
rust-vim
|
|
|
|
neoformat
|
2024-04-18 16:48:15 +02:00
|
|
|
vim-nix
|
2023-12-02 19:33:26 +01:00
|
|
|
tagbar
|
2024-04-01 21:03:18 +02:00
|
|
|
rainbow-delimiters-nvim
|
2023-06-16 14:19:22 +02:00
|
|
|
];
|
|
|
|
};
|
2023-05-17 01:10:15 +02:00
|
|
|
}
|