dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit ac2392ac47026dad15ced1ad9eb4fe4eac0b551f
parent 6790604d9e750250ea38d0a847ac9dea7e46f3da
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Fri,  7 Apr 2023 13:28:50 +0200

nvim: lots of plugins/config changes

Also switched to lazy.nvim (since even the creator of packer uses lazy).

Diffstat:
Mnvim/init.lua | 388++++---------------------------------------------------------------------------
Anvim/lazy-lock.json | 27+++++++++++++++++++++++++++
Anvim/lua/config/lsp-inlayhints.lua | 14++++++++++++++
Anvim/lua/config/mason-lspconfig.lua | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anvim/lua/config/nvim-cmp.lua | 45+++++++++++++++++++++++++++++++++++++++++++++
Anvim/lua/config/nvim-dap-ui.lua | 7+++++++
Anvim/lua/config/nvim-dap.lua | 37+++++++++++++++++++++++++++++++++++++
Anvim/lua/config/nvim-treesitter.lua | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anvim/lua/config/telescope.lua | 19+++++++++++++++++++
Anvim/lua/plugins.lua | 129+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mvim/colors/jokull.schemer | 11+++++++++++
Mvim/colors/jokull.vim | 70+++++++++++++++++++++++++++++++++++++++++++---------------------------
Mvim/spell/en.utf-8.add | 30++++++++++++++++++++++++++++++
Mvim/spell/en.utf-8.add.spl | 0
14 files changed, 528 insertions(+), 398 deletions(-)

