diff --git a/configs/nvim/.gitignore b/configs/nvim/.gitignore deleted file mode 100644 index b63c6db..0000000 --- a/configs/nvim/.gitignore +++ /dev/null @@ -1 +0,0 @@ -./plugin/ diff --git a/configs/nvim/.stylua.toml b/configs/nvim/.stylua.toml new file mode 100644 index 0000000..139e939 --- /dev/null +++ b/configs/nvim/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 160 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferSingle" +call_parentheses = "None" diff --git a/configs/nvim/after/plugin/colors.lua b/configs/nvim/after/plugin/colors.lua deleted file mode 100644 index 56e5212..0000000 --- a/configs/nvim/after/plugin/colors.lua +++ /dev/null @@ -1,7 +0,0 @@ -function AddTransparency() - vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) - -end - -AddTransparency() diff --git a/configs/nvim/after/plugin/fugitive.lua b/configs/nvim/after/plugin/fugitive.lua deleted file mode 100644 index 2873cef..0000000 --- a/configs/nvim/after/plugin/fugitive.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', 'gs', vim.cmd.Git); diff --git a/configs/nvim/after/plugin/harpoon.lua b/configs/nvim/after/plugin/harpoon.lua deleted file mode 100644 index 058a4b5..0000000 --- a/configs/nvim/after/plugin/harpoon.lua +++ /dev/null @@ -1,10 +0,0 @@ -local mark = require('harpoon.mark') -local ui = require('harpoon.ui') - -vim.keymap.set('n', 'a', mark.add_file) -vim.keymap.set('n', '', ui.toggle_quick_menu) - -vim.keymap.set('n', '', function() ui.nav_file(1) end) -vim.keymap.set('n', '', function() ui.nav_file(2) end) -vim.keymap.set('n', '', function() ui.nav_file(3) end) -vim.keymap.set('n', '', function() ui.nav_file(4) end) diff --git a/configs/nvim/after/plugin/lsp.lua b/configs/nvim/after/plugin/lsp.lua deleted file mode 100644 index f7ad1da..0000000 --- a/configs/nvim/after/plugin/lsp.lua +++ /dev/null @@ -1,33 +0,0 @@ -local lsp = require('lsp-zero') - -lsp.preset('recommended') - -local cmp = require('cmp') -local cmp_select = {behavior = cmp.SelectBehavior.Select} -local cmp_mappings = lsp.defaults.cmp_mappings({ - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.complete() -}) - -lsp.setup_nvim_cmp({ - mapping = cmp_mappings -}) - -lsp.on_attach(function(client, bufnr) - local opts = {buffer = bufnr, remap = false} - - vim.keymap.set('n', 'gd', function() vim.lsp.buf.definition() end, opts) - vim.keymap.set('n', 'K', function() vim.lsp.buf.hover() end, opts) - vim.keymap.set('n', 'vws', function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set('n', 'vd', function() vim.diagnostic.open_float() end, opts) - vim.keymap.set('n', '[d', function() vim.diagnostic.goto_next() end, opts) - vim.keymap.set('n', ']d', function() vim.diagnostic.goto_prev() end, opts) - vim.keymap.set('n', 'vca', function() vim.lsp.buf.code_action() end, opts) - vim.keymap.set('n', 'vrr', function() vim.lsp.buf.references() end, opts) - vim.keymap.set('n', 'vrn', function() vim.lsp.buf.rename() end, opts) - vim.keymap.set('i', '', function() vim.lsp.buf.signature_help() end, opts) -end) - -lsp.setup() diff --git a/configs/nvim/after/plugin/mason.lua b/configs/nvim/after/plugin/mason.lua deleted file mode 100644 index af77151..0000000 --- a/configs/nvim/after/plugin/mason.lua +++ /dev/null @@ -1,9 +0,0 @@ -require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) diff --git a/configs/nvim/after/plugin/nvim_comment.lua b/configs/nvim/after/plugin/nvim_comment.lua deleted file mode 100644 index 2ca6833..0000000 --- a/configs/nvim/after/plugin/nvim_comment.lua +++ /dev/null @@ -1,43 +0,0 @@ --- ## Usage --- --- Either use the command `CommentToggle`, e.g.: --- --- - `CommentToggle` comment/uncomment current line --- - `67,69CommentToggle` comment/uncomment a range --- - `'<,'>CommentToggle` comment/uncomment a visual selection --- --- Or use the default mappings: --- --- - `gcc` comment/uncomment current line, this does not take a count, if you want --- a count use the `gc{count}{motion}` --- - `gc{motion}` comment/uncomment selection defined by a motion (as lines are --- commented, any comment toggling actions will default to a linewise): --- - `gcip` comment/uncomment a paragraph --- - `gc4w` comment/uncomment current line --- - `gc4j` comment/uncomment 4 lines below the current line --- - `dic` delete comment block --- - `gcic` uncomment commented block - -require('nvim_comment').setup( - { - -- Linters prefer comment and line to have a space in between markers - marker_padding = true, - -- should comment out empty or whitespace only lines - comment_empty = true, - -- trim empty comment whitespace - comment_empty_trim_whitespace = true, - -- Should key mappings be created - create_mappings = true, - -- Normal mode mapping left hand side - line_mapping = "gcc", - -- Visual/Operator mapping left hand side - operator_mapping = "gc", - -- text object mapping, comment chunk,, - comment_chunk_text_object = "ic", - -- Hook function to call before commenting takes place - hook = nil - } -) - -vim.keymap.set("v", "", "'<,'>CommentToggle") -vim.keymap.set("n", "", "CommentToggle") diff --git a/configs/nvim/after/plugin/telescope.lua b/configs/nvim/after/plugin/telescope.lua deleted file mode 100644 index 5739a54..0000000 --- a/configs/nvim/after/plugin/telescope.lua +++ /dev/null @@ -1,9 +0,0 @@ -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'pf', builtin.find_files, {}) -vim.keymap.set('n', '', builtin.git_files, {}) -vim.keymap.set('n', 'ps', function() - builtin.grep_string({ search = vim.fn.input("Grep > ") }); -end) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) -vim.keymap.set('n', 'fb', builtin.buffers, {}) -vim.keymap.set('n', 'fh', builtin.help_tags, {}) diff --git a/configs/nvim/after/plugin/treesitter.lua b/configs/nvim/after/plugin/treesitter.lua deleted file mode 100644 index a470643..0000000 --- a/configs/nvim/after/plugin/treesitter.lua +++ /dev/null @@ -1,12 +0,0 @@ -require'nvim-treesitter.configs'.setup { - ensure_installed = { "help", "javascript", "typescript", "python", "c", "lua", "rust" }, - sync_install = false, - auto_install = true, - highlight = { - enable = true, - }, - indent = { - enable = true, - disable = {'python',} - }, -} diff --git a/configs/nvim/after/plugin/undotree.lua b/configs/nvim/after/plugin/undotree.lua deleted file mode 100644 index a346462..0000000 --- a/configs/nvim/after/plugin/undotree.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) diff --git a/configs/nvim/init.lua b/configs/nvim/init.lua index 3bf53fc..7416b15 100644 --- a/configs/nvim/init.lua +++ b/configs/nvim/init.lua @@ -1,2 +1,48 @@ -require('adam') -require('adam.set') +-- Set as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + + +-- [[ Install `lazy.nvim` plugin manager ]] +require 'lazy-bootstrap' + +-- [[ Configure plugins ]] +require 'lazy-plugins' + +-- [[ Setting options ]] +require 'options' + +-- [[ Basic Keymaps ]] +require 'keymaps' + +-- [[ Configure Telescope ]] +-- (fuzzy finder) +require 'telescope-setup' + +-- [[ Configure Treesitter ]] +-- (syntax parser for highlighting) +require 'treesitter-setup' + +-- [[ Configure LSP ]] +-- (Language Server Protocol) +require 'lsp-setup' + +-- [[ Configure nvim-cmp ]] +-- (completion) +require 'cmp-setup' + +function AddTransparency() + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" }) + vim.api.nvim_set_hl(0, "LineNr", { bg = "none" }) + vim.api.nvim_set_hl(0, "GitSignsAdd", { bg = "none" }) + vim.api.nvim_set_hl(0, "GitSignsChange", { bg = "none" }) + vim.api.nvim_set_hl(0, "GitSignsDelete", { bg = "none" }) +end + +AddTransparency() + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/adam/ensure.lua b/configs/nvim/lua/adam/ensure.lua deleted file mode 100644 index 3a1ad95..0000000 --- a/configs/nvim/lua/adam/ensure.lua +++ /dev/null @@ -1,25 +0,0 @@ -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) - vim.cmd [[packadd packer.nvim]] - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - -return require('packer').startup(function(use) - use 'wbthomason/packer.nvim' - -- My plugins here - -- use 'foo1/bar1.nvim' - -- use 'foo2/bar2.nvim' - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if packer_bootstrap then - require('packer').sync() - end -end) diff --git a/configs/nvim/lua/adam/init.lua b/configs/nvim/lua/adam/init.lua deleted file mode 100644 index 9034e94..0000000 --- a/configs/nvim/lua/adam/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -require('adam.set') -require('adam.remap') -require('adam.packer') diff --git a/configs/nvim/lua/adam/packer.lua b/configs/nvim/lua/adam/packer.lua deleted file mode 100644 index 0c76e20..0000000 --- a/configs/nvim/lua/adam/packer.lua +++ /dev/null @@ -1,50 +0,0 @@ --- This file can be loaded by calling `lua require('plugins')` from your init.vim - --- Only required if you have packer configured as `opt` -vim.cmd [[packadd packer.nvim]] - -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - -- Telescope - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.0', - -- or , branch = '0.1.x', - requires = { {'nvim-lua/plenary.nvim'} } - } - - use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) - use 'nvim-treesitter/playground' - - use 'theprimeagen/harpoon' - use 'mbbill/undotree' - use 'tpope/vim-fugitive' - use 'terrortylor/nvim-comment' - - -- Visual - use 'vim-airline/vim-airline' - - use { - 'VonHeikemen/lsp-zero.nvim', - requires = { - -- LSP Support - {'neovim/nvim-lspconfig'}, - {'williamboman/mason.nvim'}, - {'williamboman/mason-lspconfig.nvim'}, - - -- Autocompletion - {'hrsh7th/nvim-cmp'}, - {'hrsh7th/cmp-buffer'}, - {'hrsh7th/cmp-path'}, - {'saadparwaiz1/cmp_luasnip'}, - {'hrsh7th/cmp-nvim-lsp'}, - {'hrsh7th/cmp-nvim-lua'}, - - -- Snippets - {'L3MON4D3/LuaSnip'}, - {'rafamadriz/friendly-snippets'}, - } - } - -end) diff --git a/configs/nvim/lua/adam/remap.lua b/configs/nvim/lua/adam/remap.lua deleted file mode 100644 index 8e54091..0000000 --- a/configs/nvim/lua/adam/remap.lua +++ /dev/null @@ -1,51 +0,0 @@ --- Shortcuts -vim.keymap.set('n', 'pv', vim.cmd.Ex) -vim.keymap.set('n', 'pS', vim.cmd.PackerSync) -vim.keymap.set('n', 'm', vim.cmd.Mason) - --- Select and Drag -vim.keymap.set("v", "J", ":m '>+1gv=gv") -vim.keymap.set("v", "K", ":m '<-2gv=gv") - --- J without moving cursor -vim.keymap.set('n', 'J', 'mzJ`z') - --- Center cursor when jumping -vim.keymap.set('n', '', 'zz') -vim.keymap.set('n', '', 'zz') - --- Center cursor during search -vim.keymap.set('n', 'n', 'nzzzv') -vim.keymap.set('n', 'N', 'Nzzzv') - --- Paste without yank -vim.keymap.set('x', 'p', '\"_dP') - --- Delete without yank -vim.keymap.set('n', 'd', '\"_d') -vim.keymap.set('v', 'd', '\"_d') - --- yank to system clipboard -vim.keymap.set('n', 'y', '\"+y') -vim.keymap.set('v', 'y', '\"+y') -vim.keymap.set('n', 'Y', '\"+Y') - --- no -vim.keymap.set('n', 'Q', '') - --- Format -vim.keymap.set('n', 'f', function() - vim.lsp.buf.format() -end) - --- quickfix -vim.keymap.set('n', '', 'cnextzz') -vim.keymap.set('n', '', 'cprevzz') -vim.keymap.set('n', 'k', 'lnextzz') -vim.keymap.set('n', 'j', 'lprevzz') - --- Super substitute -vim.keymap.set('n', 's', [[:%s/\<\>//gI]]) - --- make current script executable -vim.keymap.set('n', 'x', '!chmod +x %', { silent = true }) diff --git a/configs/nvim/lua/adam/set.lua b/configs/nvim/lua/adam/set.lua deleted file mode 100644 index 36c8785..0000000 --- a/configs/nvim/lua/adam/set.lua +++ /dev/null @@ -1,27 +0,0 @@ -vim.opt.nu = true -vim.opt.relativenumber = true - -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 -vim.opt.expandtab = true - -vim.opt.smartindent = true - -vim.opt.wrap = false - -vim.opt.swapfile = false -vim.opt.backup = false -vim.opt.undodir = os.getenv('HOME') .. '/.vim/undodir' -vim.opt.undofile = true - -vim.opt.hlsearch = false -vim.opt.incsearch = true - -vim.opt.scrolloff = 8 -vim.opt.signcolumn = 'yes' -vim.opt.isfname:append('@-@') - -vim.opt.updatetime = 50 - -vim.g.mapleader = ' ' diff --git a/configs/nvim/lua/cmp-setup.lua b/configs/nvim/lua/cmp-setup.lua new file mode 100644 index 0000000..fd0c727 --- /dev/null +++ b/configs/nvim/lua/cmp-setup.lua @@ -0,0 +1,71 @@ +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +local cmp = require 'cmp' +local luasnip = require 'luasnip' +local lspkind = require('lspkind') +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + window = { + completion = { + col_offset = -3, + side_padding = 0, + }, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. (strings[1] or "") .. " " + kind.menu = " (" .. (strings[2] or "") .. ")" + + return kind + end, + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, +} + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/keymaps.lua b/configs/nvim/lua/keymaps.lua new file mode 100644 index 0000000..c6ef0c6 --- /dev/null +++ b/configs/nvim/lua/keymaps.lua @@ -0,0 +1,64 @@ +-- [[ Basic Keymaps ]] + +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) +vim.keymap.set('n', 'pv', vim.cmd.Ex) + +-- Select and Drag +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- J without moving cursor +vim.keymap.set('n', 'J', 'mzJ`z') + +-- Center cursor when jumping +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') + +-- Center cursor during search +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') + +-- Paste without yank +vim.keymap.set('x', 'p', '\"_dP') + +-- Delete without yank +vim.keymap.set({ 'n', 'v' }, 'd', '\"_d') + +-- no +vim.keymap.set('n', 'Q', '') + +-- Format +vim.keymap.set('n', 'f', function() + vim.lsp.buf.format() +end) + +-- Super substitute +vim.keymap.set('n', 's', [[:%s/\<\>//gI]]) + +-- make current script executable +vim.keymap.set('n', 'x', '!chmod +x %', { silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/kickstart/plugins/autoformat.lua b/configs/nvim/lua/kickstart/plugins/autoformat.lua new file mode 100644 index 0000000..bc56b15 --- /dev/null +++ b/configs/nvim/lua/kickstart/plugins/autoformat.lua @@ -0,0 +1,74 @@ +-- autoformat.lua +-- +-- Use your language server to automatically format your code on save. +-- Adds additional commands as well to manage the behavior + +return { + 'neovim/nvim-lspconfig', + config = function() + -- Switch for controlling whether you want autoformatting. + -- Use :KickstartFormatToggle to toggle autoformatting on or off + local format_is_enabled = true + vim.api.nvim_create_user_command('KickstartFormatToggle', function() + format_is_enabled = not format_is_enabled + print('Setting autoformatting to: ' .. tostring(format_is_enabled)) + end, {}) + + -- Create an augroup that is used for managing our formatting autocmds. + -- We need one augroup per client to make sure that multiple clients + -- can attach to the same buffer without interfering with each other. + local _augroups = {} + local get_augroup = function(client) + if not _augroups[client.id] then + local group_name = 'kickstart-lsp-format-' .. client.name + local id = vim.api.nvim_create_augroup(group_name, { clear = true }) + _augroups[client.id] = id + end + + return _augroups[client.id] + end + + -- Whenever an LSP attaches to a buffer, we will run this function. + -- + -- See `:help LspAttach` for more information about this autocmd event. + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), + -- This is where we attach the autoformatting for reasonable clients + callback = function(args) + local client_id = args.data.client_id + local client = vim.lsp.get_client_by_id(client_id) + local bufnr = args.buf + + -- Only attach to clients that support document formatting + if not client.server_capabilities.documentFormattingProvider then + return + end + + -- Tsserver usually works poorly. Sorry you work with bad languages + -- You can remove this line if you know what you're doing :) + if client.name == 'tsserver' then + return + end + + -- Create an autocmd that will run *before* we save the buffer. + -- Run the formatting command for the LSP that has just attached. + vim.api.nvim_create_autocmd('BufWritePre', { + group = get_augroup(client), + buffer = bufnr, + callback = function() + if not format_is_enabled then + return + end + + vim.lsp.buf.format { + async = false, + filter = function(c) + return c.id == client.id + end, + } + end, + }) + end, + }) + end, +} diff --git a/configs/nvim/lua/kickstart/plugins/debug.lua b/configs/nvim/lua/kickstart/plugins/debug.lua new file mode 100644 index 0000000..7fc783f --- /dev/null +++ b/configs/nvim/lua/kickstart/plugins/debug.lua @@ -0,0 +1,87 @@ +-- debug.lua +-- +-- Shows how to use the DAP plugin to debug your code. +-- +-- Primarily focused on configuring the debugger for Go, but can +-- be extended to other languages as well. That's why it's called +-- kickstart.nvim and not kitchen-sink.nvim ;) + +return { + -- NOTE: Yes, you can install new plugins here! + 'mfussenegger/nvim-dap', + -- NOTE: And you can specify dependencies as well + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/nvim-dap-ui', + + -- Installs the debug adapters for you + 'williamboman/mason.nvim', + 'jay-babu/mason-nvim-dap.nvim', + + -- Add your own debuggers here + 'leoluz/nvim-dap-go', + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_setup = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, + } + + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', 'B', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'Debug: Set Breakpoint' }) + + -- Dap UI setup + -- For more information, see |:help nvim-dap-ui| + dapui.setup { + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + } + + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) + + dap.listeners.after.event_initialized['dapui_config'] = dapui.open + dap.listeners.before.event_terminated['dapui_config'] = dapui.close + dap.listeners.before.event_exited['dapui_config'] = dapui.close + + -- Install golang specific config + require('dap-go').setup() + end, +} diff --git a/configs/nvim/lua/lazy-bootstrap.lua b/configs/nvim/lua/lazy-bootstrap.lua new file mode 100644 index 0000000..f75c630 --- /dev/null +++ b/configs/nvim/lua/lazy-bootstrap.lua @@ -0,0 +1,17 @@ +-- [[ Install `lazy.nvim` plugin manager ]] +-- https://github.com/folke/lazy.nvim +-- `:help lazy.nvim.txt` for more info +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, + } +end +vim.opt.rtp:prepend(lazypath) + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/lazy-plugins.lua b/configs/nvim/lua/lazy-plugins.lua new file mode 100644 index 0000000..4d5167c --- /dev/null +++ b/configs/nvim/lua/lazy-plugins.lua @@ -0,0 +1,200 @@ +-- [[ Configure plugins ]] +-- NOTE: Here is where you install your plugins. +-- You can configure plugins using the `config` key. +-- +-- You can also configure plugins after the setup call, +-- as they will be available in your neovim runtime. +require('lazy').setup({ + -- NOTE: First, some plugins that don't require any configuration + + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + + -- NOTE: This is where your plugins related to LSP can be installed. + -- The configuration is done below. Search for lspconfig to find it below. + { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, + }, + + { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + }, + + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map({ 'n', 'v' }, ']c', function() + if vim.wo.diff then + return ']c' + end + vim.schedule(function() + gs.next_hunk() + end) + return '' + end, { expr = true, desc = 'Jump to next hunk' }) + + map({ 'n', 'v' }, '[c', function() + if vim.wo.diff then + return '[c' + end + vim.schedule(function() + gs.prev_hunk() + end) + return '' + end, { expr = true, desc = 'Jump to previous hunk' }) + + -- Actions + -- visual mode + map('v', 'hs', function() + gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'stage git hunk' }) + map('v', 'hr', function() + gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'reset git hunk' }) + -- normal mode + map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) + map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) + map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) + map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) + map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) + map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) + map('n', 'hb', function() + gs.blame_line { full = false } + end, { desc = 'git blame line' }) + map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) + map('n', 'hD', function() + gs.diffthis '~' + end, { desc = 'git diff against last commit' }) + + -- Toggles + map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) + map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) + + -- Text object + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) + end, + }, + }, + + { + 'mbrea-c/wal-colors.nvim', + priority = 1000, + config = function() + vim.cmd.colorscheme 'mbc' + end, + dependencies = { 'onsails/lspkind.nvim' }, + }, + + { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = 'mbc', + component_separators = '|', + section_separators = '', + }, + }, + }, + + { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help ibl` + main = 'ibl', + opts = {}, + }, + + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + + -- Fuzzy Finder (files, lsp, etc) + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + }, + + { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ':TSUpdate', + }, + + require 'kickstart.plugins.autoformat', + -- require 'kickstart.plugins.debug', + -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins +}, {}) + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/lsp-setup.lua b/configs/nvim/lua/lsp-setup.lua new file mode 100644 index 0000000..2675a81 --- /dev/null +++ b/configs/nvim/lua/lsp-setup.lua @@ -0,0 +1,120 @@ +-- [[ Configure LSP ]] +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(_, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) +end + +-- document existing key chains +require('which-key').register { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, + ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, +} +-- register which-key VISUAL mode +-- required for visual hs (hunk stage) to work +require('which-key').register({ + [''] = { name = 'VISUAL ' }, + ['h'] = { 'Git [H]unk' }, +}, { mode = 'v' }) + +-- mason-lspconfig requires that these setup functions are called in this order +-- before setting up the servers. +require('mason').setup() +require('mason-lspconfig').setup() + +-- Enable the following language servers +-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. +-- +-- Add any additional override configuration in the following tables. They will be passed to +-- the `settings` field of the server config. You must look up that documentation yourself. +-- +-- If you want to override the default filetypes that your language server will attach to you can +-- define the property 'filetypes' to the map in question. +local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, +} + +-- Setup neovim lua configuration +require('neodev').setup() + +-- nvim-cmp supports additional completion capabilities, so broadcast that to servers +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +-- Ensure the servers above are installed +local mason_lspconfig = require 'mason-lspconfig' + +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} + +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + } + end, +} + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/options.lua b/configs/nvim/lua/options.lua new file mode 100644 index 0000000..1ed3d59 --- /dev/null +++ b/configs/nvim/lua/options.lua @@ -0,0 +1,49 @@ +-- [[ Setting options ]] +-- See `:help vim.o` + +-- Make line numbers default and relative +vim.o.nu = true +vim.o.rnu = true + +-- 4 space tabs +vim.o.ts = 4 +vim.o.sts = 4 +vim.o.sw = 4 +vim.o.et = true + +-- Set highlight on search +vim.o.hls = false + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.o.cb = 'unnamedplus' + +-- Enable break indent +vim.o.bri = true + +-- Save undo history +vim.o.udir = os.getenv('HOME') .. '/.vim.undodir' +vim.o.udf = true + +-- Keep cursor 8 lines from top/bottom +vim.o.so = 8 + +-- Case-insensitive searching UNLESS \C or capital in search +vim.o.ic = true +vim.o.scs = true + +-- Keep signcolumn on by default +vim.wo.scl = 'yes' + +-- Decrease update time +vim.o.ut = 250 +vim.o.tm = 300 + +-- Set completeopt to have a better completion experience +vim.o.cot = 'menuone,noselect' + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/telescope-setup.lua b/configs/nvim/lua/telescope-setup.lua new file mode 100644 index 0000000..cfb5a56 --- /dev/null +++ b/configs/nvim/lua/telescope-setup.lua @@ -0,0 +1,81 @@ +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') + +-- Telescope live_grep in git root +-- Function to find the git root directory based on the current buffer's path +local function find_git_root() + -- Use the current buffer's path as the starting point for the git search + local current_file = vim.api.nvim_buf_get_name(0) + local current_dir + local cwd = vim.fn.getcwd() + -- If the buffer is not associated with a file, return nil + if current_file == '' then + current_dir = cwd + else + -- Extract the directory from the current file's path + current_dir = vim.fn.fnamemodify(current_file, ':h') + end + + -- Find the Git root directory from the current file's path + local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] + if vim.v.shell_error ~= 0 then + print 'Not a git repository. Searching on current working directory' + return cwd + end + return git_root +end + +-- Custom live_grep function to search in git root +local function live_grep_git_root() + local git_root = find_git_root() + if git_root then + require('telescope.builtin').live_grep { + search_dirs = { git_root }, + } + end +end + +vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) + +-- See `:help telescope.builtin` +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +local function telescope_live_grep_open_files() + require('telescope.builtin').live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } +end +vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) +vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) +vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) +vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + +-- vim: ts=2 sts=2 sw=2 et diff --git a/configs/nvim/lua/treesitter-setup.lua b/configs/nvim/lua/treesitter-setup.lua new file mode 100644 index 0000000..dd0c1d1 --- /dev/null +++ b/configs/nvim/lua/treesitter-setup.lua @@ -0,0 +1,70 @@ +-- [[ Configure Treesitter ]] +-- See `:help nvim-treesitter` +-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' +vim.defer_fn(function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = true, + + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } +end, 0) + +-- vim: ts=2 sts=2 sw=2 et diff --git a/n b/n new file mode 100755 index 0000000..702c1a4 --- /dev/null +++ b/n @@ -0,0 +1,7 @@ +#!/bin/sh + +# NNN +export NNN_FIFO=/tmp/nnn.fifo # to enable plugins +export NNN_PLUG='f:preview-tui' + +nnn -P f diff --git a/scripts/install_arch b/scripts/install_arch index bd9ad09..ed13610 100755 --- a/scripts/install_arch +++ b/scripts/install_arch @@ -29,6 +29,7 @@ alacritty \ alsa-utils \ arandr \ awesome \ +bat \ beautiful-discord-git \ bluez \ btop \ @@ -37,6 +38,7 @@ caprine \ chromium \ discord \ firefox-developer-edition \ +fzf \ gimp \ lf \ light \ @@ -60,6 +62,7 @@ python-pywalfox \ pywal-discord-git \ rar \ redshift \ +ripgrep \ rsync \ sl \ spotify-launcher \