commit a40e6a97354caf8243b470525cf737022f794caf Author: Daniel Kempkens Date: Mon Dec 6 23:35:29 2021 +0100 Initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/config/nvim/after/ftplugin/NvimTree.vim b/config/nvim/after/ftplugin/NvimTree.vim new file mode 100644 index 0000000..3b9b72a --- /dev/null +++ b/config/nvim/after/ftplugin/NvimTree.vim @@ -0,0 +1 @@ +setlocal signcolumn=no diff --git a/config/nvim/after/ftplugin/elixir.vim b/config/nvim/after/ftplugin/elixir.vim new file mode 100644 index 0000000..97b21a0 --- /dev/null +++ b/config/nvim/after/ftplugin/elixir.vim @@ -0,0 +1,6 @@ +setlocal comments=:# +setlocal commentstring=#\ %s + +setlocal spell +setlocal textwidth=120 +setlocal colorcolumn=+1 diff --git a/config/nvim/after/ftplugin/erlang.vim b/config/nvim/after/ftplugin/erlang.vim new file mode 100644 index 0000000..0e49e55 --- /dev/null +++ b/config/nvim/after/ftplugin/erlang.vim @@ -0,0 +1 @@ +iabbrev <= =< diff --git a/config/nvim/after/ftplugin/gitcommit.vim b/config/nvim/after/ftplugin/gitcommit.vim new file mode 100644 index 0000000..cebe5e6 --- /dev/null +++ b/config/nvim/after/ftplugin/gitcommit.vim @@ -0,0 +1,2 @@ +setlocal spell +setlocal colorcolumn=+1 diff --git a/config/nvim/after/ftplugin/list.vim b/config/nvim/after/ftplugin/list.vim new file mode 100644 index 0000000..f20b088 --- /dev/null +++ b/config/nvim/after/ftplugin/list.vim @@ -0,0 +1,6 @@ +setlocal nonumber norelativenumber + +nnoremap :q! +nnoremap q :q! + +let b:toggle_line_style = v:false diff --git a/config/nvim/after/ftplugin/make.vim b/config/nvim/after/ftplugin/make.vim new file mode 100644 index 0000000..caf8fe2 --- /dev/null +++ b/config/nvim/after/ftplugin/make.vim @@ -0,0 +1,3 @@ +setlocal noexpandtab +setlocal shiftwidth=2 +setlocal softtabstop=0 diff --git a/config/nvim/after/ftplugin/markdown.vim b/config/nvim/after/ftplugin/markdown.vim new file mode 100644 index 0000000..bcda2dd --- /dev/null +++ b/config/nvim/after/ftplugin/markdown.vim @@ -0,0 +1 @@ +setlocal spell diff --git a/config/nvim/after/ftplugin/pandoc.vim b/config/nvim/after/ftplugin/pandoc.vim new file mode 100644 index 0000000..bcda2dd --- /dev/null +++ b/config/nvim/after/ftplugin/pandoc.vim @@ -0,0 +1 @@ +setlocal spell diff --git a/config/nvim/after/ftplugin/qf.vim b/config/nvim/after/ftplugin/qf.vim new file mode 100644 index 0000000..f20b088 --- /dev/null +++ b/config/nvim/after/ftplugin/qf.vim @@ -0,0 +1,6 @@ +setlocal nonumber norelativenumber + +nnoremap :q! +nnoremap q :q! + +let b:toggle_line_style = v:false diff --git a/config/nvim/after/ftplugin/text.vim b/config/nvim/after/ftplugin/text.vim new file mode 100644 index 0000000..bcda2dd --- /dev/null +++ b/config/nvim/after/ftplugin/text.vim @@ -0,0 +1 @@ +setlocal spell diff --git a/config/nvim/after/queries/elixir/matchup.scm b/config/nvim/after/queries/elixir/matchup.scm new file mode 100644 index 0000000..17b87c3 --- /dev/null +++ b/config/nvim/after/queries/elixir/matchup.scm @@ -0,0 +1,36 @@ +; Function definition +(call target: ((identifier) @open.def (#any-of? @open.def "def" "defp")) + (do_block + [(rescue_block "rescue" @mid.def.1) + (catch_block "catch" @mid.def.2)]? + "end" @close.def)) @scope.def + +; case/cond clause +(call target: ((identifier) @open.case (#any-of? @open.case "case" "cond")) + (do_block + "end" @close.case)) @scope.case + +; if/with clause +(call target: ((identifier) @open.if (#any-of? @open.if "if" "with")) + (do_block + (else_block "else" @mid.else.1)? + "end" @close.if)) @scope.if + +; try clause +(call target: ((identifier) @open.try (#eq? @open.try "try")) + (do_block + [(rescue_block "rescue" @mid.try.1) + (catch_block "catch" @mid.try.2) + (after_block "after" @mid.try.3)]? + "end" @close.try)) @scope.try + +; receive clause +(call target: ((identifier) @open.receive (#eq? @open.receive "receive")) + (do_block + (after_block "after" @mid.receive.1)? + "end" @close.receive)) @scope.receive + +; for comprehension +(call target: ((identifier) @open.for (#eq? @open.for "for")) + (do_block + "end" @close.for)) @scope.for diff --git a/config/nvim/efm.yml b/config/nvim/efm.yml new file mode 100644 index 0000000..3447f28 --- /dev/null +++ b/config/nvim/efm.yml @@ -0,0 +1,78 @@ +version: 2 +root-markers: + - .git/ + - flake.nix +lint-debounce: '200ms' + +tools: + dockerfile-hadolint: &dockerfile-hadolint + lint-command: 'efm-hadolint' + lint-formats: + - '%f:%l:%trror: %m' + - '%f:%l:%tarning: %m' + - '%f:%l:%tnfo: %m' + - '%f:%l:%ttyle: %m' + + elixir-credo: &elixir-credo + lint-command: > + mix credo suggest --all-priorities --format flycheck --read-from-stdin ${INPUT} | + sed "s/ R:/ H:/; s/ D:/ I:/; s/ C:/ W:/" + lint-stdin: true + lint-formats: + - '%f:%l:%c: %t: %m' + - '%f:%l: %t: %m' + root-markers: + - mix.lock + - mix.exs + + eruby-erb: &eruby-erb + lint-command: 'erb -x -T - | ruby -c' + lint-stdin: true + lint-offset: 1 + + fish-indent: &fish-indent + format-command: 'fish_indent' + format-stdin: true + + javascript-eslint: &javascript-eslint + lint-command: 'eslint_d -f visualstudio --stdin --stdin-filename ${INPUT}' + lint-ignore-exit-code: true + lint-stdin: true + lint-formats: + - "%f(%l,%c): %tarning %m" + - "%f(%l,%c): %rror %m" + format-command: 'eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}' + format-stdin: true + root-markers: + - .eslintrc.js + + sh-shfmt: &sh-shfmt + format-command: 'shfmt -i 2' + format-stdin: true + + sh-shellcheck: &sh-shellcheck + lint-command: 'shellcheck -f gcc -x' + lint-formats: + - '%f:%l:%c: %trror: %m' + - '%f:%l:%c: %tarning: %m' + - '%f:%l:%c: %tote: %m' + +languages: + dockerfile: + - <<: *dockerfile-hadolint + + elixir: + - <<: *elixir-credo + + eruby: + - <<: *eruby-erb + + fish: + - <<: *fish-indent + + javascript: + - <<: *javascript-eslint + + sh: + - <<: *sh-shellcheck + - <<: *sh-shfmt diff --git a/config/nvim/lua/nifoc/config/autopairs.lua b/config/nvim/lua/nifoc/config/autopairs.lua new file mode 100644 index 0000000..9c5157a --- /dev/null +++ b/config/nvim/lua/nifoc/config/autopairs.lua @@ -0,0 +1,5 @@ +local npairs = require('nvim-autopairs') + +npairs.setup({ + check_ts = true, +}) diff --git a/config/nvim/lua/nifoc/config/bufferline.lua b/config/nvim/lua/nifoc/config/bufferline.lua new file mode 100644 index 0000000..cf43aa0 --- /dev/null +++ b/config/nvim/lua/nifoc/config/bufferline.lua @@ -0,0 +1,5 @@ +require('bufferline').setup{ + options = { + show_close_icon = false, + } +} diff --git a/config/nvim/lua/nifoc/config/colorizer.lua b/config/nvim/lua/nifoc/config/colorizer.lua new file mode 100644 index 0000000..746f7b8 --- /dev/null +++ b/config/nvim/lua/nifoc/config/colorizer.lua @@ -0,0 +1,7 @@ +require('colorizer').setup { + 'css'; + 'html'; + 'lua'; + 'svelte'; + 'vim' +} diff --git a/config/nvim/lua/nifoc/config/comments.lua b/config/nvim/lua/nifoc/config/comments.lua new file mode 100644 index 0000000..6232ee9 --- /dev/null +++ b/config/nvim/lua/nifoc/config/comments.lua @@ -0,0 +1,3 @@ +require('Comment').setup { + padding = true, +} diff --git a/config/nvim/lua/nifoc/config/completion.lua b/config/nvim/lua/nifoc/config/completion.lua new file mode 100644 index 0000000..3d29f07 --- /dev/null +++ b/config/nvim/lua/nifoc/config/completion.lua @@ -0,0 +1,132 @@ +local cmp = require('cmp') +local luasnip = require('luasnip') +local lspkind = require('lspkind') +local cmp_autopairs = require('nvim-autopairs.completion.cmp') + +-- Helper functions +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 + +cmp.setup { + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'nvim_lua' }, + }, { + { name = 'treesitter' }, + { name = 'buffer' }, + { name = 'path' }, + }), + + mapping = { + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + + [''] = cmp.mapping({ + c = function() + if cmp.visible() then + cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert }) + else + cmp.complete() + end + end, + + i = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, + + s = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, + }), + + [''] = cmp.mapping({ + c = function() + if cmp.visible() then + cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert }) + else + cmp.complete() + end + end, + + i = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + + s = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + }), + + [''] = cmp.mapping.confirm({ select = true }), + }, + + completion = { + keyword_length = 2, + completeopt = 'menu,menuone,noinsert', + }, + + documentation = { + border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, + }, + + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + + formatting = { + format = lspkind.cmp_format(), + }, +} + +cmp.setup.cmdline('/', { + sources = cmp.config.sources({ + { name = 'nvim_lsp_document_symbol' } + }, { + { name = 'buffer' } + }) +}) + +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + +cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) diff --git a/config/nvim/lua/nifoc/config/cursorline.lua b/config/nvim/lua/nifoc/config/cursorline.lua new file mode 100644 index 0000000..1d6e091 --- /dev/null +++ b/config/nvim/lua/nifoc/config/cursorline.lua @@ -0,0 +1,5 @@ +vim.cmd('augroup nifoc_cusorline') + vim.cmd('autocmd!') + vim.cmd('autocmd FileType TelescopePrompt setlocal nocursorline') + vim.cmd('autocmd FileType NvimTree let b:auto_cursorline_disabled = 1') +vim.cmd('augroup end') diff --git a/config/nvim/lua/nifoc/config/fterm.lua b/config/nvim/lua/nifoc/config/fterm.lua new file mode 100644 index 0000000..0c1e0f4 --- /dev/null +++ b/config/nvim/lua/nifoc/config/fterm.lua @@ -0,0 +1,3 @@ +require('FTerm').setup { + border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' } +} diff --git a/config/nvim/lua/nifoc/config/gitsigns.lua b/config/nvim/lua/nifoc/config/gitsigns.lua new file mode 100644 index 0000000..c52315b --- /dev/null +++ b/config/nvim/lua/nifoc/config/gitsigns.lua @@ -0,0 +1,24 @@ +local ns = require('nifoc.utils.statusline') + +--local theme_config = require('tokyonight.config') +--local theme_colors = require('tokyonight.colors').setup(theme_config) + +--vim.cmd('highlight GitSignsStatuslineAdd guifg=' .. theme_colors.git.add .. ' guibg=#3b4261') +--vim.cmd('highlight GitSignsStatuslineChange guifg=' .. theme_colors.git.change .. ' guibg=#3b4261') +--vim.cmd('highlight GitSignsStatuslineDelete guifg=' .. theme_colors.red .. ' guibg=#3b4261') + +require('gitsigns').setup { + signs = { + add = {hl = 'GitSignsAdd', text = '│', numhl='GitSignsAddNr', linehl='GitSignsAddLn'}, + change = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + topdelete = {hl = 'GitSignsDelete', text = '‾', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + }, + numhl = false, + linehl = false, + status_formatter = ns.gitsigns_formatter, + diff_opts = { + internal = true, + }, +} diff --git a/config/nvim/lua/nifoc/config/illuminate.lua b/config/nvim/lua/nifoc/config/illuminate.lua new file mode 100644 index 0000000..2d69fe6 --- /dev/null +++ b/config/nvim/lua/nifoc/config/illuminate.lua @@ -0,0 +1,6 @@ +vim.g.Illuminate_ftblacklist = { + 'minimap', + 'netrw', + 'NvimTree', + 'packer', +} diff --git a/config/nvim/lua/nifoc/config/indent_line.lua b/config/nvim/lua/nifoc/config/indent_line.lua new file mode 100644 index 0000000..8b2d53c --- /dev/null +++ b/config/nvim/lua/nifoc/config/indent_line.lua @@ -0,0 +1,25 @@ +require('indent_blankline').setup { + char = '¦', + show_first_indent_level = false, + use_treesitter = true, + show_current_context = true, + + context_patterns = { + 'class', + 'function', + 'method', + 'do_block', + 'stab_clause', + }, + + buftype_exclude = { + 'help', + 'nofile', + 'terminal', + }, + + filetype_exclude = { + 'minimap', + 'packer', + }, +} diff --git a/config/nvim/lua/nifoc/config/lsp.lua b/config/nvim/lua/nifoc/config/lsp.lua new file mode 100644 index 0000000..74d866b --- /dev/null +++ b/config/nvim/lua/nifoc/config/lsp.lua @@ -0,0 +1,184 @@ +local lsp = require('lspconfig') +local lsp_status = require('lsp-status') +local illuminate = require('illuminate') +local keymap = require('nifoc.keymap') + +local function enable_lsp_fixer(_) + vim.cmd [[ + augroup nifoc_lsp_formatting + autocmd! * + autocmd BufWritePre lua vim.lsp.buf.formatting_sync(nil, 1000) + augroup end + ]] +end + +local function custom_attach(client, bufnr) + -- Plugin attachments + lsp_status.on_attach(client) + keymap.lsp_attach(client, bufnr) + + if client.resolved_capabilities.document_highlight then + illuminate.on_attach(client) + end + + if vim.b.nifoc_lsp_enabled == nil then + vim.api.nvim_buf_set_var(bufnr, 'nifoc_lsp_enabled', 1) + vim.cmd("setlocal omnifunc=v:lua.vim.lsp.omnifunc") + end + + if client.resolved_capabilities.document_formatting and vim.b.nifoc_fixer_enabled == nil then + vim.api.nvim_buf_set_var(bufnr, 'nifoc_fixer_enabled', 1) + + enable_lsp_fixer(client) + end + + vim.api.nvim_command('doautocmd User NifocLspAttached') +end + +-- Setup + +vim.cmd('sign define LspDiagnosticsSignError text= texthl=LspDiagnosticsSignError linehl= numhl=') +vim.cmd('sign define LspDiagnosticsSignWarning text= texthl=LspDiagnosticsSignWarning linehl= numhl=') +vim.cmd('sign define LspDiagnosticsSignInformation text= texthl=LspDiagnosticsSignInformation linehl= numhl=') +vim.cmd('sign define LspDiagnosticsSignHint text= texthl=LspDiagnosticsSignHint linehl= numhl=') + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + underline = true, + virtual_text = { + prefix = '■ ', + spacing = 4, + }, + signs = false, + update_in_insert = false, + } +) + +lsp_status.register_progress() + +-- Default configuration + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) +capabilities = vim.tbl_extend('keep', capabilities, lsp_status.capabilities) + +local flags = { + allow_incremental_sync = true, + debounce_text_changes = 700, +} + +local default_config = { + on_attach = custom_attach, + capabilities = capabilities, + flags = flags, +} + +local default_servers = { + 'angularls', + 'bashls', + 'cssls', + 'dockerls', + 'html', + 'rnix', + 'sqls', + 'taplo', + 'yamlls' +} + +for _, name in ipairs(default_servers) do + lsp[name].setup(default_config) +end + +-- Default configuration without formatting + +local default_servers_no_formatting = { + 'tsserver' +} + +for _, name in ipairs(default_servers_no_formatting) do + lsp[name].setup(vim.tbl_extend('force', default_config, { + on_attach = function(client, bufnr) + client.resolved_capabilities.document_formatting = false + custom_attach(client, bufnr) + end, + })) +end + +-- Custom configuration + +lsp.elixirls.setup(vim.tbl_extend('force', default_config, { + cmd = { 'elixir-ls' }, +})) + +lsp.jsonls.setup(vim.tbl_extend('force', default_config, { + cmd = { 'vscode-json-language-server', '--stdio' }, +})) + +lsp.solargraph.setup(vim.tbl_extend('force', default_config, { + settings = { + solargraph = { + diagnostics = true, + }, + }, +})) + +lsp.sumneko_lua.setup(vim.tbl_extend('force', default_config, { + cmd = { + vim.fn.globpath('~', 'Code/LSP/lua/bin/macOS/lua-language-server'), + '-E', + vim.fn.globpath('~', 'Code/LSP/lua/main.lua') + }, + root_dir = lsp.util.root_pattern("init.vim", "init.lua", ".git") or vim.loop.os_homedir(), + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + path = vim.split(package.path, ';'), + }, + diagnostics = { + globals = {'vim', 'use'}, + }, + workspace = { + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + }, + }, + telemetry = {enable = false}, + }, + }, +})) + +-- Try to start efm as the last language server + +lsp.efm.setup(vim.tbl_extend('force', default_config, { + cmd = { + 'efm-langserver', + '-c', + vim.fn.globpath('~', '.config/nvim/efm.yml'), + }, + filetypes = { + 'dockerfile', + 'elixir', + 'fish', + 'javascript', + 'sh', + }, + on_attach = function(client, bufnr) + local disable_formatter_ft = { 'dockerfile', 'elixir' } + local slow_ft = {} + + if vim.tbl_contains(disable_formatter_ft, vim.bo.filetype) then + client.resolved_capabilities.document_formatting = false + end + + if vim.tbl_contains(slow_ft, vim.bo.filetype) then + client.resolved_capabilities.text_document_did_change = vim.lsp.protocol.TextDocumentSyncKind.None + end + + client.resolved_capabilities.document_symbol = false + client.resolved_capabilities.workspace_symbol = false + + custom_attach(client, bufnr) + end, +})) diff --git a/config/nvim/lua/nifoc/config/lsp_trouble.lua b/config/nvim/lua/nifoc/config/lsp_trouble.lua new file mode 100644 index 0000000..0731c19 --- /dev/null +++ b/config/nvim/lua/nifoc/config/lsp_trouble.lua @@ -0,0 +1,7 @@ +require('trouble').setup { + action_keys = { + previous = "", + next = "", + }, + use_lsp_diagnostic_signs = true +} diff --git a/config/nvim/lua/nifoc/config/lualine.lua b/config/nvim/lua/nifoc/config/lualine.lua new file mode 100644 index 0000000..ba29522 --- /dev/null +++ b/config/nvim/lua/nifoc/config/lualine.lua @@ -0,0 +1,37 @@ +local ns = require('nifoc.utils.statusline') + +--local theme_config = require('tokyonight.config') +--local theme_colors = require('tokyonight.colors').setup(theme_config) + +require('lualine').setup { + options = { + theme = 'dracula-nvim', + -- section_separators = {'', ''}, + section_separators = '', + -- component_separators = {'', ''}, + component_separators = '|', + icons_enabled = true, + }, + + sections = { + lualine_a = {'mode'}, + lualine_b = { + 'b:gitsigns_status', + { + 'diagnostics', + sources = {'nvim_lsp'}, + --color_error = {fg =theme_colors.error}, + --color_warn = {fg = theme_colors.warning}, + --color_info = {fg = theme_colors.info}, + symbols = {error = ' ', warn = ' ', info = ' '} + }, + }, + lualine_c = {ns.current_function}, + + lualine_x = {'filetype', ns.lsp_enabled, ns.treesitter_enabled, ns.fixer_enabled, ns.spell_enabled}, + lualine_y = {ns.current_line_percent}, + lualine_z = {ns.line_column}, + }, + + extensions = { 'nvim-tree' }, +} diff --git a/config/nvim/lua/nifoc/config/matchup.lua b/config/nvim/lua/nifoc/config/matchup.lua new file mode 100644 index 0000000..f84abca --- /dev/null +++ b/config/nvim/lua/nifoc/config/matchup.lua @@ -0,0 +1,5 @@ +vim.g.matchup_matchparen_deferred = true + +vim.g.matchup_matchparen_offscreen = { + method = 'popup', +} diff --git a/config/nvim/lua/nifoc/config/nvim_tree.lua b/config/nvim/lua/nifoc/config/nvim_tree.lua new file mode 100644 index 0000000..9fb128d --- /dev/null +++ b/config/nvim/lua/nifoc/config/nvim_tree.lua @@ -0,0 +1,30 @@ +require('nvim-tree').setup { + open_on_setup = false, + auto_close = true, + + update_cwd = true, + update_focused_file = { + enable = true, + update_cwd = true + }, + + git = { + enable = true, + ignore = true, + timeout = 500, + }, +} + +vim.g.nvim_tree_quit_on_open = 0 +vim.g.nvim_tree_respect_buf_cwd = 1 +vim.g.nvim_tree_git_hl = 1 +vim.g.nvim_tree_show_icons = { + git = 1, + folders = 1, + files = 1, +} + +vim.cmd('augroup nifoc_nvim_tree_telescope') + vim.cmd('autocmd!') + vim.cmd('autocmd User TelescopeFindPre NvimTreeClose') +vim.cmd('augroup end') diff --git a/config/nvim/lua/nifoc/config/project.lua b/config/nvim/lua/nifoc/config/project.lua new file mode 100644 index 0000000..a9920aa --- /dev/null +++ b/config/nvim/lua/nifoc/config/project.lua @@ -0,0 +1,17 @@ +require('project_nvim').setup { + detection_methods = { "pattern", "lsp" }, + + patterns = { + ".git", + "_darcs", + ".hg", + ".bzr", + ".svn", + ".gitlab-ci.yml", + "flake.nix", + "init.lua", + "Makefile", + "mix.exs", + "package.json", + }, +} diff --git a/config/nvim/lua/nifoc/config/telescope.lua b/config/nvim/lua/nifoc/config/telescope.lua new file mode 100644 index 0000000..82e852f --- /dev/null +++ b/config/nvim/lua/nifoc/config/telescope.lua @@ -0,0 +1,41 @@ +local telescope = require('telescope') +local actions = require('telescope.actions') + +telescope.setup { + defaults = { + prompt_prefix = ' ', + selection_caret = ' ', + set_env = { ['COLORTERM'] = 'truecolor' }, + + layout_strategy = 'horizontal', + layout_config = { + horizontal = { + preview_width = 0.50, + }, + }, + + path_display = {'smart', 'absolute'}, + + mappings = { + i = { + [""] = actions.close + }, + }, + }, + + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + } + }, +} + +telescope.load_extension('fzf') + +vim.cmd('augroup nifoc_telescope') + vim.cmd('autocmd!') + vim.cmd('autocmd User TelescopePreviewerLoaded let w:is_telescope=v:true') +vim.cmd('augroup end') diff --git a/config/nvim/lua/nifoc/config/themes.lua b/config/nvim/lua/nifoc/config/themes.lua new file mode 100644 index 0000000..47e5266 --- /dev/null +++ b/config/nvim/lua/nifoc/config/themes.lua @@ -0,0 +1,9 @@ +-- tokyonight + +vim.g.tokyonight_style = 'night' +vim.g.tokyonight_hide_inactive_statusline = true +vim.g.tokyonight_sidebars = { "qf", "packer" } + +-- dracula + +vim.g.dracula_show_end_of_buffer = false diff --git a/config/nvim/lua/nifoc/config/todo_comments.lua b/config/nvim/lua/nifoc/config/todo_comments.lua new file mode 100644 index 0000000..45b8640 --- /dev/null +++ b/config/nvim/lua/nifoc/config/todo_comments.lua @@ -0,0 +1,3 @@ +require('todo-comments').setup { + signs = false, +} diff --git a/config/nvim/lua/nifoc/config/treesitter.lua b/config/nvim/lua/nifoc/config/treesitter.lua new file mode 100644 index 0000000..ada9cae --- /dev/null +++ b/config/nvim/lua/nifoc/config/treesitter.lua @@ -0,0 +1,48 @@ +local treesitter = require('nvim-treesitter') +local treesitter_config = require('nvim-treesitter.configs') + +-- Custom module +treesitter.define_modules { + nifoc_hooks = { + enable = false, + attach = function(bufnr) + vim.api.nvim_buf_set_var(bufnr, 'nifoc_treesitter_enabled', 1) + end, + detach = function(bufnr) + vim.api.nvim_buf_set_var(bufnr, 'nifoc_treesitter_enabled', 0) + end, + is_supported = function() + return true + end + } +} + +treesitter_config.setup { + ensure_installed = "maintained", + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + textobjects = { + select = { + enable = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + }, + }, + }, + matchup = {enable = true}, + autopairs = {enable = true}, + autotag = {enable = true}, + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + playground = {enable = true}, + nifoc_hooks = {enable = true}, +} diff --git a/config/nvim/lua/nifoc/config/virt_column.lua b/config/nvim/lua/nifoc/config/virt_column.lua new file mode 100644 index 0000000..9abd610 --- /dev/null +++ b/config/nvim/lua/nifoc/config/virt_column.lua @@ -0,0 +1 @@ +require('virt-column').setup() diff --git a/config/nvim/lua/nifoc/config/visual_eof.lua b/config/nvim/lua/nifoc/config/visual_eof.lua new file mode 100644 index 0000000..8ed7db0 --- /dev/null +++ b/config/nvim/lua/nifoc/config/visual_eof.lua @@ -0,0 +1,20 @@ +require('visual-eof').setup { + text_EOL = '↵', + text_NOEOL = '✗↵', + ft_ng = { + 'fugitive.*', + 'git.*', + 'LspTrouble', + 'minimap', + 'netrw', + 'NvimTree', + 'packer', + 'TelescopePrompt', + }; + buf_filter = function(bufnr) + local disable_buftypes = {'terminal', 'nofile'} + local buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype') + + return not vim.tbl_contains(disable_buftypes, buftype) + end; +} diff --git a/config/nvim/lua/nifoc/config/whichkey.lua b/config/nvim/lua/nifoc/config/whichkey.lua new file mode 100644 index 0000000..d1a073e --- /dev/null +++ b/config/nvim/lua/nifoc/config/whichkey.lua @@ -0,0 +1 @@ +require('which-key').setup {} diff --git a/config/nvim/lua/nifoc/keymap.lua b/config/nvim/lua/nifoc/keymap.lua new file mode 100644 index 0000000..b69a88d --- /dev/null +++ b/config/nvim/lua/nifoc/keymap.lua @@ -0,0 +1,193 @@ +local wk = require('which-key') +local npairs = require('nvim-autopairs') + +local telescope = require('telescope') +local telescope_builtin = require('telescope.builtin') +local telescope_themes = require('telescope.themes') + +-- Global key function +_G.nifoc_keymap_cr_complete = function() + return npairs.autopairs_cr() +end + +local M = {} + +function M.setup() + vim.api.nvim_set_keymap('n', '', '', {noremap = true}) + vim.g.mapleader = ' ' + vim.opt.timeoutlen = 500 + + -- mappings + local leader = { + n = { + "NvimTreeToggle", + "Toggle nvim-tree" + }, + o = { + function() require('nifoc.utils.telescope').project_files() end, + "Find Files" + }, + s = { + function() telescope_builtin.live_grep(telescope_themes.get_ivy()) end, + "Live Grep" + }, + ["ut"] = { + "UndotreeToggle", + "Undotree" + }, + f = { + name = "file", + n = { + "enew", + "New File" + }, + }, + b = { + name = "buffer", + l = { + function() telescope_builtin.buffers(telescope_themes.get_dropdown()) end, + "List Buffers" + }, + n = { + "BufferLineCycleNext", + "Next Buffer" + }, + p = { + "BufferLineCyclePrev", + "Previous Buffer" + }, + f = { + function() telescope_builtin.current_buffer_fuzzy_find(telescope_themes.get_dropdown()) end, + "Find In Buffer" + }, + t = { + function() telescope_builtin.treesitter(telescope_themes.get_dropdown()) end, + "Find Via Treesitter" + }, + }, + p = { + name = "project", + t = { + "TodoTelescope", + "TODO Comments" + }, + }, + v = { + name = "vcs", + s = { + function() telescope_builtin.git_status(telescope_themes.get_ivy()) end, + "Status" + }, + b = { + function() telescope_builtin.git_branches(telescope_themes.get_ivy()) end, + "List Branches" + }, + l = { + function() require('gitsigns').blame_line() end, + "Blame Line" + }, + }, + d = { + name = "debug", + l = { + name = "lsp", + i = { + "LspInfo", + "Info" + }, + r = { + "LspRestart", + "Restart" + } + }, + t = { + "TSPlaygroundToggle", + "TS Playground" + }, + n = { + function() telescope.extensions.notify.notify() end, + "Notifications" + }, + } + } + + -- Register which-key mappings + wk.register(leader, {prefix = "", noremap = false, silent = true}) + + -- Other mappings + vim.api.nvim_set_keymap('n', '', ':noh', {noremap = true, silent = true}) + + vim.api.nvim_set_keymap('i', '', 'v:lua.nifoc_keymap_cr_complete()', {noremap = true, expr = true, silent = true}) + + vim.api.nvim_set_keymap('n', '', 'b', {noremap = true}) + vim.api.nvim_set_keymap('n', '', 'w', {noremap = true}) + vim.api.nvim_set_keymap('n', '', '^', {noremap = true}) + vim.api.nvim_set_keymap('n', '', '$', {noremap = true}) + vim.api.nvim_set_keymap('i', '', 'b', {noremap = true}) + vim.api.nvim_set_keymap('i', '', 'w', {noremap = true}) + vim.api.nvim_set_keymap('i', '', '^', {noremap = true}) + vim.api.nvim_set_keymap('i', '', '$', {noremap = true}) + + vim.api.nvim_set_keymap('v', 'p', '"_dP', {noremap = true}) + vim.api.nvim_set_keymap('n', 'd', '"_d', {noremap = true}) + vim.api.nvim_set_keymap('v', 'd', '"_d', {noremap = true}) + + vim.api.nvim_set_keymap('n', '', 'lua require("FTerm").toggle()', {noremap = true, silent = true}) + vim.api.nvim_set_keymap('t', '', 'lua require("FTerm").toggle()', {noremap = true, silent = true}) +end + +function M.lsp_attach(client, bufnr) + -- mappings + local leader = { + t = { + "Telescope lsp_document_symbols theme=get_dropdown", + "LSP Document Tags" + }, + l = { + name = "lsp", + d = { + name = "diagnostics", + d = { + "LspTroubleToggle lsp_document_diagnostics", + "Document Diagnostics" + }, + w = { + "LspTroubleToggle lsp_workspace_diagnostics", + "Workspace Diagnostics" + }, + }, + c = { + name = "code action", + a = { + "Telescope lsp_code_actions theme=get_dropdown", + "Code Action" + }, + }, + f = { + name = "find", + r = { + "LspTroubleToggle lsp_references", + "References" + }, + d = { + "LspTroubleToggle lsp_definitions", + "Definitions" + }, + }, + }, + } + + -- Top-level mappings + local top = { + K = { + "lua vim.lsp.buf.hover()", + "Show Documentation" + }, + } + + -- Register which-key mappings + wk.register(leader, {prefix = "", noremap = true, silent = true, buffer = bufnr}) + wk.register(top, {noremap = true, silent = true, buffer = bufnr}) +end + +return M diff --git a/config/nvim/lua/nifoc/plugins.lua b/config/nvim/lua/nifoc/plugins.lua new file mode 100644 index 0000000..ad85eb0 --- /dev/null +++ b/config/nvim/lua/nifoc/plugins.lua @@ -0,0 +1,69 @@ +-- Disable some built-in plugins +vim.g.loaded_matchit = 1 +vim.g.loaded_matchparen = 1 +vim.g.loaded_gzip = 1 +vim.g.loaded_rrhelper = 1 +vim.g.loaded_tarPlugin = 1 +vim.g.loaded_zipPlugin = 1 +vim.g.loaded_netrwPlugin = 1 +vim.g.loaded_netrwFileHandlers = 1 +vim.g.loaded_netrwSettings = 1 +vim.g.loaded_2html_plugin = 1 +vim.g.loaded_vimballPlugin = 1 +vim.g.loaded_getscriptPlugin = 1 +vim.g.loaded_logipat = 1 +vim.g.loaded_tutor_mode_plugin = 1 + +vim.g.loaded_python_provider = 0 +vim.g.loaded_python3_provider = 0 +vim.g.loaded_ruby_provider = 0 +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 + +-- Require Plugin Configuration + +-- Fixes +require('nifoc.config.cursorline') + +-- Keybindings +require('nifoc.config.whichkey') + +-- Syntax +require('nifoc.config.treesitter') + +-- Telescope +require('nifoc.config.telescope') +require('nifoc.config.project') +require('nifoc.config.todo_comments') + +-- LSP +require('nifoc.config.lsp') +require('nifoc.config.lsp_trouble') +require('nifoc.config.illuminate') + +-- cmp +require('nifoc.config.completion') + +-- Pairs +require('nifoc.config.autopairs') +require('nvim-ts-autotag').setup() +require('nifoc.config.matchup') + +-- Comments +require('nifoc.config.comments') + +-- Textobjects +require('surround').setup({}) + +-- UI +require('nifoc.config.lualine') +require('nifoc.config.bufferline') +require('nifoc.config.nvim_tree') +require('nifoc.config.indent_line') +require('nifoc.config.virt_column') +require('nifoc.config.colorizer') +require('nifoc.config.gitsigns') +require('spellsitter').setup() +vim.notify = require('notify') +require('nifoc.config.visual_eof') +require('nifoc.config.fterm') diff --git a/config/nvim/lua/nifoc/utils/line_style.lua b/config/nvim/lua/nifoc/utils/line_style.lua new file mode 100644 index 0000000..0b140a1 --- /dev/null +++ b/config/nvim/lua/nifoc/utils/line_style.lua @@ -0,0 +1,37 @@ +local M = {} + +local check_disable = function() + local buftype = vim.bo.buftype + return buftype == 'terminal' or buftype == 'nofile' +end + +local check_toggle = function() + if check_disable() then + return false + elseif vim.w.is_telescope then + return false + else + local toggle_line_style = vim.b.toggle_line_style + return toggle_line_style == nil or toggle_line_style == 1 + end +end + +function M.maybe_set_special_style() + if check_disable() then + vim.opt_local.number = false + vim.opt_local.relativenumber = false + end + + if vim.w.is_telescope then + vim.opt_local.number = true + vim.opt_local.relativenumber = false + end +end + +function M.maybe_set_relativenumber(value) + if check_toggle() then + vim.opt_local.relativenumber = value + end +end + +return M diff --git a/config/nvim/lua/nifoc/utils/statusline.lua b/config/nvim/lua/nifoc/utils/statusline.lua new file mode 100644 index 0000000..34d45cc --- /dev/null +++ b/config/nvim/lua/nifoc/utils/statusline.lua @@ -0,0 +1,135 @@ +local M = {} + +local buffer_not_empty = function() + if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then + return true + end + + return false +end + +local buffer_variable_exists = function(key) + return buffer_not_empty() and vim.b[key] ~= nil +end + +local buffer_has_lsp = function() + return buffer_not_empty() and #vim.lsp.buf_get_clients() > 0 +end + +function M.line_column() + local line = tostring(vim.fn.line('.')) + local column = tostring(vim.fn.col('.')) + + return string.format("%3s:%-3s", line, column) +end + +function M.current_line_percent() + local current_line = vim.fn.line('.') + local total_line = vim.fn.line('$') + + if current_line == 1 then + return 'Top' + elseif current_line == total_line then + return 'Bot' + end + + return [[%2p%%]] +end + +function M.filetype() + local f_name = vim.fn.expand('%:t') + local f_extension = vim.fn.expand('%:e') + local f_type = vim.bo.filetype + + if f_type:len() > 0 then + return f_type .. ' ' .. require('nvim-web-devicons').get_icon(f_name, f_extension, {default = true}) + else + return 'no ft' + end +end + +function M.diagnostics_status() + if buffer_has_lsp() then + local status = require('lsp-status').diagnostics() + local errors, warnings, info, hints = status.errors, status.warnings, status.info, status.hints + local status_txt = {} + + if errors > 0 then table.insert(status_txt, ' ' .. errors) end + if warnings > 0 then table.insert(status_txt, ' ' .. warnings) end + if info > 0 then table.insert(status_txt, ' ' .. info) end + if hints > 0 then table.insert(status_txt, ' ' .. hints) end + + local formatted_status = table.concat(status_txt, ' ') + + if formatted_status:len() > 0 then + return formatted_status + else + return '' + end + else + return '' + end +end + +function M.gitsigns_formatter(status) + local added, changed, removed = status.added, status.changed, status.removed + local result = {} + + if added ~= nil and added > 0 then + table.insert(result, string.format("%%#GitSignsStatuslineAdd# %s", added)) + end + + if changed ~= nil and changed > 0 then + table.insert(result, string.format("%%#GitSignsStatuslineChange# %s", changed)) + end + + if removed ~= nil and removed > 0 then + table.insert(result, string.format("%%#GitSignsStatuslineDelete# %s", removed)) + end + + return table.concat(result, ' ') +end + +function M.current_function() + local fn = vim.b.lsp_current_function + + if fn ~= nil and fn:len() > 0 then + return ' ' .. fn + else + return '' + end +end + +function M.spell_enabled() + if buffer_not_empty() and vim.wo.spell then + return 'ﮒ' + else + return '' + end +end + +function M.fixer_enabled() + if buffer_variable_exists('nifoc_fixer_enabled') then + return '' + else + return '' + end +end + +function M.treesitter_enabled() + if buffer_variable_exists('nifoc_treesitter_enabled') then + return '' + else + return '' + end +end + +function M.lsp_enabled() + if buffer_variable_exists('nifoc_lsp_enabled') then + return '' + else + return '' + end +end + +return M diff --git a/config/nvim/lua/nifoc/utils/telescope.lua b/config/nvim/lua/nifoc/utils/telescope.lua new file mode 100644 index 0000000..e794b95 --- /dev/null +++ b/config/nvim/lua/nifoc/utils/telescope.lua @@ -0,0 +1,18 @@ +local telescope_themes = require('telescope.themes') + +local M = {} + +M.project_files = function() + local git_opts = telescope_themes.get_ivy() + local ok = pcall(require'telescope.builtin'.git_files, git_opts) + + if not ok then + local find_opts = telescope_themes.get_ivy({ + find_command = { 'rg', '--files', '--hidden', '-L', '-g', '!.git/*' } + }) + + require('telescope.builtin').find_files(find_opts) + end +end + +return M diff --git a/config/nvim/lua/nix_init.lua b/config/nvim/lua/nix_init.lua new file mode 100644 index 0000000..7c07235 --- /dev/null +++ b/config/nvim/lua/nix_init.lua @@ -0,0 +1,116 @@ +-- Preamble +pcall(require, 'impatient') +vim.cmd('syntax enable') +vim.cmd('filetype plugin indent on') +vim.opt.compatible = false +vim.opt.hidden = true +vim.opt.shell = '/bin/sh' + +-- Options +vim.opt.encoding = 'utf-8' +vim.opt.synmaxcol = 500 +vim.opt.showmode = false +vim.opt.ruler = false +vim.opt.ttyfast = true +vim.opt.lazyredraw = true +vim.opt.cursorline = true +vim.opt.list = true +vim.opt.listchars = {tab = '»·', trail = '·'} +vim.opt.showbreak = '↪ ' +vim.opt.backspace = {'indent', 'eol', 'start'} +vim.opt.showtabline = 2 +vim.opt.signcolumn = 'yes:1' +vim.opt.wildoptions = 'pum' +vim.opt.modeline = false +vim.opt.startofline = false +vim.opt.synmaxcol = 300 + +vim.opt.incsearch = true +vim.opt.grepprg = 'rg --vimgrep --no-heading' +vim.opt.grepformat = '%f:%l:%c:%m,%f:%l:%m' +vim.opt.inccommand = 'nosplit' + +vim.opt.completeopt = {'menu', 'menuone', 'noselect'} + +vim.opt.wrap = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.softtabstop = 2 +vim.opt.expandtab = true + +vim.opt.viewoptions = {'cursor', 'folds', 'slash', 'unix'} + +vim.opt.foldenable = false + +vim.opt.splitbelow = true +vim.opt.splitright = true + +vim.opt.autoread = true + +vim.opt.diffopt = {'filler', 'internal', 'algorithm:histogram', 'indent-heuristic'} + +vim.opt.spelllang = {'en', 'de'} + +-- UI +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.conceallevel = 2 +vim.opt.concealcursor = 'niv' + +-- See: https://github.com/antoinemadec/FixCursorHold.nvim +vim.opt.updatetime = 750 +vim.g.cursorhold_updatetime = 100 + +vim.opt.shortmess:append('c') +vim.opt.shortmess:remove('S') + +vim.opt.termguicolors = true +vim.cmd('set mouse=a mousemodel=popup_setpos') + +-- Plugins +require('nifoc.config.themes') +require('nifoc.plugins') + +-- Theme +vim.opt.background = 'dark' +vim.cmd('colorscheme dracula') + +-- Backups +vim.opt.backup = false +vim.opt.swapfile = false +vim.opt.undofile = true +vim.opt.undodir = os.getenv('HOME') .. '/.local/share/nvim/undo//' + +-- Clipboard +vim.g.clipboard = { + name = 'pbcopy', + copy = { + ['+'] = 'pbcopy', + ['*'] = 'pbcopy', + }, + paste = { + ['+'] = 'pbpaste', + ['*'] = 'pbpaste', + }, + cache_enabled = 0, +} + +vim.cmd('set clipboard+=unnamedplus') + +-- Keymap +require('nifoc.keymap').setup() + +-- Autocmds +vim.cmd('augroup nifoc_numbertoggle') + vim.cmd('autocmd!') + vim.cmd("autocmd BufEnter,BufWinEnter * lua require('nifoc.utils.line_style').maybe_set_special_style()") + vim.cmd('autocmd TermOpen * setlocal nonumber norelativenumber') + vim.cmd("autocmd BufEnter,InsertLeave * lua require('nifoc.utils.line_style').maybe_set_relativenumber(true)") + vim.cmd("autocmd BufLeave,InsertEnter * lua require('nifoc.utils.line_style').maybe_set_relativenumber(false)") +vim.cmd('augroup end') + +vim.cmd('augroup nifoc_yank') + vim.cmd('autocmd!') + vim.cmd('autocmd TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=500}') +vim.cmd('augroup end') diff --git a/config/yt-dlp.nix b/config/yt-dlp.nix new file mode 100644 index 0000000..fba6c1c --- /dev/null +++ b/config/yt-dlp.nix @@ -0,0 +1,6 @@ +{ + xdg.configFile.yt-dlp = { + source = ./yt-dlp; + recursive = true; + }; +} diff --git a/config/yt-dlp/config b/config/yt-dlp/config new file mode 100644 index 0000000..294a798 --- /dev/null +++ b/config/yt-dlp/config @@ -0,0 +1,21 @@ +# Add metadata and other things to the video +--add-metadata +--embed-subs +#--embed-thumbnail +--xattrs + +# Prefer best mp4 video +-f 'bestvideo+bestaudio/best' + +# Subtitles +--write-sub +--sub-format best +--sub-lang en,de + +# Download using aria2 +#--external-downloader aria2c +#--external-downloader-args "-j 8 -s 8 -x 8 -k 1M --file-allocation none" + +# Other +--no-overwrites +--no-call-home diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..523fda6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,140 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1638571010, + "narHash": "sha256-KSO7u13VRLdklQTKYJaBSfVcurEvw+HifAsHR7V2i5E=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "781d25b315def05cd7ede3765226c54216f0b1fe", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "neovim-flake": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "dir": "contrib", + "lastModified": 1638765202, + "narHash": "sha256-eW/ZDUrfP8rD8a5Rotqo8i5PKiK7UFWe75DgMLAtenY=", + "owner": "neovim", + "repo": "neovim", + "rev": "523f03b506bf577811c0e136bc852cdb89f92c00", + "type": "github" + }, + "original": { + "dir": "contrib", + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-nightly-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "neovim-flake": "neovim-flake", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1638778450, + "narHash": "sha256-C5UoHcRk5YjKNz9bVv+Kp28PjT/A+R49rUlpa1hFxvU=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "740f1503ca2e5c066507e836bac13aa21c87da3b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1638535497, + "narHash": "sha256-tk5LNbdkUhALp00+r5ZmQ3t7n2d5M7YUQB+MznWvVOg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c71f061c68ba8ce53471b767d5049cbd0f3d8490", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1638761670, + "narHash": "sha256-LywnGCbjfMHp4lwAmIXozB/rAqPkCG0J8HhMPwXsR1U=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "02336c5c5f719cd6bd4cfc5a091a1ccee6f06b1d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "neovim-nightly-overlay": "neovim-nightly-overlay", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..97e9c4e --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; + }; + + outputs = inputs@{ self, nixpkgs, home-manager, ... }: { + homeConfigurations = { + daniel = inputs.home-manager.lib.homeManagerConfiguration { + system = "x86_64-darwin"; + homeDirectory = "/Users/daniel"; + username = "daniel"; + stateVersion = "21.11"; + + configuration = { config, pkgs, ... }: + let + overlay-neovim = inputs.neovim-nightly-overlay.overlay; + in + { + nixpkgs.overlays = [ + overlay-neovim + ]; + + nixpkgs.config = { + allowUnfree = true; + allowBroken = true; + }; + + imports = [ ./home.nix ]; + }; + }; + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..8abdd12 --- /dev/null +++ b/home.nix @@ -0,0 +1,55 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ./programs/fish.nix + ./programs/starship.nix + + ./programs/nvim + + ./programs/git.nix + + ./programs/bat.nix + + ./programs/jq.nix + + # ./config/nvim.nix + ./config/yt-dlp.nix + ]; + + home = { + packages = with pkgs; [ + aria2 + arp-scan + atomicparsley + cachix + dogdns + exa + fd + ffmpeg + fzf + gallery-dl + hexyl + hyperfine + # neovim-nightly + nix-prefetch-github + parallel + procs + ripgrep + rtmpdump + tokei + yt-dlp + ]; + }; + + programs = { + home-manager.enable = true; + + direnv = { + enable = true; + nix-direnv.enable = true; + }; + + zoxide.enable = true; + }; +} diff --git a/programs/bat.nix b/programs/bat.nix new file mode 100644 index 0000000..f8581af --- /dev/null +++ b/programs/bat.nix @@ -0,0 +1,9 @@ +{ + programs.bat = { + enable = true; + + config = { + theme = "Dracula"; + }; + }; +} diff --git a/programs/fish.nix b/programs/fish.nix new file mode 100644 index 0000000..4169660 --- /dev/null +++ b/programs/fish.nix @@ -0,0 +1,67 @@ +{ pkgs, ... }: + +{ + programs.fish = { + enable = true; + + plugins = [ + { + name = "foreign-env"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc"; + sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"; + }; + } + + { + name = "dracula"; + src = pkgs.fetchFromGitHub { + owner = "dracula"; + repo = "fish"; + rev = "28db361b55bb49dbfd7a679ebec9140be8c2d593"; + sha256 = "vdqYlEyYvlPVgTkwXbE8GVZo0UBBT88JyMSWYykhfx4="; + }; + } + ]; + + shellAliases = { + hmsw = "home-manager switch --flake ~/.config/nixpkgs/#$USER"; + j = "z"; + ji = "zi"; + la = "exa --long --all --group --header --group-directories-first --sort=type --icons"; + lg = "exa --long --all --group --header --git"; + lt = "exa --long --all --group --header --tree --level "; + upa = "nix flake update ~/.config/nixpkgs -v"; + upp = "nix flake update ./ -v"; + upn = "$HOME/.config/nixpkgs/programs/nvim/update-plugins.sh"; + ucl = "nix-collect-garbage -d && nix-store --gc && nix-store --optimise -v"; + }; + + shellInit = '' + if test -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + fenv source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + end + + if test -d "$HOME/bin" + set -gx PATH "$HOME/bin" $PATH + end + + # Vendor Configuration + if test -d "$HOME/.nix-profile/share/fish/vendor_conf.d" + for vendor_conf in $HOME/.nix-profile/share/fish/vendor_conf.d/*.fish + source "$vendor_conf" + end + end + + + # Custom Scripts + if test -d "$HOME/.config/fish/custom-scripts" + for custom_script in $HOME/.config/fish/custom-scripts/*.fish + source "$custom_script" + end + end + ''; + }; +} diff --git a/programs/git.nix b/programs/git.nix new file mode 100644 index 0000000..7d4f38a --- /dev/null +++ b/programs/git.nix @@ -0,0 +1,57 @@ +{ + programs.git = { + enable = true; + lfs.enable = true; + delta.enable = true; + + userName = "Daniel Kempkens"; + userEmail = "daniel+git@kempkens.io"; + + aliases = { + lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"; + }; + + extraConfig = { + core = { + editor = "nvim"; + whitespace = "trailing-space,space-before-tab"; + autocrlf = "input"; + }; + + pull = { + rebase = true; + }; + + push = { + default = "simple"; + }; + + diff = { + indentheuristic = true; + algorithm = "histogram"; + }; + + apply = { + whitespace = "fix"; + }; + + rerere = { + enabled = true; + }; + + color = { + ui = "auto"; + }; + }; + + ignores = [ + "*~" + "*.swp" + ".DS_Store" + ]; + + delta.options = { + theme = "Dracula"; + }; + }; +} diff --git a/programs/jq.nix b/programs/jq.nix new file mode 100644 index 0000000..51e210b --- /dev/null +++ b/programs/jq.nix @@ -0,0 +1,15 @@ +{ + programs.jq = { + enable = true; + + colors = { + null = "1;32"; + false = "1;35"; + true = "1;35"; + numbers = "0;35"; + strings = "0;33"; + arrays = "1;37"; + objects = "1;37"; + }; + }; +} diff --git a/programs/nvim/default.nix b/programs/nvim/default.nix new file mode 100644 index 0000000..a7ef0fe --- /dev/null +++ b/programs/nvim/default.nix @@ -0,0 +1,115 @@ +{ pkgs, ... }: + +let + customPlugins = import ./plugins.nix { inherit pkgs; }; +in +{ + programs.neovim = { + enable = true; + package = pkgs.neovim-nightly; + + extraConfig = '' + lua require('nix_init') + ''; + + extraPackages = with pkgs; [ + tree-sitter + + # LSP + efm-langserver + nodePackages.bash-language-server + nodePackages.dockerfile-language-server-nodejs + nodePackages.vscode-langservers-extracted + nodePackages.yaml-language-server + rnix-lsp + sqls + taplo-lsp + + # LSP Tools + hadolint + shellcheck + shfmt + ]; + + plugins = with customPlugins; [ + # Fixes + impatient-nvim + FixCursorHold-nvim + vim-auto-cursorline + + # Utils + popup-nvim + plenary-nvim + nvim-web-devicons + + # Keybindings + which-key-nvim + + # Themes + tokyonight-nvim + dracula-nvim + + # Syntax + nvim-treesitter + playground + Jenkinsfile-vim-syntax + + # Telescope + telescope-nvim + telescope-fzf-native-nvim + project-nvim + todo-comments-nvim + + # LSP + nvim-lspconfig + lsp-trouble-nvim + lspkind-nvim + lsp-status-nvim + vim-illuminate + + # cmp + nvim-cmp + cmp-nvim-lsp + LuaSnip + cmp_luasnip + cmp-nvim-lua + cmp-path + cmp-buffer + cmp-treesitter + cmp-cmdline + cmp-nvim-lsp-document-symbol + + # Pairs + nvim-autopairs + nvim-ts-autotag + vim-matchup + + # Comments + Comment-nvim + + # Textobjects + nvim-treesitter-textobjects + surround-nvim + + # UI + undotree + lualine-nvim + nvim-bufferline-lua + nvim-tree-lua + indent-blankline-nvim + virt-column-nvim + nvim-colorizer-lua + gitsigns-nvim + spellsitter-nvim + nvim-notify + nvim-visual-eof-lua + FTerm-nvim + editorconfig-vim + ]; + }; + + xdg.configFile.nvim = { + source = ../../config/nvim; + recursive = true; + }; +} diff --git a/programs/nvim/plugins.nix b/programs/nvim/plugins.nix new file mode 100644 index 0000000..3465376 --- /dev/null +++ b/programs/nvim/plugins.nix @@ -0,0 +1,605 @@ +# This file has been auto-generated +{ pkgs, ... }: +{ + impatient-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "impatient.nvim"; + version = "282b99b"; + src = pkgs.fetchFromGitHub { + owner = "lewis6991"; + repo = "impatient.nvim"; + rev = "282b99b817d61e6c6860addf5629b641925a937a"; + sha256 = "RtXtmtfpPAtZuDSn/eKaX12w1BybqUeWoKVGV2yEMCM="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/lewis6991/impatient.nvim"; + }; + FixCursorHold-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "FixCursorHold.nvim"; + version = "0e4e22d"; + src = pkgs.fetchFromGitHub { + owner = "antoinemadec"; + repo = "FixCursorHold.nvim"; + rev = "0e4e22d21975da60b0fd2d302285b3b603f9f71e"; + sha256 = "v56qtPGa8MkEPpQpzA+XHH/TsV1q4p65wSuvF140LuM="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/antoinemadec/FixCursorHold.nvim"; + }; + vim-auto-cursorline = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "vim-auto-cursorline"; + version = "ee22b15"; + src = pkgs.fetchFromGitHub { + owner = "delphinus"; + repo = "vim-auto-cursorline"; + rev = "ee22b1589809f1b1aaaaef15997a0a84585d667f"; + sha256 = "+ajtZm9pJrl49fI7zFqBJ49SL1XqfOoTp0ICelEknYc="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/delphinus/vim-auto-cursorline"; + }; + which-key-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "which-key.nvim"; + version = "d3032b6"; + src = pkgs.fetchFromGitHub { + owner = "folke"; + repo = "which-key.nvim"; + rev = "d3032b6d3e0adb667975170f626cb693bfc66baa"; + sha256 = "mgLmwP8ci9VjRiwBedZDPXi6CjNtJy3iOJDbmSXtisk="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/folke/which-key.nvim"; + }; + tokyonight-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "tokyonight.nvim"; + version = "b3a829d"; + src = pkgs.fetchFromGitHub { + owner = "folke"; + repo = "tokyonight.nvim"; + rev = "b3a829d2ba6344b5364fda71b5b7501f707d1bdf"; + sha256 = "n00mEFtTbN8XAmlOcjtToagaUqROJ8Id4E4kAPXpEVk="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/folke/tokyonight.nvim"; + }; + dracula-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "dracula.nvim"; + version = "aa9d195"; + src = pkgs.fetchFromGitHub { + owner = "Mofiqul"; + repo = "dracula.nvim"; + rev = "aa9d195ab856b1c8e9d3afca0768cdc2d992a4a7"; + sha256 = "qRwhrXwpcasr8JC2W7oBiKLsywUzYgSDL8n9rAeQWkk="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/Mofiqul/dracula.nvim"; + }; + nvim-treesitter = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-treesitter"; + version = "d6a0a26"; + src = pkgs.fetchFromGitHub { + owner = "nvim-treesitter"; + repo = "nvim-treesitter"; + rev = "d6a0a26b8563409d4660def7320a4f4bc23954df"; + sha256 = "WqTxPlN39/IoDh7/nWbY+yArkkDYD8IRADhSt0X0yZs="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-treesitter/nvim-treesitter"; + }; + playground = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "playground"; + version = "787a7a8"; + src = pkgs.fetchFromGitHub { + owner = "nvim-treesitter"; + repo = "playground"; + rev = "787a7a8d4444e58467d6b3d4b88a497e7d494643"; + sha256 = "YMINv064VzuzZLuQNY6HN3oCZvYjNQi6IMliQPTijfg="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-treesitter/playground"; + }; + Jenkinsfile-vim-syntax = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "Jenkinsfile-vim-syntax"; + version = "0d05729"; + src = pkgs.fetchFromGitHub { + owner = "martinda"; + repo = "Jenkinsfile-vim-syntax"; + rev = "0d05729168ea44d60862f17cffa80024ab30bcc9"; + sha256 = "/qUlzGfo2OhHEBGaoTH8K4VVT0Zg9ocJBb84orMD4xc="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/martinda/Jenkinsfile-vim-syntax"; + }; + popup-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "popup.nvim"; + version = "b7404d3"; + src = pkgs.fetchFromGitHub { + owner = "nvim-lua"; + repo = "popup.nvim"; + rev = "b7404d35d5d3548a82149238289fa71f7f6de4ac"; + sha256 = "dNWz/xovUg55fDZUpVs/2kLphk3lqQyvPtc9ATwbeSQ="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-lua/popup.nvim"; + }; + plenary-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "plenary.nvim"; + version = "5d4a65a"; + src = pkgs.fetchFromGitHub { + owner = "nvim-lua"; + repo = "plenary.nvim"; + rev = "5d4a65a84d2eb2ee035c667d01ef8e7cafb8a549"; + sha256 = "ctluRYRvuOR/LmRmtQoztY1BuOezU1zdTlKrARuN/J0="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-lua/plenary.nvim"; + }; + telescope-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "telescope.nvim"; + version = "82e3cc3"; + src = pkgs.fetchFromGitHub { + owner = "nvim-telescope"; + repo = "telescope.nvim"; + rev = "82e3cc322ad87b262aef092cb7475e769740e83a"; + sha256 = "72Ff7d4f7EHRG9+r/U9BV5XbN1vMkyVoZcfrZ6uVQuA="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-telescope/telescope.nvim"; + }; + telescope-fzf-native-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "telescope-fzf-native.nvim"; + version = "b8662b0"; + src = pkgs.fetchFromGitHub { + owner = "nvim-telescope"; + repo = "telescope-fzf-native.nvim"; + rev = "b8662b076175e75e6497c59f3e2799b879d7b954"; + sha256 = "gd/nNgMhvHdJWOlHMdYxY8Hi8Qo4F66TjKSewNKNR3I="; + fetchSubmodules = false; + }; + buildPhase = "make"; + meta.homepage = "https://github.com/nvim-telescope/telescope-fzf-native.nvim"; + }; + project-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "project.nvim"; + version = "71d0e23"; + src = pkgs.fetchFromGitHub { + owner = "ahmedkhalf"; + repo = "project.nvim"; + rev = "71d0e23dcfc43cfd6bb2a97dc5a7de1ab47a6538"; + sha256 = "RUPbmMPfa1lT2fIslC9vZR3e23IkOyPpYnWDytxkvUs="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/ahmedkhalf/project.nvim"; + }; + nvim-lspconfig = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-lspconfig"; + version = "22b21bc"; + src = pkgs.fetchFromGitHub { + owner = "neovim"; + repo = "nvim-lspconfig"; + rev = "22b21bc000a8320675ea10f4f50f1bbd48d09ff2"; + sha256 = "9SrA6rsrpjVZC2OuEaC1faYXqpT8rrDsZ4Sqz60D7Y4="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/neovim/nvim-lspconfig"; + }; + nvim-web-devicons = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-web-devicons"; + version = "8df4988"; + src = pkgs.fetchFromGitHub { + owner = "kyazdani42"; + repo = "nvim-web-devicons"; + rev = "8df4988ecf8599fc1f8f387bbf2eae790e4c5ffb"; + sha256 = "a6vlRuNAa5oJy5AFp0SjqNUwSE/kc8jaII7T9IcG+Kw="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/kyazdani42/nvim-web-devicons"; + }; + lsp-trouble-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "lsp-trouble.nvim"; + version = "4a45782"; + src = pkgs.fetchFromGitHub { + owner = "folke"; + repo = "lsp-trouble.nvim"; + rev = "4a45782db943f95500b61ffce187bf4cada954ae"; + sha256 = "qkJkMPxmUVytymwgXI8BW3OPMZcGRT9pSA4LzXhOlZg="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/folke/lsp-trouble.nvim"; + }; + lspkind-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "lspkind-nvim"; + version = "f3b5efa"; + src = pkgs.fetchFromGitHub { + owner = "onsails"; + repo = "lspkind-nvim"; + rev = "f3b5efa11f0665accb7bd0258260b9d08dd4956e"; + sha256 = "qIs65OIV0m5Y3pe5ozG6sYa1yIx0vXpkNC0Gkkm9amw="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/onsails/lspkind-nvim"; + }; + lsp-status-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "lsp-status.nvim"; + version = "e8e5303"; + src = pkgs.fetchFromGitHub { + owner = "nvim-lua"; + repo = "lsp-status.nvim"; + rev = "e8e5303f9ee3d8dc327c97891eaa1257ba5d4eee"; + sha256 = "otDFYc9Sl1OYmkrWFCzgAG0XkXyvR/ebRe2zAOwQ1IA="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-lua/lsp-status.nvim"; + }; + nvim-cmp = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-cmp"; + version = "edc2a50"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "nvim-cmp"; + rev = "edc2a503ee33e2a62e94a2257e9e3bbd50fa6feb"; + sha256 = "5/ZvonFG65i+bBKAdlgD0+zI87BgIaEGFwocsPkbmS0="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/nvim-cmp"; + }; + cmp-nvim-lsp = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-nvim-lsp"; + version = "1341172"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "cmp-nvim-lsp"; + rev = "134117299ff9e34adde30a735cd8ca9cf8f3db81"; + sha256 = "jLfW4xoYnEOWa7oWSmkB7vNxu9Jgttbme+nTiAC92so="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/cmp-nvim-lsp"; + }; + LuaSnip = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "LuaSnip"; + version = "0528072"; + src = pkgs.fetchFromGitHub { + owner = "L3MON4D3"; + repo = "LuaSnip"; + rev = "052807223ba4d9babb412f12f08da0b34bc083cf"; + sha256 = "rA6c/Yq3Vk9Pqrm38vIJJLufPNB1uHkuu5wATlkcBD0="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/L3MON4D3/LuaSnip"; + }; + cmp_luasnip = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp_luasnip"; + version = "75bf643"; + src = pkgs.fetchFromGitHub { + owner = "saadparwaiz1"; + repo = "cmp_luasnip"; + rev = "75bf6434f175206cd219f9d2bbcae154a009346c"; + sha256 = "j26ufCjpIAaoaK2Dp9fI0oaEW05tC0a89omz6k3lpis="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/saadparwaiz1/cmp_luasnip"; + }; + cmp-nvim-lua = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-nvim-lua"; + version = "d276254"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "cmp-nvim-lua"; + rev = "d276254e7198ab7d00f117e88e223b4bd8c02d21"; + sha256 = "/xUfw5adjXu8ySZBBFrLVJ1FCNJzfh79wf+wJsW6sIY="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/cmp-nvim-lua"; + }; + cmp-path = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-path"; + version = "d83839a"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "cmp-path"; + rev = "d83839ae510d18530c6d36b662a9e806d4dceb73"; + sha256 = "6WCIwAmCjOaBh1jrmeVttGQVNLZTPeWY2T7+X8wD9W4="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/cmp-path"; + }; + cmp-buffer = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-buffer"; + version = "a706dc6"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "cmp-buffer"; + rev = "a706dc69c49110038fe570e5c9c33d6d4f67015b"; + sha256 = "FdWs15eTad4igwN5F5+CKxSMQi9eX07BXjM/HgTIURc="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/cmp-buffer"; + }; + cmp-treesitter = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-treesitter"; + version = "a6b4c95"; + src = pkgs.fetchFromGitHub { + owner = "ray-x"; + repo = "cmp-treesitter"; + rev = "a6b4c95ee922cace635b5a46c7fcc691d2559fbb"; + sha256 = "Skdb113mgJqPJGUCk08ymo2IrnCyMO2KY36rOIxFHRk="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/ray-x/cmp-treesitter"; + }; + cmp-cmdline = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-cmdline"; + version = "29ca81a"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "cmp-cmdline"; + rev = "29ca81a6f0f288e6311b3377d9d9684d22eac2ec"; + sha256 = "BkMvtwkLnT0tnLn9F+vt3vtmAQOBVFwFC3YF7ZsE8Hs="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/cmp-cmdline"; + }; + cmp-nvim-lsp-document-symbol = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "cmp-nvim-lsp-document-symbol"; + version = "29d12e5"; + src = pkgs.fetchFromGitHub { + owner = "hrsh7th"; + repo = "cmp-nvim-lsp-document-symbol"; + rev = "29d12e55cf49ee07b829114ad39b161cad2544ab"; + sha256 = "i3lc1u+ml1Zh6bx+uaiIYZZbQhAhJyMbeWzIYwgZlXA="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/hrsh7th/cmp-nvim-lsp-document-symbol"; + }; + nvim-autopairs = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-autopairs"; + version = "18fe311"; + src = pkgs.fetchFromGitHub { + owner = "windwp"; + repo = "nvim-autopairs"; + rev = "18fe311bb967d16ddf2cc28e7e71f234c37d3e26"; + sha256 = "Pln8qhfjEJ2VXcDPZ0P6UNQHTcY3Xw58B4X56IVr008="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/windwp/nvim-autopairs"; + }; + nvim-ts-autotag = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-ts-autotag"; + version = "80d427a"; + src = pkgs.fetchFromGitHub { + owner = "windwp"; + repo = "nvim-ts-autotag"; + rev = "80d427af7b898768c8d8538663d52dee133da86f"; + sha256 = "8SINCRoarkkQdrKzq4xujn197G4BRHQ7HYJQj929nME="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/windwp/nvim-ts-autotag"; + }; + Comment-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "Comment.nvim"; + version = "00aff9f"; + src = pkgs.fetchFromGitHub { + owner = "numToStr"; + repo = "Comment.nvim"; + rev = "00aff9f0fb75328c686a8484cd090ad72c355cb1"; + sha256 = "l84IFDOiqfPBdWxKbp51JJZZG6iTv/uBHtV5vFHU+gc="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/numToStr/Comment.nvim"; + }; + nvim-treesitter-textobjects = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-treesitter-textobjects"; + version = "eb8ff2f"; + src = pkgs.fetchFromGitHub { + owner = "nvim-treesitter"; + repo = "nvim-treesitter-textobjects"; + rev = "eb8ff2f55915a0b02167315e72fe7f60cbd7f16d"; + sha256 = "R5ie5E+AMCOTwYedXeIN0ltOxE9iKpAhwHd9X91TPRw="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"; + }; + surround-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "surround.nvim"; + version = "a21c3ee"; + src = pkgs.fetchFromGitHub { + owner = "blackCauldron7"; + repo = "surround.nvim"; + rev = "a21c3eeee2f139d20694ff70135b3557cadece1c"; + sha256 = "U0Kz99O7Vi9OAIxSFnqOfVtlVRvHlX2ExhPZnG0KSnE="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/blackCauldron7/surround.nvim"; + }; + vim-matchup = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "vim-matchup"; + version = "ef044ee"; + src = pkgs.fetchFromGitHub { + owner = "andymass"; + repo = "vim-matchup"; + rev = "ef044ee012baa01d6f4ad79a04eeb5edb5bc7d84"; + sha256 = "HhNvaiVYR8sI4UItJVZDYodZjQYmV1ZJ0NmMDiN5DqY="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/andymass/vim-matchup"; + }; + undotree = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "undotree"; + version = "bdd7153"; + src = pkgs.fetchFromGitHub { + owner = "mbbill"; + repo = "undotree"; + rev = "bdd715338a3a0c82674153108a3deaf827d36cfb"; + sha256 = "J4qQS000SJ/CTElLhpEV0dVXGQ5XRg6SnENtpQCExrw="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/mbbill/undotree"; + }; + lualine-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "lualine.nvim"; + version = "d68631d"; + src = pkgs.fetchFromGitHub { + owner = "nvim-lualine"; + repo = "lualine.nvim"; + rev = "d68631d2c02bd31d937349d739c625cc81dd9ac1"; + sha256 = "5DYBCXS+DLsoK5yNlcGVcKUYd/gbAOYuLIQbUVd2YGw="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/nvim-lualine/lualine.nvim"; + }; + nvim-bufferline-lua = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-bufferline.lua"; + version = "463637a"; + src = pkgs.fetchFromGitHub { + owner = "akinsho"; + repo = "nvim-bufferline.lua"; + rev = "463637a3ac86dcaacbcd47aa608f53aaad749696"; + sha256 = "CBWRJiPYhNR86imNHt79P24uthMW09kRBQ53pCew8Fo="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/akinsho/nvim-bufferline.lua"; + }; + nvim-tree-lua = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-tree.lua"; + version = "2e33b16"; + src = pkgs.fetchFromGitHub { + owner = "kyazdani42"; + repo = "nvim-tree.lua"; + rev = "2e33b1654384921ec1cc9656a2018744f3f1ce81"; + sha256 = "VFiZJt6vCzSyK1BL9UYYKj3nBKMrthiC0GR3mEhma5E="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/kyazdani42/nvim-tree.lua"; + }; + indent-blankline-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "indent-blankline.nvim"; + version = "0f8df7e"; + src = pkgs.fetchFromGitHub { + owner = "lukas-reineke"; + repo = "indent-blankline.nvim"; + rev = "0f8df7e43f0cae4c44e0e8383436ad602f333419"; + sha256 = "8sELQ8TY3DN9V+pG6Li0wXb5/xe5uhPymL/JSAplWI4="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/lukas-reineke/indent-blankline.nvim"; + }; + virt-column-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "virt-column.nvim"; + version = "7b013a2"; + src = pkgs.fetchFromGitHub { + owner = "lukas-reineke"; + repo = "virt-column.nvim"; + rev = "7b013a2c873df8e1ec9412532b5ac7592d35a61d"; + sha256 = "CmexkPZnguQc0597h1jWIgxrrUOOevQV7TXsLKSveIE="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/lukas-reineke/virt-column.nvim"; + }; + nvim-colorizer-lua = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-colorizer.lua"; + version = "36c610a"; + src = pkgs.fetchFromGitHub { + owner = "norcalli"; + repo = "nvim-colorizer.lua"; + rev = "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6"; + sha256 = "6YrnItxExL2C8pNIdLd+hXCjsB2MbZANwWkah6dreD8="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/norcalli/nvim-colorizer.lua"; + }; + gitsigns-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "gitsigns.nvim"; + version = "5eb87a0"; + src = pkgs.fetchFromGitHub { + owner = "lewis6991"; + repo = "gitsigns.nvim"; + rev = "5eb87a0b05914d3763277ebe257bd5bafcdde8cd"; + sha256 = "jT01Opd/PEqXs80ZLCRqVcs0H28df+rNNp3n5wZ7lQk="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/lewis6991/gitsigns.nvim"; + }; + spellsitter-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "spellsitter.nvim"; + version = "3b378cf"; + src = pkgs.fetchFromGitHub { + owner = "lewis6991"; + repo = "spellsitter.nvim"; + rev = "3b378cfb74dcdd159f52d6506401915f65c51fd5"; + sha256 = "oFx5/IU3T8iHQY6lFnMBynyU8btQgn9cXyOR53C5E0o="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/lewis6991/spellsitter.nvim"; + }; + nvim-notify = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-notify"; + version = "ef027e3"; + src = pkgs.fetchFromGitHub { + owner = "rcarriga"; + repo = "nvim-notify"; + rev = "ef027e34b618eac42fb0111c1db670ba01793039"; + sha256 = "PBySkhxwqrVrUECsaqW6JXtDwfQXSwLn3xHcrESH0R0="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/rcarriga/nvim-notify"; + }; + nvim-visual-eof-lua = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-visual-eof.lua"; + version = "3c001c6"; + src = pkgs.fetchFromGitHub { + owner = "LumaKernel"; + repo = "nvim-visual-eof.lua"; + rev = "3c001c6cda4db5bf62ba33344e61e30230acd9eb"; + sha256 = "azT2Cv3G5/HHsu/PkW/vW0CmrnZ/T7Q6x9Mlypr6pFY="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/LumaKernel/nvim-visual-eof.lua"; + }; + vim-illuminate = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "vim-illuminate"; + version = "2beae05"; + src = pkgs.fetchFromGitHub { + owner = "RRethy"; + repo = "vim-illuminate"; + rev = "2beae0581caa66cf8c09fad7c7c557f92d49d2bd"; + sha256 = "GwuMmUZTGk0hlB1dqXGosNRua+Y8woR6SvqqoRI6LOM="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/RRethy/vim-illuminate"; + }; + FTerm-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "FTerm.nvim"; + version = "0911ab9"; + src = pkgs.fetchFromGitHub { + owner = "numToStr"; + repo = "FTerm.nvim"; + rev = "0911ab93b488fdd8032e695ab56d14357e14e836"; + sha256 = "MThp2SSzDbK3edKfOtnAHy2NCkuLQs3FCs6h5ox5bl0="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/numToStr/FTerm.nvim"; + }; + todo-comments-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "todo-comments.nvim"; + version = "6570fd2"; + src = pkgs.fetchFromGitHub { + owner = "folke"; + repo = "todo-comments.nvim"; + rev = "6570fd271d17fec1966522f3a19cc6f4c88824c4"; + sha256 = "1sRrDNQ8OuWcN/yKTIQ1It3UkUDfe2Ln9d2CCuR0xS4="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/folke/todo-comments.nvim"; + }; + editorconfig-vim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "editorconfig-vim"; + version = "3078cd1"; + src = pkgs.fetchFromGitHub { + owner = "editorconfig"; + repo = "editorconfig-vim"; + rev = "3078cd10b28904e57d878c0d0dab42aa0a9fdc89"; + sha256 = "HFHrm+V296IJh27yJW76DD09ehYc8hMxnnvR9+ddP2M="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/editorconfig/editorconfig-vim"; + }; +} diff --git a/programs/nvim/plugins.txt b/programs/nvim/plugins.txt new file mode 100644 index 0000000..02d809d --- /dev/null +++ b/programs/nvim/plugins.txt @@ -0,0 +1,50 @@ +lewis6991/impatient.nvim +antoinemadec/FixCursorHold.nvim +delphinus/vim-auto-cursorline +folke/which-key.nvim +folke/tokyonight.nvim +Mofiqul/dracula.nvim +nvim-treesitter/nvim-treesitter +nvim-treesitter/playground +martinda/Jenkinsfile-vim-syntax +nvim-lua/popup.nvim +nvim-lua/plenary.nvim +nvim-telescope/telescope.nvim +nvim-telescope/telescope-fzf-native.nvim/make +ahmedkhalf/project.nvim +neovim/nvim-lspconfig +kyazdani42/nvim-web-devicons +folke/lsp-trouble.nvim +onsails/lspkind-nvim +nvim-lua/lsp-status.nvim +hrsh7th/nvim-cmp +hrsh7th/cmp-nvim-lsp +L3MON4D3/LuaSnip +saadparwaiz1/cmp_luasnip +hrsh7th/cmp-nvim-lua +hrsh7th/cmp-path +hrsh7th/cmp-buffer +ray-x/cmp-treesitter +hrsh7th/cmp-cmdline +hrsh7th/cmp-nvim-lsp-document-symbol +windwp/nvim-autopairs +windwp/nvim-ts-autotag +numToStr/Comment.nvim +nvim-treesitter/nvim-treesitter-textobjects +blackCauldron7/surround.nvim +andymass/vim-matchup +mbbill/undotree +nvim-lualine/lualine.nvim +akinsho/nvim-bufferline.lua +kyazdani42/nvim-tree.lua +lukas-reineke/indent-blankline.nvim +lukas-reineke/virt-column.nvim +norcalli/nvim-colorizer.lua +lewis6991/gitsigns.nvim +lewis6991/spellsitter.nvim +rcarriga/nvim-notify +LumaKernel/nvim-visual-eof.lua +RRethy/vim-illuminate +numToStr/FTerm.nvim +folke/todo-comments.nvim +editorconfig/editorconfig-vim diff --git a/programs/nvim/update-plugins.sh b/programs/nvim/update-plugins.sh new file mode 100755 index 0000000..b58c7a4 --- /dev/null +++ b/programs/nvim/update-plugins.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env nix-shell +#!nix-shell update-shell.nix -i bash + +script_dir="$(dirname "$(realpath "$0")")" +plugins="${script_dir}/plugins.txt" +nix_new_file="${script_dir}/plugins_new.nix" +nix_file="${script_dir}/plugins.nix" + +echo '# This file has been auto-generated' > "$nix_new_file" +echo '{ pkgs, ... }:' >> "$nix_new_file" + +echo "{" >> "$nix_new_file" +while IFS='' read -r LINE || [ -n "${LINE}" ]; do + owner="$(echo "$LINE" | cut -d'/' -f1)" + repo="$(echo "$LINE" | cut -d'/' -f2)" + build="$(echo "$LINE" | cut -d'/' -f3)" + name="$(echo "$repo" | tr [.] '-')" + src="$(nix-prefetch-github --nix --no-fetch-submodules "$owner" "$repo" 2> /dev/null | tail -n +4)" + rev="$(echo "$src" | grep rev | cut -d '"' -f 2)" + + echo "Updating ${owner}/${repo} ..." + + echo "${name} = pkgs.vimUtils.buildVimPluginFrom2Nix {" >> "$nix_new_file" + echo "pname = \"${repo}\";" >> "$nix_new_file" + echo "version = \"${rev:0:7}\";" >> "$nix_new_file" + echo "src = ${src};" >> "$nix_new_file" + + if [ -n "$build" ]; then + echo "buildPhase = \"${build}\";" >> "$nix_new_file" + fi + + echo "meta.homepage = \"https://github.com/${owner}/${repo}\";" >> "$nix_new_file" + echo '};' >> "$nix_new_file" +done < "$plugins" +echo "}" >> "$nix_new_file" + +nixpkgs-fmt "$nix_new_file" + +if test -f "$nix_file"; then + diff -U 4 "$nix_file" "$nix_new_file" | bat --paging=never -ldiff + mv "$nix_new_file" "$nix_file" +else + mv "$nix_new_file" "$nix_file" + bat --paging=never "$nix_file" +fi diff --git a/programs/nvim/update-shell.nix b/programs/nvim/update-shell.nix new file mode 100644 index 0000000..da0fea3 --- /dev/null +++ b/programs/nvim/update-shell.nix @@ -0,0 +1,9 @@ +{ pkgs ? import { } }: + +pkgs.mkShell { + packages = with pkgs; [ + bat + nix-prefetch-github + nixpkgs-fmt + ]; +} diff --git a/programs/starship.nix b/programs/starship.nix new file mode 100644 index 0000000..6cd8dec --- /dev/null +++ b/programs/starship.nix @@ -0,0 +1,73 @@ +{ + programs.starship = { + enable = true; + enableFishIntegration = true; + + settings = { + add_newline = true; + + cmd_duration = { + format = "\\[[ $duration]($style)\\]"; + }; + + docker_context = { + symbol = " "; + format = "\\[[$symbol$context]($style)\\]"; + }; + + elixir = { + symbol = " "; + format = "\\[[$symbol($version \\(OTP $otp_version\\))]($style)\\]"; + }; + + erlang = { + symbol = " "; + format = "\\[[$symbol($version)]($style)\\]"; + }; + + git_branch = { + symbol = " "; + format = "\\[[$symbol$branch]($style)\\]"; + }; + + java = { + symbol = " "; + format = "\\[[$symbol($version)]($style)\\]"; + }; + + nix_shell = { + symbol = " "; + format = "\\[[$symbol$state( \\($name\\))]($style)\\]"; + }; + + nodejs = { + symbol = " "; + format = "\\[[$symbol($version)]($style)\\]"; + }; + + package = { + symbol = " "; + format = "\\[[$symbol$version]($style)\\]"; + }; + + php = { + symbol = " "; + format = "\\[[$symbol($version)]($style)\\]"; + }; + + python = { + symbol = " "; + format = "\\[[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style)\\]"; + }; + + ruby = { + symbol = " "; + format = "\\[[$symbol($version)]($style)\\]"; + }; + + time = { + format = "\\[[$time]($style)\\]"; + }; + }; + }; +}