diff --git a/nvim/init.lua b/nvim/init.lua @@ -5,114 +5,29 @@ call setenv("MYOLDVIMRC", "~/.vim/vimrc") source $MYOLDVIMRC ]]) --- Install packer -local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' -local is_bootstrap = false -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - is_bootstrap = true - vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path } - vim.cmd [[packadd packer.nvim]] +-- Install Lazy +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 -require('packer').startup(function(use) - -- Package manager - use 'wbthomason/packer.nvim' +vim.opt.rtp:prepend(lazypath) - use { -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - requires = { - -- Automatically install LSPs to stdpath for neovim - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - - -- Useful status updates for LSP - 'j-hui/fidget.nvim', - - -- Additional lua configuration, makes nvim stuff amazing - 'folke/neodev.nvim', +require('lazy').setup('plugins', { + performance = { + rtp = { + reset = false, }, - } - - use { -- Autocompletion - 'hrsh7th/nvim-cmp', - requires = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, - } - - use { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - run = function() - pcall(require('nvim-treesitter.install').update { with_sync = true }) - end, - } - - use { -- Additional text objects via treesitter - 'nvim-treesitter/nvim-treesitter-textobjects', - after = 'nvim-treesitter', - } - - -- Git related plugins - use 'lewis6991/gitsigns.nvim' - - use 'lukas-reineke/indent-blankline.nvim' -- Add indentation guides even on blank lines - use 'numToStr/Comment.nvim' -- "gc" to comment visual regions/lines - - -- Fuzzy Finder (files, lsp, etc) - use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } - - -- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available - use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable 'make' == 1 } - - -- Linting - for when LSP is not enough - use 'mfussenegger/nvim-lint' - - use { - "folke/which-key.nvim", - config = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - require("which-key").setup { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } - end - } - - -- Add custom plugins to packer from ~/.config/nvim/lua/custom/plugins.lua - local has_plugins, plugins = pcall(require, 'custom.plugins') - if has_plugins then - plugins(use) - end - - if is_bootstrap then - require('packer').sync() - end -end) - --- When we are bootstrapping a configuration, it doesn't --- make sense to execute the rest of the init.lua. --- --- You'll need to restart nvim, and then it will work. -if is_bootstrap then - print '==================================' - print ' Plugins are being installed' - print ' Wait until Packer completes,' - print ' then restart nvim' - print '==================================' - return -end - --- Automatically source and re-compile packer whenever you save this init.lua -local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true }) -vim.api.nvim_create_autocmd('BufWritePost', { - command = 'source <afile> | PackerCompile', - group = packer_group, - pattern = vim.fn.expand '$MYVIMRC', + }, }) --- [[ Setting options ]] --- See `:help vim.o` - -- Set completeopt to have a better completion experience vim.o.completeopt = 'menuone,noselect' @@ -137,126 +52,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) --- Enable Comment.nvim -require('Comment').setup() - --- Enable `lukas-reineke/indent-blankline.nvim` --- See `:help indent_blankline.txt` -require('indent_blankline').setup { - char = '┊', - show_trailing_blankline_indent = false, - filetype = {'python'}, -} - --- Gitsigns --- See `:help gitsigns.txt` -require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, -} - --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - ['<C-u>'] = false, - ['<C-d>'] = false, - }, - }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- See `:help telescope.builtin` -vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) --- vim.keymap.set('n', '<leader>/', 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]' }) - -vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', '<leader>sr', require('telescope.builtin').lsp_references, { desc = '[S]earch [R]eferences' }) - --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` -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', 'typescript', 'help', 'vim', 'bash', 'ledger', 'ruby', - 'python', 'java', 'sql'}, - - highlight = { enable = true }, - indent = { enable = true, disable = { 'python' } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '<c-space>', - node_incremental = '<c-space>', - scope_incremental = '<c-s>', - node_decremental = '<c-d>', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['<leader>a'] = '@parameter.inner', - }, - swap_previous = { - ['<leader>A'] = '@parameter.inner', - }, - }, - }, -} -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) @@ -264,155 +59,6 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist) --- LSP settings. --- 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('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('<leader>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('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('<leader>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 - --- Enable the following language servers --- Feel free to add/remove any LSPs that you want here. They will automatically be installed. --- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md --- 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. -local servers = { - ruby_ls = {}, - rust_analyzer = {}, - bashls = {}, - pyright = {}, - jdtls = {}, - jsonls = {}, - texlab = {}, - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - }, - }, -} - --- 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) - --- Setup mason so it can manage external tooling -require('mason').setup() - --- 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], - } - end, -} - --- Turn on lsp status information -require('fidget').setup() - --- nvim-cmp setup -local cmp = require 'cmp' -require("luasnip.loaders.from_snipmate").lazy_load({paths="~/.dotfiles/vim/snippets"}) -local luasnip = require 'luasnip' - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - ['<C-d>'] = cmp.mapping.scroll_docs(-4), - ['<C-f>'] = cmp.mapping.scroll_docs(4), - ['<C-Space>'] = cmp.mapping.complete(), - ['<CR>'] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - ['<Tab>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - ['<S-Tab>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, -} - --- linting -require('lint').linters_by_ft = { - sh = {'shellcheck'}, -} -vim.api.nvim_create_autocmd({ "BufWritePost" }, { - callback = function() - require("lint").try_lint() - end, -}) vim.cmd ([[ nnoremap <leader><C-e><C-u> :<c-u>exe "vsplit ~/.vim/snippets/"..&filetype..".snippets"<CR> diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json @@ -0,0 +1,26 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" }, + "LuaSnip": { "branch": "master", "commit": "bc8ec05022743d3f08bda7a76c6bb5e9a9024581" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "gitsigns.nvim": { "branch": "main", "commit": "372d5cb485f2062ac74abc5b33054abac21d8b58" }, + "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, + "lazy.nvim": { "branch": "main", "commit": "57cce98dfdb2f2dd05a0567d89811e6d0505e13b" }, + "lsp-inlayhints.nvim": { "branch": "main", "commit": "84ca3abe8aaecbb5b30ad89e4701d4a9c821b72c" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "d88d3564b2ae1d35163ccefda7184d7df104e198" }, + "mason.nvim": { "branch": "main", "commit": "b54d4e3171cc9735de915dbb97e987fb1f05dad9" }, + "neodev.nvim": { "branch": "main", "commit": "864b35006d3de24c60e44b566de8018f919b13e6" }, + "null-ls.nvim": { "branch": "main", "commit": "5855128178fa78293acdfb5b4e41ef046779240b" }, + "nvim-cmp": { "branch": "main", "commit": "777450fd0ae289463a14481673e26246b5e38bf2" }, + "nvim-dap": { "branch": "master", "commit": "1dd02e82c77d558e30ba831db4c2e7ed534e874f" }, + "nvim-dap-python": { "branch": "master", "commit": "972b8b8b65823c433ee834ed02a7f06edf590dfc" }, + "nvim-dap-ui": { "branch": "master", "commit": "56a2df0e96bfa64ebd6967e7cad877a1530633d5" }, + "nvim-lspconfig": { "branch": "master", "commit": "1ec6f5cbf6ffc44c84783d70039df5295ca22b4e" }, + "nvim-treesitter": { "branch": "master", "commit": "226c1475a46a2ef6d840af9caa0117a439465500" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "b55fe6175f0001347a433c9df358c8cbf8a4e90f" }, + "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, + "telescope.nvim": { "branch": "master", "commit": "942fe5faef47b21241e970551eba407bc10d9547" }, + "which-key.nvim": { "branch": "main", "commit": "4b73390eec680b4c061ea175eb32c0ff3412271d" } +}+ \ No newline at end of file diff --git a/nvim/lua/config/lsp-inlayhints.lua b/nvim/lua/config/lsp-inlayhints.lua @@ -0,0 +1,14 @@ +require('lsp-inlayhints').setup() +vim.api.nvim_create_augroup("LspAttach_inlayhints", {}) +vim.api.nvim_create_autocmd("LspAttach", { + group = "LspAttach_inlayhints", + callback = function(args) + if not (args.data and args.data.client_id) then + return + end + + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + require("lsp-inlayhints").on_attach(client, bufnr) + end, +}) diff --git a/nvim/lua/config/mason-lspconfig.lua b/nvim/lua/config/mason-lspconfig.lua @@ -0,0 +1,88 @@ +local mason_lspconfig = require 'mason-lspconfig' +-- Enable the following language servers +-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. +-- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md +-- 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. +local servers = { + ruby_ls = {}, + rust_analyzer = {}, + bashls = {}, + pyright = {}, + jdtls = {}, + jsonls = {}, + texlab = {}, + lua_ls = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + } + }, + }, +} + + +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} + +-- LSP settings. +-- 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('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('<leader>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('<leader>K', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('<leader>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 +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + on_attach = on_attach, + settings = servers[server_name], + } + end, +} diff --git a/nvim/lua/config/nvim-cmp.lua b/nvim/lua/config/nvim-cmp.lua @@ -0,0 +1,45 @@ +local cmp = require 'cmp' +require("luasnip.loaders.from_snipmate").lazy_load({paths="~/.dotfiles/vim/snippets"}) +local luasnip = require 'luasnip' +luasnip.setup({ + history = false +}) + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<CR>'] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + ['<Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + ['<S-Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} diff --git a/nvim/lua/config/nvim-dap-ui.lua b/nvim/lua/config/nvim-dap-ui.lua @@ -0,0 +1,7 @@ +require('dapui').setup() +vim.keymap.set({'n', 'v'}, '<localleader>dh', function() + require('dapui').eval(nil, {}) +end) +vim.keymap.set('n', '<localleader>do', function() + require('dapui').toggle() +end) diff --git a/nvim/lua/config/nvim-dap.lua b/nvim/lua/config/nvim-dap.lua @@ -0,0 +1,37 @@ +local dap = require('dap') +dap.adapters.codelldb = { + type = 'server', + port = "${port}", + executable = { + -- CHANGE THIS to your path! + command = 'codelldb', + args = {"--port", "${port}"}, + + -- On windows you may have to uncomment this: + -- detached = false, + } +} +dap.configurations.rust = { + { + name = "Launch file", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + }, +} +vim.keymap.set('n', '<localleader>dc', function() require('dap').continue() end) +vim.keymap.set('n', '<localleader>dn', function() require('dap').step_over() end) +vim.keymap.set('n', '<localleader>di', function() require('dap').step_into() end) +vim.keymap.set('n', '<localleader>df', function() require('dap').step_out() end) +vim.keymap.set('n', '<localleader>db', function() require('dap').toggle_breakpoint() end) +vim.keymap.set('n', '<localleader>dB', function() require('dap').set_breakpoint() end) +vim.keymap.set('n', '<localleader>dm', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) +vim.keymap.set('n', '<localleader>dr', function() require('dap').repl.open() end) +vim.keymap.set('n', '<localleader>dC', function() require('dap').run_last() end) +vim.keymap.set('n', '<localleader>dj', function() require('dap').focus_frame() end) +vim.keymap.set('n', '<localleader>dH', function() require('dap').goto_(nil) end) +vim.keymap.set('n', '<localleader>dS', function() require('dap').close() end) diff --git a/nvim/lua/config/nvim-treesitter.lua b/nvim/lua/config/nvim-treesitter.lua @@ -0,0 +1,61 @@ +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', 'typescript', 'vim', 'bash', 'ledger', 'ruby', + 'python', 'java', 'sql'}, + + highlight = { enable = true }, + indent = { enable = true, disable = { 'python' } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '<c-space>', + node_incremental = '<c-space>', + scope_incremental = '<c-s>', + node_decremental = '<c-d>', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['<leader>a'] = '@parameter.inner', + }, + swap_previous = { + ['<leader>A'] = '@parameter.inner', + }, + }, + }, +} diff --git a/nvim/lua/config/telescope.lua b/nvim/lua/config/telescope.lua @@ -0,0 +1,19 @@ +pcall(require('telescope').load_extension, 'fzf') +require('telescope').setup { + defaults = { + mappings = { + i = { + ['<C-u>'] = false, + ['<C-d>'] = false, + }, + }, + }, +} +vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', '<leader>sr', require('telescope.builtin').lsp_references, { desc = '[S]earch [R]eferences' }) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua @@ -0,0 +1,129 @@ +return { + { + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + {'williamboman/mason.nvim', + opts = {}, + }, + { 'williamboman/mason-lspconfig.nvim', + config = function() + require 'config.mason-lspconfig' + end, + }, + + -- Useful status updates for LSP + {'j-hui/fidget.nvim', + opts = {}, + }, + + -- Additional lua configuration, makes nvim stuff amazing + { + 'folke/neodev.nvim', + opts = { + library = { plugins = { "nvim-dap-ui" }, types = true }, + }, + } + }, + }, + + { + 'jose-elias-alvarez/null-ls.nvim', + config = function() + local null_ls = require('null-ls') + null_ls.setup { sources = { null_ls.builtins.code_actions.shellcheck } } + end, + }, + + { -- Autocompletion + 'hrsh7th/nvim-cmp', + config = function() + require 'config.nvim-cmp' + end, + dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, + }, + + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = function() + pcall(require('nvim-treesitter.install').update { with_sync = true }) + end, + config = function() + require 'config.nvim-treesitter' + end, + }, + + -- Additional text objects via treesitter + 'nvim-treesitter/nvim-treesitter-textobjects', + + { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + } + }, + + + { -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + opts = { + char = '┊', + show_trailing_blankline_indent = false, + filetype = {'python'}, + } + }, + + { + 'numToStr/Comment.nvim', -- "gc" to comment visual regions/lines + opts = {} + }, + + -- Fuzzy Finder (files, lsp, etc) + { 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require 'config.telescope' + end, + }, + + -- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available + { 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = vim.fn.executable 'make' == 1 + }, + + { + "folke/which-key.nvim", + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + require("which-key").setup() + end + }, + + -- DAP: debugging + { 'mfussenegger/nvim-dap', config = function() + require 'config.nvim-dap' + end + }, + {'mfussenegger/nvim-dap-python', + config = function() + require('dap-python').setup(vim.fn.stdpath("data") .. "/mason/packages/debugpy/venv/bin/python") + end + }, + { "rcarriga/nvim-dap-ui", dependencies = {"mfussenegger/nvim-dap"}, config = function() + require 'config.nvim-dap-ui' + end + }, + + { 'lvimuser/lsp-inlayhints.nvim', config = function() + require 'config.lsp-inlayhints' + end} + +} diff --git a/vim/colors/jokull.schemer b/vim/colors/jokull.schemer @@ -97,6 +97,14 @@ GitGutterChange gold, bg GitGutterDelete darkred, bg GitGutterChangeDelete offlightred, bg NormalFloat NONE, lightgrey +DapUIDecoration offairblue, NONE +DapUIScope ddarkblue, NONE +DapUIStoppedThread ddarkblue, NONE +DapUIBreakpointsPath ddarkblue, NONE +DapUIBreakpointsCurrentLine darkgreen, NONE +DapUIWatchesEmpty darkred, NONE +DapUIModifiedValue offlightred, NONE + " link group1,group2,... target group link structure type @@ -122,3 +130,6 @@ link ALEWarning diff link ALEWarningLine difftext link gitcommitSummary include link gitcommitOverflow errormsg +link DapUIStepOver,DapUIStepInto,DapUIStepBack,DapUIStepOut DapUIScope +link DapUIPlayPause,DapUIRestart,DapUIWatchesValue darkgreen +link DapUIWatchesError,DapUIStop DapUIWatchesEmpty diff --git a/vim/colors/jokull.vim b/vim/colors/jokull.vim @@ -53,51 +53,67 @@ hi GitGutterChange guifg=#8e830e guibg=#e4e4e4 ctermfg=100 ctermbg=254 cterm=NON hi GitGutterDelete guifg=#6e032e guibg=#e4e4e4 ctermfg=52 ctermbg=254 cterm=NONE gui=NONE hi GitGutterChangeDelete guifg=#80537e guibg=#e4e4e4 ctermfg=96 ctermbg=254 cterm=NONE gui=NONE hi NormalFloat guifg=NONE guibg=#d0d0d0 ctermfg=NONE ctermbg=252 cterm=NONE gui=NONE +hi DapUIDecoration guifg=#a8caff guibg=NONE ctermfg=153 ctermbg=NONE cterm=NONE gui=NONE +hi DapUIScope guifg=#005f87 guibg=NONE ctermfg=24 ctermbg=NONE cterm=NONE gui=NONE +hi DapUIStoppedThread guifg=#005f87 guibg=NONE ctermfg=24 ctermbg=NONE cterm=NONE gui=NONE +hi DapUIBreakpointsPath guifg=#005f87 guibg=NONE ctermfg=24 ctermbg=NONE cterm=NONE gui=NONE +hi DapUIBreakpointsCurrentLine guifg=#009051 guibg=NONE ctermfg=29 ctermbg=NONE cterm=NONE gui=NONE +hi DapUIWatchesEmpty guifg=#6e032e guibg=NONE ctermfg=52 ctermbg=NONE cterm=NONE gui=NONE +hi DapUIModifiedValue guifg=#80537e guibg=NONE ctermfg=96 ctermbg=NONE cterm=NONE gui=NONE " Link definitions -hi! link precondit include hi! link tag delimiter -hi! link spellbad todo -hi! link spelllocal string hi! link gh_files_dir function hi! link conditional statement -hi! link markdowncode type -hi! link netrwdir function -hi! link gitcommitSummary include hi! link netrwexe title -hi! link tabline tablinefill hi! link ALEWarningLine difftext -hi! link mkdlink type hi! link signcolumn linenr -hi! link spellcap string -hi! link spellrare string hi! link netrwMarkFile incsearch -hi! link markdownUrl string -hi! link error errormsg -hi! link preproc include +hi! link pmenusel statusline +hi! link DapUIWatchesValue darkgreen hi! link ALEError errormsg +hi! link specialcomment delimiter +hi! link DapUIStepOut DapUIScope +hi! link precondit include +hi! link markdowncode type +hi! link DapUIWatchesError DapUIWatchesEmpty +hi! link tabline tablinefill +hi! link DapUIStepBack DapUIScope +hi! link mkdlink type +hi! link netrwdir function +hi! link DapUIStepInto DapUIScope +hi! link DapUIRestart darkgreen hi! link number delimiter -hi! link define include hi! link typedef structure -hi! link repeat statement -hi! link specialcomment delimiter -hi! link pmenu statuslinenc -hi! link storageclass structure hi! link ALEWarning diffchange -hi! link gitcommitOverflow errormsg hi! link macro include -hi! link pmenusel statusline hi! link modemsg string -hi! link ALEErrorLine diffdelete -hi! link character constant -hi! link structure type -hi! link debug delimiter +hi! link repeat statement hi! link special delimiter -hi! link label structure hi! link operator statement -hi! link vimwikilink type hi! link specialchar delimiter +hi! link label structure +hi! link ALEErrorLine diffdelete +hi! link DapUIStop DapUIWatchesEmpty +hi! link spellrare string +hi! link define include +hi! link gitcommitOverflow errormsg +hi! link DapUIPlayPause darkgreen +hi! link debug delimiter +hi! link structure type +hi! link pmenu statuslinenc +hi! link vimwikilink type +hi! link gitcommitSummary include +hi! link spelllocal string +hi! link spellcap string +hi! link markdownUrl string +hi! link error errormsg +hi! link preproc include +hi! link storageclass structure +hi! link DapUIStepOver DapUIScope +hi! link spellbad todo +hi! link character constant " Code to clear any groups that are not defined -let s:DefinedColors=['precondit', 'tag', 'spellbad', 'spelllocal', 'gh_files_dir', 'conditional', 'markdowncode', 'netrwdir', 'gitcommitsummary', 'netrwexe', 'tabline', 'alewarningline', 'mkdlink', 'signcolumn', 'spellcap', 'spellrare', 'netrwmarkfile', 'markdownurl', 'error', 'preproc', 'aleerror', 'number', 'define', 'typedef', 'repeat', 'specialcomment', 'pmenu', 'storageclass', 'alewarning', 'gitcommitoverflow', 'macro', 'pmenusel', 'modemsg', 'aleerrorline', 'character', 'structure', 'debug', 'special', 'label', 'operator', 'vimwikilink', 'specialchar', 'normal', 'keyword', 'cursorline', 'string', 'identifier', 'function', 'statement', 'include', 'type', 'search', 'incsearch', 'folded', 'tablinefill', 'tablinesel', 'wildmenu', 'linenr', 'vertsplit', 'todo', 'nontext', 'statusline', 'statuslinenc', 'statuslinetermnc', 'statuslineterm', 'statuslinefile', 'statuslinenormmode', 'visual', 'title', 'matchparen', 'qffilename', 'delimiter', 'comment', 'errormsg', 'cursorlinenr', 'specialkey', 'constant', 'diffadd', 'diffdelete', 'diffchange', 'difftext', 'gitgutteradd', 'gitgutterchange', 'gitgutterdelete', 'gitgutterchangedelete', 'normalfloat'] +let s:DefinedColors=['tag', 'gh_files_dir', 'conditional', 'netrwexe', 'alewarningline', 'signcolumn', 'netrwmarkfile', 'pmenusel', 'dapuiwatchesvalue', 'aleerror', 'specialcomment', 'dapuistepout', 'precondit', 'markdowncode', 'dapuiwatcheserror', 'tabline', 'dapuistepback', 'mkdlink', 'netrwdir', 'dapuistepinto', 'dapuirestart', 'number', 'typedef', 'alewarning', 'macro', 'modemsg', 'repeat', 'special', 'operator', 'specialchar', 'label', 'aleerrorline', 'dapuistop', 'spellrare', 'define', 'gitcommitoverflow', 'dapuiplaypause', 'debug', 'structure', 'pmenu', 'vimwikilink', 'gitcommitsummary', 'spelllocal', 'spellcap', 'markdownurl', 'error', 'preproc', 'storageclass', 'dapuistepover', 'spellbad', 'character', 'normal', 'keyword', 'cursorline', 'string', 'identifier', 'function', 'statement', 'include', 'type', 'search', 'incsearch', 'folded', 'tablinefill', 'tablinesel', 'wildmenu', 'linenr', 'vertsplit', 'todo', 'nontext', 'statusline', 'statuslinenc', 'statuslinetermnc', 'statuslineterm', 'statuslinefile', 'statuslinenormmode', 'visual', 'title', 'matchparen', 'qffilename', 'delimiter', 'comment', 'errormsg', 'cursorlinenr', 'specialkey', 'constant', 'diffadd', 'diffdelete', 'diffchange', 'difftext', 'gitgutteradd', 'gitgutterchange', 'gitgutterdelete', 'gitgutterchangedelete', 'normalfloat', 'dapuidecoration', 'dapuiscope', 'dapuistoppedthread', 'dapuibreakpointspath', 'dapuibreakpointscurrentline', 'dapuiwatchesempty', 'dapuimodifiedvalue'] function! s:ClearUndefinedColors(colors) let undefined_groups = filter(a:colors->keys()->map('tolower(v:val)'), 'index(s:DefinedColors, tolower(v:val)) < 0') call map(undefined_groups, "execute('highlight' . ' ' . v:val . ' ' . 'NONE')") diff --git a/vim/spell/en.utf-8.add b/vim/spell/en.utf-8.add @@ -655,3 +655,33 @@ ADR CDMI Tadiphone Roccat +unobfuscated +GitLab's +Radare2 +LTS +EPYC +rebasing +SDKs +32-bit +Aarch64 +64-bit +pseudocode +decompile +Aligator +S6500 +Infinix +usr +SHA +disassembler +rebase +SuperVisor +checksum +outliers +Pico +r2Pipe +endian +ABI +superset +ARM64 +SQLite +Fitbit diff --git a/vim/spell/en.utf-8.add.spl b/vim/spell/en.utf-8.add.spl Binary files differ.