From 84a221def0114a14bfa03815ec6dad3ebaa96f4a Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Mon, 19 Dec 2022 03:01:32 +0700 Subject: [PATCH] Slowly building out nvim.lua --- .config/emacs/init.org | 6 ++ .config/nvim/init.lua | 64 ++++++---------- .config/nvim/lua/plugins.lua | 142 +++++++++++++++++++++++++++++++++++ .gitignore | 1 + 4 files changed, 171 insertions(+), 42 deletions(-) diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 309e6e8..bb0cd8f 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -1103,6 +1103,12 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i #+begin_src emacs-lisp (setq compilation-auto-jump-to-first-error t) #+end_src +** Debugging +*** DAP +#+begin_src emacs-lisp +(straight-use-package 'dap-mode) +#+end_src + ** Languages *** Rust #+begin_src emacs-lisp diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index fa5b34e..e8b3bf5 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,50 +1,30 @@ -- This file can be loaded by calling `lua require('plugins')` from your init.vim --- Only required if you have packer configured as `opt` -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 +require('plugins') +local map = vim.keymap.set -local packer_bootstrap = ensure_packer() -local packer = require('packer') +vim.o.clipboard = 'unnamedplus' +vim.o.wrap = false +vim.o.hlsearch = false +vim.wo.number = true +vim.wo.relativenumber = true +vim.o.ignorecase = true +vim.o.smartcase = true +vim.o.termguicolors = true -packer.startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - use { - 'marko-cerovac/material.nvim', - config = function() - vim.g.material_style = "palenight" - vim.cmd [[colorscheme material]] - end - } - use { 'TimUntersberger/neogit', requires = 'nvim-lua/plenary.nvim' } -end) +vim.g.mapleader = " " -if packer_bootstrap then - require('packer').sync() -end +map("n", "", vim.cmd.w) +map("n", "", vim.cmd.wq) +map("n", "vv", "^vg_", { noremap = true }) -local autocmd = vim.api.nvim_create_autocmd -local augroup = vim.api.nvim_create_augroup +local telescope = require('telescope.builtin') +map('n', 'f', telescope.find_files, {}) +map('n', 'g', telescope.live_grep, {}) +map('n', 'b', telescope.buffers, {}) +map('n', 't', telescope.help_tags, {}) -autocmd('BufWritePost', { - group = augroup('packer_user_config', { clear = true }), - pattern = "init.lua", - once = true, - callback = function() - vim.cmd('source $MYVIMRC') - packer.compile() - end -}) - -local neogit = require('neogit') - -neogit.setup {} +-- local neogit = require('neogit') +-- +-- neogit.setup {} diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index e69de29..6d31450 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,142 @@ +-- Only required if you have packer configured as `opt` +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() +local packer = require('packer') + +packer.startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + use 'nvim-lua/plenary.nvim' + use { + 'nvim-telescope/telescope-fzf-native.nvim', + run = 'make', + cond = vim.fn.executable 'make' == 1 +} + use { + 'marko-cerovac/material.nvim', + config = function() + vim.g.material_style = "palenight" + vim.cmd [[colorscheme material]] + end + } + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end + } + use { -- Additional text objects via treesitter + 'nvim-treesitter/nvim-treesitter-textobjects', + after = 'nvim-treesitter', + } + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.0', + requires = { {'nvim-lua/plenary.nvim'} } + } + use { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup() + end + } + use { + "kylechui/nvim-surround", + tag = "*", -- Use for stability; omit to use `main` branch for the latest features + config = function() + require("nvim-surround").setup({}) + end + } +-- use { 'TimUntersberger/neogit', requires = 'nvim-lua/plenary.nvim' } +end) + +if packer_bootstrap then + require('packer').sync() +end + +local autocmd = vim.api.nvim_create_autocmd +local augroup = vim.api.nvim_create_augroup + + +autocmd(('BufWritePost'), { + group = augroup('packer_user_config', { clear = true }), + pattern = "plugins.lua", + once = true, + callback = function() + vim.cmd('source ~/.config/nvim/lua/plugins.lua') + packer.compile() + end +}) + +require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'bash', 'rust', 'go', 'help', 'haskell', 'ocaml' }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false + }, + 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 = { + [')'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['('] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, +-- TODO: Fix this + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, +} diff --git a/.gitignore b/.gitignore index e1d307d..af774ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .config/emacs/* !.config/emacs/init.org +/.config/nvim/plugin/