diff --git a/.config/nvim/after/plugin/keymappings.lua b/.config/nvim/after/plugin/keymappings.lua index ccb6689..50ef9f4 100644 --- a/.config/nvim/after/plugin/keymappings.lua +++ b/.config/nvim/after/plugin/keymappings.lua @@ -1,11 +1,9 @@ - local Remap = require("halfdan.keymap") local nnoremap = Remap.nnoremap local vnoremap = Remap.vnoremap local inoremap = Remap.inoremap local tnoremap = Remap.tnoremap local xnoremap = Remap.xnoremap -local nmap = Remap.nmap -- Yank until end of line nnoremap('Y', 'yg$') @@ -44,13 +42,13 @@ nnoremap("/", ":split") -- Keybindings below this are neovim cli only if vim.g.vscode then - -- Toggle Comment - vim.keymap.set('x', 'gc', 'VSCodeCommentary', {}) - vim.keymap.set('n', 'gc', 'VSCodeCommentary', {}) - vim.keymap.set('o', 'gc', 'VSCodeCommentary', {}) - vim.keymap.set('n', 'gcc', 'VSCodeCommentaryLine', {}) + -- Toggle Comment + vim.keymap.set('x', 'gc', 'VSCodeCommentary', {}) + vim.keymap.set('n', 'gc', 'VSCodeCommentary', {}) + vim.keymap.set('o', 'gc', 'VSCodeCommentary', {}) + vim.keymap.set('n', 'gcc', 'VSCodeCommentaryLine', {}) - return + return end tnoremap('', '') @@ -108,32 +106,49 @@ nnoremap('sv', ':source $MYVIMRC') local builtin = require("telescope.builtin") nnoremap("gg", function() - -- builtin.live_grep() - require "telescope".extensions.egrepify.egrepify { sorting_strategy = 'ascending' } + require "telescope".extensions.egrepify.egrepify { sorting_strategy = 'ascending' } +end) + +nnoremap("gs", function() + require('neogit').open({ kind = 'split' }) end) nnoremap("", function() - builtin.find_files() + builtin.find_files() end) nnoremap("ff", function() - require('telescope').extensions.smart_open.smart_open({cwd_only = true}) + require('telescope').extensions.smart_open.smart_open({ cwd_only = true }) end) nnoremap("fh", function() - builtin.find_files{cwd=vim.fn.expand('%:p:h')} + builtin.find_files { cwd = vim.fn.expand('%:p:h') } end) nnoremap("gw", function() - builtin.grep_string { search = vim.fn.expand("") } + builtin.grep_string { search = vim.fn.expand("") } end) nnoremap("fb", function() - builtin.buffers() + builtin.buffers() end) nnoremap("gc", function() - builtin.git_branches() + builtin.git_branches() end) +nnoremap("nt", function() + require("neotest").run.run() +end) +nnoremap("nf", function() + require("neotest").run.run(vim.fn.expand("%")) +end) + +nnoremap("nd", function() + require("neotest").run.run({ strategy = "dap" }) +end) + +nnoremap("ns", function() + require("neotest").summary.toggle() +end) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index 6177ef9..10c5d51 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -1,70 +1,68 @@ if vim.g.vscode then - return + return end - - vim.diagnostic.config({ - underline = true, - signs = { - text = { - [vim.diagnostic.severity.ERROR] = "", - [vim.diagnostic.severity.WARN] = "", - [vim.diagnostic.severity.INFO] = "", - [vim.diagnostic.severity.HINT] = "", -- optional, you can pick any icon + underline = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "", + [vim.diagnostic.severity.WARN] = "", + [vim.diagnostic.severity.INFO] = "", + [vim.diagnostic.severity.HINT] = "", -- optional, you can pick any icon + }, }, - }, - virtual_text = true, -- or { prefix = "●" } for customization - update_in_insert = false, - severity_sort = true, + virtual_text = true, -- or { prefix = "●" } for customization + update_in_insert = false, + severity_sort = true, }) -- Setup for nvim-notify vim.lsp.set_log_level(2) -- Map LSP message types (1=Error, 2=Warning, 3=Info, 4=Log) to vim.log.levels local severity_map = { - [1] = vim.log.levels.ERROR, - [2] = vim.log.levels.WARN, - [3] = vim.log.levels.INFO, - [4] = vim.log.levels.DEBUG, + [1] = vim.log.levels.ERROR, + [2] = vim.log.levels.WARN, + [3] = vim.log.levels.INFO, + [4] = vim.log.levels.DEBUG, } vim.lsp.handlers["window/showMessage"] = function(_, result, ctx, _) - local lvl = severity_map[result.type] or vim.log.levels.INFO - if vim.lsp.log.should_log(lvl) then - local client = vim.lsp.get_client_by_id(ctx.client_id) - local title = client and ("LSP | " .. client.name) or "LSP" - vim.notify(result.message, lvl, { title = title }) - end + local lvl = severity_map[result.type] or vim.log.levels.INFO + if vim.lsp.log.should_log(lvl) then + local client = vim.lsp.get_client_by_id(ctx.client_id) + local title = client and ("LSP | " .. client.name) or "LSP" + vim.notify(result.message, lvl, { title = title }) + end end -- symbols for autocomplete vim.lsp.protocol.CompletionItemKind = { - "  (Text) ", - "  (Method)", - "  (Function)", - "  (Constructor)", - " ﴲ (Field)", - "[] (Variable)", - "  (Class)", - " ﰮ (Interface)", - "  (Module)", - " 襁 (Property)", - "  (Unit)", - "  (Value)", - " 練 (Enum)", - "  (Keyword)", - "  (Snippet)", - "  (Color)", - "  (File)", - "  (Reference)", - "  (Folder)", - "  (EnumMember)", - " ﲀ (Constant)", - " ﳤ (Struct)", - "  (Event)", - "  (Operator)", - "  (TypeParameter)" + "  (Text) ", + "  (Method)", + "  (Function)", + "  (Constructor)", + " ﴲ (Field)", + "[] (Variable)", + "  (Class)", + " ﰮ (Interface)", + "  (Module)", + " 襁 (Property)", + "  (Unit)", + "  (Value)", + " 練 (Enum)", + "  (Keyword)", + "  (Snippet)", + "  (Color)", + "  (File)", + "  (Reference)", + "  (Folder)", + "  (EnumMember)", + " ﲀ (Constant)", + " ﳤ (Struct)", + "  (Event)", + "  (Operator)", + "  (TypeParameter)" } @@ -74,73 +72,73 @@ vim.keymap.set('n', 'e', 'Lspsaga show_line_diagnostics', { nor -- Send diagnostics to location list vim.keymap.set('n', 'q', function() - vim.diagnostic.setloclist() + vim.diagnostic.setloclist() end, { noremap = true, silent = true }) -- Global mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions vim.keymap.set('n', 'e', vim.diagnostic.open_float) vim.keymap.set('n', ']d', function() - vim.diagnostic.jump_next() + vim.diagnostic.goto_next() end, { desc = "Go to next diagnostic" }) vim.keymap.set('n', '[d', function() - vim.diagnostic.jump_prev() + vim.diagnostic.goto_prev() end, { desc = "Go to previous diagnostic" }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- Use LspAttach autocommand to only map the following keys -- after the language server attaches to the current buffer vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - -- Enable completion triggered by - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - 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', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - vim.keymap.set('n', 'f', function() - vim.lsp.buf.format { async = true } - end, opts) - end, + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + 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', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() + vim.lsp.buf.format { async = true } + end, opts) + end, }) vim.lsp.config("lua_ls", { - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using - version = "LuaJIT", - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim" }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - telemetry = { - -- Do not send telemetry data containing a randomized but unique identifier - enable = false, - }, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using + version = "LuaJIT", + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + -- Do not send telemetry data containing a randomized but unique identifier + enable = false, + }, + }, }, - }, }) @@ -151,41 +149,41 @@ local neodev = require("neodev") neodev.setup({}) vim.lsp.config("lua_ls", { - settings = { - Lua = { - runtime = { version = "LuaJIT" }, - diagnostics = { globals = { "vim" } }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { enable = false }, + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + diagnostics = { globals = { "vim" } }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + telemetry = { enable = false }, + }, }, - }, }) vim.lsp.config('gopls', { - cmd = { "gopls" }, - filetypes = { "go", "gomod", "gowork", "gotmpl" }, - root_markers = { "go.work", "go.mod", ".git" }, - settings = { - gopls = { - analyses = { - unusedparams = true, - shadow = true, - }, - staticcheck = true, + cmd = { "gopls" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + root_markers = { "go.work", "go.mod", ".git" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + }, + staticcheck = true, + }, }, - }, }) vim.lsp.enable 'lua_ls' vim.lsp.enable 'gopls' vim.lsp.config('expert', { - cmd = { 'expert' }, - root_markers = { 'mix.exs', '.git' }, - filetypes = { 'elixir', 'eelixir', 'heex' }, + cmd = { 'expert' }, + root_markers = { 'mix.exs', '.git' }, + filetypes = { 'elixir', 'eelixir', 'heex' }, }) vim.lsp.enable 'expert' diff --git a/.config/nvim/after/plugin/neotest.lua b/.config/nvim/after/plugin/neotest.lua index da5c9c8..29e8bd8 100644 --- a/.config/nvim/after/plugin/neotest.lua +++ b/.config/nvim/after/plugin/neotest.lua @@ -16,18 +16,7 @@ vim.diagnostic.config({ }, }, neotest_ns) -neotest.setup({ - log_level = vim.log.levels.DEBUG, - adapters = { - require("neotest-elixir")({ - args = { "--trace" }, - write_delay = 0, - }), - require("neotest-rust"), - -- require("neotest-vim-test")({ allow_file_types = { "haskell"} }), - require("neotest-golang") - }, -}) + nnoremap("nt", function() neotest.run.run() diff --git a/.config/nvim/after/plugin/notify.lua b/.config/nvim/after/plugin/notify.lua deleted file mode 100644 index 9ea7077..0000000 --- a/.config/nvim/after/plugin/notify.lua +++ /dev/null @@ -1,9 +0,0 @@ -if vim.g.vscode then - return -end - -require('notify').setup({ - background_colour = "#000000", - max_width = 120, - max_height = 10, -}) diff --git a/.config/nvim/after/plugin/sneak.lua b/.config/nvim/after/plugin/sneak.lua deleted file mode 100644 index b5513a0..0000000 --- a/.config/nvim/after/plugin/sneak.lua +++ /dev/null @@ -1,12 +0,0 @@ -if vim.g.vscode then - return -end - --- Sneak -vim.g["sneak#label"] = 1 -vim.g["sneak#prompt"] = "🔎" -vim.g["sneak#s_next"] = 1 - --- Vim-Test -vim.g["test#strategy"] = "neovim" -vim.g["test#neovim#term_position"] = "vert rightbelow 80" diff --git a/.config/nvim/lua/halfdan/autocmds.lua b/.config/nvim/lua/halfdan/autocmds.lua index bffe5c9..79fefaa 100644 --- a/.config/nvim/lua/halfdan/autocmds.lua +++ b/.config/nvim/lua/halfdan/autocmds.lua @@ -1,10 +1,11 @@ -local vim = vim -local api = vim.api - vim.cmd([[autocmd TermOpen * setlocal nonumber norelativenumber]]) -local format_group = api.nvim_create_augroup("FormatGroup", { clear = true }) -api.nvim_create_autocmd( - { "BufWinEnter", "BufReadPost" }, - { pattern = "*", command = "normal zR", group = format_group } -) +vim.api.nvim_create_autocmd("FileType", { + pattern = { "norg", "neorg" }, + callback = function() + if pcall(vim.treesitter.start) then + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + end, +}) diff --git a/.config/nvim/lua/halfdan/cmp.lua b/.config/nvim/lua/halfdan/cmp.lua deleted file mode 100644 index 97a5970..0000000 --- a/.config/nvim/lua/halfdan/cmp.lua +++ /dev/null @@ -1,96 +0,0 @@ -local cmp = require'cmp' -local lspkind = require('lspkind') - -local source_mapping = { - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - nvim_lua = "[Lua]", - path = "[Path]", -} - -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({ - preselect = cmp.PreselectMode.None, - snippet = { - expand = function(args) - vim.snippet.expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = false, -- only confirm if explicitly selected - }, - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif vim.snippet.active({ direction = 1 }) then - vim.snippet.jump(1) - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif vim.snippet.active({ direction = -1 }) then - vim.snippet.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - }, { - { name = "buffer" }, - }), - - formatting = { - format = function(entry, vim_item) - vim_item.kind = lspkind.presets.default[vim_item.kind] - local menu = source_mapping[entry.source.name] - vim_item.menu = menu - return vim_item - end, - }, - - experimental = { - ghost_text = true, - }, -}) - --- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline({ '/', '?' }, { - sources = { - { name = 'buffer' } - } -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }), - mappings = cmp.mapping.preset.cmdline(), -}) - diff --git a/.config/nvim/lua/halfdan/debugger/init.lua b/.config/nvim/lua/halfdan/debugger/init.lua index 133f773..b61ff8d 100644 --- a/.config/nvim/lua/halfdan/debugger/init.lua +++ b/.config/nvim/lua/halfdan/debugger/init.lua @@ -1,4 +1,3 @@ -local dap = require("dap") local dapui = require("dapui") local daptext = require("nvim-dap-virtual-text") @@ -81,37 +80,37 @@ end dap.adapters.mix_task = { - type = 'executable', - command = '/usr/local/opt/elixir-ls/rel/debugger.sh', -- debugger.bat for windows - args = {} + type = 'executable', + command = '/usr/local/opt/elixir-ls/rel/debugger.sh', -- debugger.bat for windows + args = {} } dapgo.setup() dap.configurations.elixir = { - { - type = 'mix_task', - name = 'mix test', - request = 'launch', - task = 'test', - taskArgs = { '--trace' }, - startApps = false, - projectDir = "${workspaceFolder}", - requireFiles = { "test/**/test_helper.exs", "test/**/*_test.exs" } - }, - { - name = "mix test focused", - type = "mix_task", - request = "launch", - taskArgs = { - "${relativeFile}:${lineNumber}", - "--color", - "--trace" + { + type = 'mix_task', + name = 'mix test', + request = 'launch', + task = 'test', + taskArgs = { '--trace' }, + startApps = false, + projectDir = "${workspaceFolder}", + requireFiles = { "test/**/test_helper.exs", "test/**/*_test.exs" } }, - projectDir = "${workspaceRoot}", - requireFiles = { - "test/**/test_helper.exs", - "test/**/*_test.exs" + { + name = "mix test focused", + type = "mix_task", + request = "launch", + taskArgs = { + "${relativeFile}:${lineNumber}", + "--color", + "--trace" + }, + projectDir = "${workspaceRoot}", + requireFiles = { + "test/**/test_helper.exs", + "test/**/*_test.exs" + } } - } } diff --git a/.config/nvim/lua/halfdan/globals.lua b/.config/nvim/lua/halfdan/globals.lua deleted file mode 100644 index ed83901..0000000 --- a/.config/nvim/lua/halfdan/globals.lua +++ /dev/null @@ -1,25 +0,0 @@ -O = { - auto_close_tree = 0, - auto_complete = true, - background = 'dark', - ignorecase = 'smartcase', - clipboard = 'unnamedplus', - incsearch = true, - termguicolors = true, - colorscheme = 'monokai-pro', - hidden_files = true, - wrap_lines = false, - number = true, - relative_number = true, - shell = 'zsh', - timeoutlen = 500, - scrolloff = 8, - noshowmode = true, - splitright = true, - splitbelow = true, - - database = {save_location = '~/.config/nvcode_db', auto_execute = 1}, -} - -DATA_PATH = vim.fn.stdpath('data') -CACHE_PATH = vim.fn.stdpath('cache') diff --git a/.config/nvim/lua/halfdan/init.lua b/.config/nvim/lua/halfdan/init.lua index 3512842..4bc0893 100644 --- a/.config/nvim/lua/halfdan/init.lua +++ b/.config/nvim/lua/halfdan/init.lua @@ -4,19 +4,13 @@ if vim.g.vscode then -- VSCode extension else -- ordinary Neovim - require("halfdan.lazy") - vim.notify = require("notify") + require("halfdan.lazy") - require("halfdan.neogit") - -- require('halfdan.globals') - require('halfdan.keymap') - -- require('halfdan.cmp') - require('halfdan.colorscheme') - require('halfdan.treesitter') - require('halfdan.telescope') - require('halfdan.lualine') + require('halfdan.keymap') + require('halfdan.colorscheme') + require('halfdan.lualine') - require('halfdan.autocmds') + require('halfdan.autocmds') - require('halfdan.debugger') + require('halfdan.debugger') end diff --git a/.config/nvim/lua/halfdan/lazy.lua b/.config/nvim/lua/halfdan/lazy.lua index 9107a1a..612c2f8 100644 --- a/.config/nvim/lua/halfdan/lazy.lua +++ b/.config/nvim/lua/halfdan/lazy.lua @@ -1,376 +1,24 @@ +if vim.g.vscode then + return +end + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) -if vim.g.vscode then - return -end - require("lazy").setup({ - { - "NeogitOrg/neogit", - dependencies = { - "nvim-lua/plenary.nvim", -- required - "nvim-telescope/telescope.nvim", -- optional - "sindrets/diffview.nvim", -- optional - "ibhagwan/fzf-lua", -- optional + spec = { + -- import your plugins + { import = "halfdan.plugins" }, }, - config = true - }, - {'airblade/vim-gitgutter'}, - - -- Load .editorconfig files - {'editorconfig/editorconfig-vim'}, - - { - "m4xshen/hardtime.nvim", - lazy = false, - dependencies = { "MunifTanjim/nui.nvim" }, - opts = {}, - }, - { - "karb94/neoscroll.nvim", - opts = {}, - }, - {'junegunn/vim-easy-align'}, - - -- Goodies - {'tpope/vim-fugitive'}, - {'tpope/vim-surround'}, -- ✅ - {'tpope/vim-dispatch'}, - - -- Treesitter - { - 'nvim-treesitter/nvim-treesitter', - branch = 'main', - build = ':TSUpdate', - }, - - -- Testing - {'vim-test/vim-test'}, - { - "nvim-neotest/neotest", - dependencies = { - "nvim-neotest/nvim-nio", - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - "antoinemadec/FixCursorHold.nvim", - -- plugins - "fredrikaverpil/neotest-golang", - "jfpedroza/neotest-elixir", - "rouge8/neotest-rust", - } - }, - {"nvim-neotest/neotest-vim-test" }, - {'akinsho/toggleterm.nvim', version = "*", config = function() - require('toggleterm').setup({ - open_mapping = [[]], - start_in_insert = true, - direction = "horizontal", - autochdir = false, - size = 20, - highlights = { - FloatBorder = { link = "ToggleTermBorder" }, - Normal = { link = "ToggleTerm" }, - NormalFloat = { link = "ToggleTerm" }, - }, - winbar = { - enabled = true, - name_formatter = function(term) - return term.name - end, - }, - }) - end}, - - {'f-person/git-blame.nvim'}, - -- Status Line and Bufferline - { - 'nvim-lualine/lualine.nvim', - dependencies = {'kyazdani42/nvim-web-devicons'}, - event = { "BufReadPost", "BufNewFile" }, - opts = function() - local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim") - return { - float = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), - separator = "bubble", -- bubble | triangle - ---@type any - colorful = true, - } - end, - config = function(_, opts) - local lualine_config = require("halfdan.lualine") - lualine_config.setup(opts) - lualine_config.load() - end, - }, - - {'rcarriga/nvim-notify'}, - - { - "nvim-neorg/neorg", - lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default - version = "*", -- Pin Neorg to the latest stable release - config = function() - require('neorg').setup({ - load = { - ["core.defaults"] = {}, - ["core.dirman"] = { - config = { - workspaces = { - work = "~/org/work", - home = "~/org/home", - }, - index = "index.norg", - } - }, - -- ["core.completion"] = { - -- config = { - -- engine = "nvim-cmp", - -- }, - -- }, - ["core.concealer"] = {}, - ["core.journal"] = { - config = { - strategy = "flat", - }, - }, - ["core.integrations.telescope"] = {}, - } - }) - end, - }, - {'nvim-neorg/neorg-telescope'}, - - {'justinmk/vim-sneak'}, - - {'machakann/vim-highlightedyank'}, - - { - 'nvimdev/lspsaga.nvim', - config = function() - require('lspsaga').setup({ - symbol_in_winbar = { - enable = false, - }, - lightbulb = { - enable = false, - } - }) - end, - dependencies = { - 'nvim-treesitter/nvim-treesitter', -- optional - 'nvim-tree/nvim-web-devicons' -- optional - } - }, - - -- { - -- 'hrsh7th/nvim-cmp', - -- dependencies = { - -- { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' }, - -- 'hrsh7th/cmp-nvim-lsp', - -- 'onsails/lspkind.nvim', - -- { 'hrsh7th/cmp-path', after = 'nvim-cmp' }, - -- { 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' }, - -- { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp', event = 'CmdlineEnter' }, - -- {'petertriho/cmp-git', after = 'nvim-cmp'}, - -- } - -- }, - { - 'saghen/blink.cmp', - dependencies = { 'rafamadriz/friendly-snippets' }, - version = '1.*', - -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust - -- build = 'cargo build --release', - -- If you use nix, you can build from source using latest nightly rust with: - -- build = 'nix run .#build-plugin', - - ---@module 'blink.cmp' - ---@type blink.cmp.Config - opts = { - -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) - -- 'super-tab' for mappings similar to vscode (tab to accept) - -- 'enter' for enter to accept - -- 'none' for no mappings - -- - -- All presets have the following mappings: - -- C-space: Open menu or open docs if already open - -- C-n/C-p or Up/Down: Select next/previous item - -- C-e: Hide menu - -- C-k: Toggle signature help (if signature.enabled = true) - -- - -- See :h blink-cmp-config-keymap for defining your own keymap - keymap = { preset = 'super-tab' }, - - appearance = { - -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- Adjusts spacing to ensure icons are aligned - nerd_font_variant = 'mono' - }, - - -- (Default) Only show the documentation popup when manually triggered - completion = { documentation = { auto_show = false } }, - - -- Default list of enabled providers defined so that you can extend it - -- elsewhere in your config, without redefining it, due to `opts_extend` - sources = { - default = { 'lsp', 'path', 'snippets', 'buffer' }, - }, - - -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance - -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, - -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` - -- - -- See the fuzzy documentation for more information - fuzzy = { implementation = "prefer_rust" } - }, - opts_extend = { "sources.default" } - }, - - -- Used to display LSP status in Lualine - {'nvim-lua/lsp-status.nvim'}, - - { - "hedyhli/outline.nvim", - lazy = true, - cmd = { "Outline", "OutlineOpen" }, - keys = { -- Example mapping to toggle outline - { "o", "Outline", desc = "Toggle outline" }, - }, - opts = { - -- Your setup opts here - }, - }, - { - 'numToStr/Comment.nvim', - config = function() - require('Comment').setup() - end - }, - - -- Telescope fuzzy find files/grep - {'nvim-lua/popup.nvim'}, - {'nvim-lua/plenary.nvim'}, - { - "fdschmidt93/telescope-egrepify.nvim", - dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } - }, - {'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - {'nvim-telescope/telescope.nvim'}, - {'nvim-telescope/telescope-dap.nvim'}, - { - "danielfalk/smart-open.nvim", - branch = "0.2.x", - dependencies = {"kkharji/sqlite.lua"} - }, - - {'numToStr/FTerm.nvim'}, - - -- Debugging - "mfussenegger/nvim-dap", - "rcarriga/nvim-dap-ui", - "nvim-neotest/nvim-nio", - "theHamsta/nvim-dap-virtual-text", - "leoluz/nvim-dap-go", - - -- => Language Support - { - "folke/neodev.nvim", - config = function() - require("neodev").setup({}) - end - }, - {'neovim/nvim-lspconfig'}, - {'rust-lang/rust.vim'}, - { - 'mrcjkb/rustaceanvim', - version = '^6', -- Recommended - lazy = false, -- This plugin is already lazy - }, - {'tpope/vim-projectionist'}, - - -- themes & colorschemes - { "rose-pine/neovim", name = "rose-pine" }, - {'luisiacc/gruvbox-baby'}, - {'akinsho/bufferline.nvim', version = "*", dependencies = 'nvim-tree/nvim-web-devicons', - keys = { - { "", "BufferLineGoToBuffer 1", desc = "Go to buffer 1" }, - { "", "BufferLineGoToBuffer 2", desc = "Go to buffer 2" }, - { "", "BufferLineGoToBuffer 3", desc = "Go to buffer 3" }, - { "", "BufferLineGoToBuffer 4", desc = "Go to buffer 4" }, - { "", "BufferLineGoToBuffer 5", desc = "Go to buffer 5" }, - { "", "BufferLineGoToBuffer 6", desc = "Go to buffer 6" }, - { "", "BufferLineGoToBuffer 7", desc = "Go to buffer 7" }, - { "", "BufferLineGoToBuffer 8", desc = "Go to buffer 8" }, - { "", "BufferLineGoToBuffer 9", desc = "Go to buffer 9" }, - { "", "BufferLineCycleNext", desc = "Next buffer" }, - { "", "BufferLineCyclePrev", desc = "Previous buffer" }, - { "", "BufferLineMoveNext", desc = "Move buffer right" }, - { "", "BufferLineMovePrev", desc = "Move buffer left" }, - }, - opts = function() - local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim") - return { - options = { - diagnostics = "nvim_lsp", -- | "nvim_lsp" | "coc", - -- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' }, - separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' }, - -- separator_style = "slant", -- | "thick" | "thin" | { 'any', 'any' }, - indicator = { - -- icon = " ", - -- style = 'icon', - style = "underline", - }, - close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" - diagnostics_indicator = function(count, _, _, _) - if count > 9 then - return "9+" - end - return tostring(count) - end, - numbers = function(opts) - return string.format('%s', opts.raise(opts.ordinal)) - end, - offsets = { - { - filetype = "neo-tree", - text = "EXPLORER", - text_align = "center", - separator = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), -- set to `true` if clear background of neo-tree - }, - { - filetype = "NvimTree", - text = "EXPLORER", - text_align = "center", - separator = vim.tbl_contains(monokai_opts.background_clear or {}, "nvim-tree"), -- set to `true` if clear background of neo-tree - }, - }, - hover = { - enabled = true, - delay = 0, - reveal = { "close" }, - }, - }, - } - end, - }, - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information - } - } + checker = { enabled = true }, }) diff --git a/.config/nvim/lua/halfdan/neogit.lua b/.config/nvim/lua/halfdan/neogit.lua deleted file mode 100644 index 0a21aec..0000000 --- a/.config/nvim/lua/halfdan/neogit.lua +++ /dev/null @@ -1,12 +0,0 @@ -local neogit = require('neogit') -local nnoremap = require('halfdan.keymap').nnoremap - -neogit.setup { - integrations = { - diffview = true - } -} - -nnoremap("gs", function() - neogit.open({kind='split'}) -end) diff --git a/.config/nvim/lua/halfdan/plugins/blink.lua b/.config/nvim/lua/halfdan/plugins/blink.lua new file mode 100644 index 0000000..106d5c4 --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/blink.lua @@ -0,0 +1,55 @@ +return { + + + { + 'saghen/blink.cmp', + dependencies = { 'rafamadriz/friendly-snippets' }, + version = '1.*', + -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'super-tab' }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono' + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = false } }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + }, + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust" } + }, + opts_extend = { "sources.default" } + }, + +} diff --git a/.config/nvim/lua/halfdan/plugins/debugging.lua b/.config/nvim/lua/halfdan/plugins/debugging.lua new file mode 100644 index 0000000..b4083ce --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/debugging.lua @@ -0,0 +1,8 @@ +return { + -- Debugging + "mfussenegger/nvim-dap", + "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", + "theHamsta/nvim-dap-virtual-text", + "leoluz/nvim-dap-go", +} diff --git a/.config/nvim/lua/halfdan/plugins/lsp.lua b/.config/nvim/lua/halfdan/plugins/lsp.lua new file mode 100644 index 0000000..d1db080 --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/lsp.lua @@ -0,0 +1,35 @@ +return { + -- => Language Support + { + 'nvimdev/lspsaga.nvim', + config = function() + require('lspsaga').setup({ + symbol_in_winbar = { + enable = false, + }, + lightbulb = { + enable = false, + } + }) + end, + dependencies = { + 'nvim-treesitter/nvim-treesitter', -- optional + 'nvim-tree/nvim-web-devicons' -- optional + } + }, + { + "folke/neodev.nvim", + config = function() + require("neodev").setup({}) + end + }, + { 'neovim/nvim-lspconfig' }, + { 'rust-lang/rust.vim' }, + { + 'mrcjkb/rustaceanvim', + version = '^6', -- Recommended + lazy = false, -- This plugin is already lazy + }, + -- Used to display LSP status in Lualine + { 'nvim-lua/lsp-status.nvim' }, +} diff --git a/.config/nvim/lua/halfdan/plugins/neogit.lua b/.config/nvim/lua/halfdan/plugins/neogit.lua new file mode 100644 index 0000000..717e3c1 --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/neogit.lua @@ -0,0 +1,18 @@ +return { + { + "NeogitOrg/neogit", + dependencies = { + "nvim-lua/plenary.nvim", -- required + "nvim-telescope/telescope.nvim", -- optional + "sindrets/diffview.nvim", -- optional + "ibhagwan/fzf-lua", -- optional + }, + config = function() + require("neogit").setup({ + integrations = { + diffview = true + } + }) + end + }, +} diff --git a/.config/nvim/lua/halfdan/plugins/neorg.lua b/.config/nvim/lua/halfdan/plugins/neorg.lua new file mode 100644 index 0000000..390c565 --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/neorg.lua @@ -0,0 +1,36 @@ +return { + { + "nvim-neorg/neorg", + lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default + version = "*", -- Pin Neorg to the latest stable release + config = function() + require('neorg').setup({ + load = { + ["core.defaults"] = {}, + ["core.dirman"] = { + config = { + workspaces = { + work = "~/org/work", + home = "~/org/home", + }, + index = "index.norg", + } + }, + -- ["core.completion"] = { + -- config = { + -- engine = "nvim-cmp", + -- }, + -- }, + ["core.concealer"] = {}, + ["core.journal"] = { + config = { + strategy = "flat", + }, + }, + ["core.integrations.telescope"] = {}, + } + }) + end, + }, + { 'nvim-neorg/neorg-telescope' }, +} diff --git a/.config/nvim/lua/halfdan/plugins/neotest.lua b/.config/nvim/lua/halfdan/plugins/neotest.lua new file mode 100644 index 0000000..63ffb3e --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/neotest.lua @@ -0,0 +1,28 @@ +return { + -- Testing + { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + -- plugins + "fredrikaverpil/neotest-golang", + "jfpedroza/neotest-elixir", + "rouge8/neotest-rust", + }, + config = function() + require("neotest").setup({ + log_level = vim.log.levels.DEBUG, + adapters = { + require("neotest-elixir")({ + args = { "--trace" }, + write_delay = 0, + }), + require("neotest-rust"), + require("neotest-golang") + }, + }) + end + }, +} diff --git a/.config/nvim/lua/halfdan/plugins/other.lua b/.config/nvim/lua/halfdan/plugins/other.lua new file mode 100644 index 0000000..a6697bb --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/other.lua @@ -0,0 +1,105 @@ +return { + + { 'airblade/vim-gitgutter' }, + + -- Load .editorconfig files + { 'editorconfig/editorconfig-vim' }, + + { + "m4xshen/hardtime.nvim", + lazy = false, + dependencies = { "MunifTanjim/nui.nvim" }, + opts = {}, + }, + { + "karb94/neoscroll.nvim", + opts = {}, + }, + { 'junegunn/vim-easy-align' }, + + -- Goodies + { 'tpope/vim-fugitive' }, + { 'tpope/vim-surround' }, + { 'tpope/vim-dispatch' }, + + { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + require('toggleterm').setup({ + open_mapping = [[]], + start_in_insert = true, + direction = "horizontal", + autochdir = false, + size = 20, + highlights = { + FloatBorder = { link = "ToggleTermBorder" }, + Normal = { link = "ToggleTerm" }, + NormalFloat = { link = "ToggleTerm" }, + }, + winbar = { + enabled = true, + name_formatter = function(term) + return term.name + end, + }, + }) + end + }, + + { 'f-person/git-blame.nvim' }, + { + 'justinmk/vim-sneak', + config = function() + vim.g["sneak#label"] = 1 + vim.g["sneak#prompt"] = "🔎" + vim.g["sneak#s_next"] = 1 + + -- Vim-Test + vim.g["test#strategy"] = "neovim" + vim.g["test#neovim#term_position"] = "vert rightbelow 80" + end + }, + + { 'machakann/vim-highlightedyank' }, + + + + { + "hedyhli/outline.nvim", + lazy = true, + cmd = { "Outline", "OutlineOpen" }, + keys = { -- Example mapping to toggle outline + { "o", "Outline", desc = "Toggle outline" }, + }, + opts = { + -- Your setup opts here + }, + }, + { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup() + end + }, + + { + 'tpope/vim-projectionist', + config = function() + vim.g.projectionist_heuristics = { + ["*.go"] = { + ["*.go"] = { + alternate = "{}_test.go", + type = "source", + }, + ["*_test.go"] = { + alternate = "{}.go", + type = "test", + }, + }, + } + end + }, + + +} diff --git a/.config/nvim/lua/halfdan/plugins/telescope.lua b/.config/nvim/lua/halfdan/plugins/telescope.lua new file mode 100644 index 0000000..5d1149e --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/telescope.lua @@ -0,0 +1,86 @@ +return { + { + "fdschmidt93/telescope-egrepify.nvim", + dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } + }, + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + { + 'nvim-telescope/telescope.nvim', + config = function() + local actions = require('telescope.actions') + + -- Global remapping + require('telescope').setup { + defaults = { + -- find_command = { 'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' }, + file_ignore_patterns = { "_build", "node_modules", "deps", ".git", ".elixir_ls" }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + -- borderchars = { "█", " ", "▀", "█", "█", " ", " ", "▀" }, + file_sorter = require 'telescope'.extensions.fzf.get_fzf_sorter, + -- Developer configurations: Not meant for general override + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + -- To disable a keymap, put [map] = false + -- So, to not map "", just put + -- [""] = false, + + -- Otherwise, just set the mapping to the function that you want it to be. + -- [""] = actions.select_horizontal, + + -- Add up multiple actions + [""] = actions.select_default + actions.center + + -- You can perform as many actions in a row as you like + -- [""] = actions.select_default + actions.center + my_cool_custom_action, + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + [""] = actions.close, + -- [""] = my_cool_custom_action, + } + } + }, + pickers = { + buffers = { + mappings = { + n = { + ['d'] = actions.delete_buffer + }, -- n + i = { + [''] = actions.delete_buffer + }, + } + } + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + 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" + -- the default case_mode is "smart_case" + filename_first = true + } + }, + } + + require('telescope').load_extension("fzf") + require('telescope').load_extension("dap") + require('telescope').load_extension("smart_open") + require('telescope').load_extension("egrepify") + end + }, + { 'nvim-telescope/telescope-dap.nvim' }, + { + "danielfalk/smart-open.nvim", + branch = "0.2.x", + dependencies = { "kkharji/sqlite.lua" } + }, +} diff --git a/.config/nvim/lua/halfdan/plugins/themes.lua b/.config/nvim/lua/halfdan/plugins/themes.lua new file mode 100644 index 0000000..00c7b3b --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/themes.lua @@ -0,0 +1,7 @@ +return { + -- themes & colorschemes + { "rose-pine/neovim", name = "rose-pine" }, + { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, + { 'luisiacc/gruvbox-baby' }, + { "rebelot/kanagawa.nvim" } +} diff --git a/.config/nvim/lua/halfdan/plugins/treesitter.lua b/.config/nvim/lua/halfdan/plugins/treesitter.lua new file mode 100644 index 0000000..60e5250 --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/treesitter.lua @@ -0,0 +1,84 @@ +local function register(ensure_installed) + for filetype, parser in pairs(ensure_installed) do + local filetypes = vim.treesitter.language.get_filetypes(parser) + if not vim.tbl_contains(filetypes, filetype) then + table.insert(filetypes, filetype) + end + + -- register and start parsers for filetypes + vim.treesitter.language.register(parser, filetypes) + end +end + +--- Install and start parsers for nvim-treesitter. +local function install_and_start() + -- Auto-install and start treesitter parser for any buffer with a registered filetype + vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function(event) + local bufnr = event.buf + local filetype = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) + + -- Skip if no filetype + if filetype == "" then + return + end + + -- Get parser name based on filetype + local parser_name = vim.treesitter.language.get_lang(filetype) -- WARNING: might return filetype (not helpful) + if not parser_name then + return + end + + vim.notify( + vim.inspect("Successfully got parser " .. parser_name .. " for filetype " .. filetype), + vim.log.levels.DEBUG, + { title = "core/treesitter" } + ) + + -- Check if parser_name is available in parser configs + local parser_configs = require("nvim-treesitter.parsers") + local parser_can_be_used = parser_configs[parser_name] + if not parser_can_be_used then + return -- Parser not ailable, skip silently + end + + local parser_installed = pcall(vim.treesitter.get_parser, bufnr, parser_name) + + -- If not installed, install parser synchronously + if not parser_installed then + require("nvim-treesitter").install({ parser_name }):wait(30000) -- main branch syntax + vim.notify("Installed parser: " .. parser_name, vim.log.levels.INFO, { title = "core/treesitter" }) + end + + -- Check so tree-sitter can see the newly installed parser + parser_installed = pcall(vim.treesitter.get_parser, bufnr, parser_name) + if not parser_installed then + return + end + + -- Start treesitter for this buffer + vim.treesitter.start(bufnr, parser_name) + end, + }) +end + +return { + -- Treesitter + { + 'nvim-treesitter/nvim-treesitter', + lazy = false, + branch = 'main', + build = ':TSUpdate', + opts = { + ensure_installed = { "python", "go", "elixir", "heex", "rust", "gomod", "json", "lua", "yaml", "norg", + "query", "markdown", "markdown_inline", "gleam", "zig", "odin", "terraform", "hcl" } + }, + config = function(_, opts) + -- Register parsers from opts.ensure_installed + register(opts.ensure_installed) + + -- Create autocmd which installs and starts parsers. + install_and_start() + end + }, +} diff --git a/.config/nvim/lua/halfdan/plugins/ui.lua b/.config/nvim/lua/halfdan/plugins/ui.lua new file mode 100644 index 0000000..55c3961 --- /dev/null +++ b/.config/nvim/lua/halfdan/plugins/ui.lua @@ -0,0 +1,108 @@ +return { + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'kyazdani42/nvim-web-devicons' }, + event = { "BufReadPost", "BufNewFile" }, + opts = function() + local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim") + return { + float = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), + separator = "bubble", -- bubble | triangle + ---@type any + colorful = true, + } + end, + config = function(_, opts) + local lualine_config = require("halfdan.lualine") + lualine_config.setup(opts) + lualine_config.load() + end, + }, + { + 'rcarriga/nvim-notify', + config = function() + vim.notify = require('notify') + + require('notify').setup({ + background_colour = "#000000", + max_width = 120, + max_height = 10, + }) + end + }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + } + }, + { + 'akinsho/bufferline.nvim', + version = "*", + dependencies = 'nvim-tree/nvim-web-devicons', + keys = { + { "", "BufferLineGoToBuffer 1", desc = "Go to buffer 1" }, + { "", "BufferLineGoToBuffer 2", desc = "Go to buffer 2" }, + { "", "BufferLineGoToBuffer 3", desc = "Go to buffer 3" }, + { "", "BufferLineGoToBuffer 4", desc = "Go to buffer 4" }, + { "", "BufferLineGoToBuffer 5", desc = "Go to buffer 5" }, + { "", "BufferLineGoToBuffer 6", desc = "Go to buffer 6" }, + { "", "BufferLineGoToBuffer 7", desc = "Go to buffer 7" }, + { "", "BufferLineGoToBuffer 8", desc = "Go to buffer 8" }, + { "", "BufferLineGoToBuffer 9", desc = "Go to buffer 9" }, + { "", "BufferLineCycleNext", desc = "Next buffer" }, + { "", "BufferLineCyclePrev", desc = "Previous buffer" }, + { "", "BufferLineMoveNext", desc = "Move buffer right" }, + { "", "BufferLineMovePrev", desc = "Move buffer left" }, + }, + opts = function() + local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim") + return { + options = { + diagnostics = "nvim_lsp", -- | "nvim_lsp" | "coc", + -- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' }, + separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' }, + -- separator_style = "slant", -- | "thick" | "thin" | { 'any', 'any' }, + indicator = { + -- icon = " ", + -- style = 'icon', + style = "underline", + }, + close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + diagnostics_indicator = function(count, _, _, _) + if count > 9 then + return "9+" + end + return tostring(count) + end, + numbers = function(opts) + return string.format('%s', opts.raise(opts.ordinal)) + end, + offsets = { + { + filetype = "neo-tree", + text = "EXPLORER", + text_align = "center", + separator = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), -- set to `true` if clear background of neo-tree + }, + { + filetype = "NvimTree", + text = "EXPLORER", + text_align = "center", + separator = vim.tbl_contains(monokai_opts.background_clear or {}, "nvim-tree"), -- set to `true` if clear background of neo-tree + }, + }, + hover = { + enabled = true, + delay = 0, + reveal = { "close" }, + }, + }, + } + end, + }, +} diff --git a/.config/nvim/lua/halfdan/telescope-project.lua b/.config/nvim/lua/halfdan/telescope-project.lua deleted file mode 100644 index 1027025..0000000 --- a/.config/nvim/lua/halfdan/telescope-project.lua +++ /dev/null @@ -1,8 +0,0 @@ -if vim.g.vscode then - return -end - --- Global remapping ------------------------------- --- '--color=never', -require'telescope'.load_extension('project') diff --git a/.config/nvim/lua/halfdan/telescope.lua b/.config/nvim/lua/halfdan/telescope.lua deleted file mode 100644 index 09b6d12..0000000 --- a/.config/nvim/lua/halfdan/telescope.lua +++ /dev/null @@ -1,68 +0,0 @@ -local actions = require('telescope.actions') - --- Global remapping -require('telescope').setup { - defaults = { - -- find_command = { 'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' }, - file_ignore_patterns = { "_build", "node_modules", "deps", ".git", ".elixir_ls" }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - -- borderchars = { "█", " ", "▀", "█", "█", " ", " ", "▀" }, - file_sorter = require 'telescope'.extensions.fzf.get_fzf_sorter, - -- Developer configurations: Not meant for general override - mappings = { - i = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.smart_send_to_qflist + actions.open_qflist, - -- To disable a keymap, put [map] = false - -- So, to not map "", just put - -- [""] = false, - - -- Otherwise, just set the mapping to the function that you want it to be. - -- [""] = actions.select_horizontal, - - -- Add up multiple actions - [""] = actions.select_default + actions.center - - -- You can perform as many actions in a row as you like - -- [""] = actions.select_default + actions.center + my_cool_custom_action, - }, - n = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.smart_send_to_qflist + actions.open_qflist, - [""] = actions.close, - -- [""] = my_cool_custom_action, - } - } - }, - pickers = { - buffers = { - mappings = { - n = { - ['d'] = actions.delete_buffer - }, -- n - i = { - [''] = actions.delete_buffer - }, - } - } - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - 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" - -- the default case_mode is "smart_case" - filename_first = true - } - }, -} - -require('telescope').load_extension("fzf") -require('telescope').load_extension("dap") -require('telescope').load_extension("smart_open") -require('telescope').load_extension("egrepify") diff --git a/.config/nvim/lua/halfdan/treesitter.lua b/.config/nvim/lua/halfdan/treesitter.lua deleted file mode 100644 index bb998d1..0000000 --- a/.config/nvim/lua/halfdan/treesitter.lua +++ /dev/null @@ -1,23 +0,0 @@ -if vim.g.vscode then - return -end - -require('nvim-treesitter').setup({ - ensure_installed = { "python", "go", "elixir", "heex", "rust", "gomod", "json", "lua", "yaml", "norg", "query", "markdown", "markdown_inline", "gleam", "zig", "odin"}, - ignore_install = { "haskell" }, - highlight = { - enable = true, - }, - indent = { - enable = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, -})