From 91cbdd4eaa0f2f1c2b4721b755a86bf2de50aace Mon Sep 17 00:00:00 2001 From: Dustin Swan Date: Mon, 7 Nov 2022 10:51:03 -0500 Subject: [PATCH] custom neovim --- home-cli.nix | 2 +- init.lua | 177 +++++++++++++++++++-------------------------------- 2 files changed, 65 insertions(+), 114 deletions(-) diff --git a/home-cli.nix b/home-cli.nix index 8397077..6420b2a 100644 --- a/home-cli.nix +++ b/home-cli.nix @@ -7,7 +7,7 @@ in home.stateVersion = "18.09"; home.packages = with pkgs; [ # magic-wormhole - ripgrep fd mosh w3m nnn hexyl wget httpie timg sox du-dust duplicati bitwarden-cli gnupg gpg-tui rage sd libqalculate glow spotify-tui spotifyd amfora duf pandoc pastel jq jo fx jc miller visidata sc-im cacert weechat ddgr + ripgrep fd mosh w3m nnn hexyl wget httpie timg sox du-dust restic bitwarden-cli gnupg gpg-tui rage sd libqalculate glow spotify-tui spotifyd amfora duf pandoc pastel jq jo fx jc miller sc-im cacert weechat ddgr # visidata nixfmt shellcheck vale tectonic zathura # lilypond-with-fonts nodejs deno yarn nodePackages.typescript-language-server nodePackages.stylelint nodePackages.js-beautify nodePackages.expo-cli ocaml dune_2 ocamlPackages.utop ocamlPackages.ocp-indent ocamlPackages.merlin diff --git a/init.lua b/init.lua index c4891f3..34d6fe6 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,9 @@ vim.g.mapleader = ' ' -vim.g.maplocalleader = '\\' +vim.g.maplocalleader = ',' vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 +vim.opt.timeoutlen = 100 vim.opt.number = true vim.opt.mouse = 'a' vim.opt.ignorecase = true @@ -12,6 +13,9 @@ vim.opt.tabstop = 2 vim.opt.shiftwidth = 2 vim.opt.termguicolors = true vim.opt.completeopt = "menu,menuone,noselect" +vim.opt.cursorline = true + +vim.api.nvim_create_autocmd("FileType", { pattern = { "org" }, command = "setlocal nowrap" }) require('packer').startup(function(use) use 'wbthomason/packer.nvim' @@ -25,6 +29,7 @@ require('packer').startup(function(use) use 'mfussenegger/nvim-dap' use 'lukas-reineke/indent-blankline.nvim' use 'LnL7/vim-nix' + use 'AndrewRadev/splitjoin.vim' use { 'nvim-telescope/telescope.nvim', @@ -82,7 +87,13 @@ require('packer').startup(function(use) use { "folke/which-key.nvim", config = function() - require("which-key").setup() + require("which-key").setup({ + plugins = { + spelling = { + enabled = true + } + } + }) end } @@ -111,7 +122,7 @@ require('packer').startup(function(use) config = function() require("noice").setup() require("notify").setup({ - background_colour = "#000000" -- #1a1b26", + background_colour = "#000000" }) end, requires = { @@ -119,98 +130,30 @@ require('packer').startup(function(use) "rcarriga/nvim-notify", } }) - - use "rafamadriz/friendly-snippets" - - use({ - "L3MON4D3/LuaSnip", - tag = "v.*", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end - }) - - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/cmp-buffer' - use 'hrsh7th/cmp-path' - use 'hrsh7th/cmp-cmdline' - use 'saadparwaiz1/cmp_luasnip' - use 'dmitmel/cmp-digraphs' - use 'uga-rosa/cmp-dictionary' - use 'kdheepak/cmp-latex-symbols' - - use { - 'hrsh7th/nvim-cmp', - config = function () - 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 - - local luasnip = require("luasnip") - local cmp = require("cmp") - - cmp.setup({ - snippet = { - expand = function(args) - require'luasnip'.lsp_expand(args.body) - end - }, - - sources = { - { name = 'luasnip' }, - { name = 'buffer' }, - { name = 'path' }, - { name = 'nvim_lsp' }, - -- { name = 'digraphs' }, - { name = "latex_symbols" }, - { name = 'dictionary', keyword_length = 2 }, - }, - - mapping = { - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - - [""] = 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" }), - } - }) - end - } - use { - 'neovim/nvim-lspconfig', - config = function() - -- require'lspconfig'.eslint.setup{} - require'lspconfig'.tsserver.setup{} - end - } - - use { - "williamboman/mason.nvim", + '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'}, + }, config = function() - require("mason").setup() + local lsp = require('lsp-zero') + lsp.preset('recommended') + lsp.setup() end } @@ -218,10 +161,14 @@ require('packer').startup(function(use) 'numToStr/Comment.nvim', config = function() require('Comment').setup({ - -- toggler = { - -- line = 'cc', - -- block = 'cb', - -- } + toggler = { + line = 'cc', + block = 'cb', + }, + opleader = { + line = 'cc', + block = 'cb', + } }) end } @@ -283,13 +230,7 @@ require('packer').startup(function(use) use { "akinsho/toggleterm.nvim", tag = '*', config = function() - require("toggleterm").setup({ - open_mapping = [[]], - direction = 'float', - float_opts = { - border = "curved" - } - }) + require("toggleterm").setup({ direction = 'float' }) end } @@ -313,6 +254,13 @@ local wk = require("which-key") wk.register({ [""] = { + a = { ":Alpha", "Alpha" }, + b = { + name = "Buffer", + d = { ":bdelete!", "Delete" }, + }, + c = "Comment", + e = { ":NvimTreeToggle", "File Tree" }, f = { name = "Find", f = { "Telescope find_files", "Files" }, @@ -320,20 +268,23 @@ wk.register({ r = { "Telescope oldfiles", "Recent Files" }, b = { "Telescope buffers", "Buffers" }, }, - b = { - name = "buffer", - d = { ":bdelete!", "Delete" }, - }, - e = { ":NvimTreeToggle", "File Tree" }, + J = { ":SplitjoinJoin", "Join" }, t = { name = "Table", - t = { ":TableModeRealign", "Realign" }, + m = "Toggle Table Mode", + t = "Tableize", + r = { ":TableModeRealign", "Realign" }, + e = { ":TableEvalFormulaLine", "Evaluate" }, + }, + o = "Org", + p = { + name = "Packer", + s = { ":PackerSync", "Sync" }, }, - S = { ":source %", "Source current file" }, + S = { ":SplitjoinSplit", "Split" }, T = { ":TroubleToggle", "Trouble" }, - ps = { ":PackerSync", "Packer Sync" }, - [";"] = { ":Alpha", "Alpha" }, }, [""] = { ":BufferLineCycleNext", "Next Tab" }, [""] = { ":BufferLineCyclePrev", "Previous Tab" }, + [""] = { ":ToggleTerm", "Terminal" }, })