Skip to content
Closed

dfg #1989

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- # kickstart.nvim / M64 personalized -->
# kickstart.nvim
My neovim config, based on kickstart.

## Introduction

Expand All @@ -11,6 +13,47 @@ A starting point for Neovim that is:
**NOT** a Neovim distribution, but instead a starting point for your configuration.

## Installation
TL;DR

I have added toggleterm, neo-tree, vim-fugitive, notify, scrollview, telescope-env and C/C++ incl. DAP support mainly, as well as little tweaks and shortcuts to make autocomplete more natural (ie. let autocomplete accept with enter)
You get a full C/C++ IDE config incl DAP debugging support working out of the box, clangd based: lsp, linter, formatter, dap config and what kickstart.nvim normally does (see below). You should build gdb from source to have DAP support.

```
- If you have an existing setup, I recommend a full clean:
- back it up
- rm -rf ~/.local/share/nvim
- rm -rf ~/.config/nvim
- I strongly recommend to pull latest neovim sources and build current neovim from source
- I strongly recommend to pull and compile gdb so you have version 14.1 with DAP support
- clone this repo into ~/.config and rename it to nvim
- start neovim, wait a bit and enjoy!

Some of the shortcuts (my <leader> is comma)
- ; : : (thx renerocksai for this idea!)
- ,, : fuzzy select / open file
- ,v : open a new vsplit
- ,mm : make (in persistent terminal)
- ,mc : make clean (in persistent terminal)
- <Ctrl-t> : toggle persistent terminal
- <Ctrl-G> : toggle neo-tree
- <Ctrl-P> : keyword fuzzy search
```
You can search for M64 in init.lua to find my changes.

To get the full blown C/C++ IDE experience:

When you have first started nvim after these steps, it autoinstalls almost all packages, and configures neovim. To get the full blown C/C++ IDE experience: have a look at `Mason`! (I do not want to interfere with its's installation mechanisms -> you need to manually follow this steps, to complete setup)

In nvim start Mason by entering `:Mason`, select and install the following packages:

```
◍ clangd
◍ cpplint
◍ cpptools
◍ markdownlint
```
to do so - hover over the corresponding package name from the list, and press `i` to install it. That's it!


### Install Neovim

Expand Down
148 changes: 46 additions & 102 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,97 +1,11 @@
--[[

=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
======== .-----. ========
======== .----------------------. | === | ========
======== |.-""""""""""""""""""-.| |-----| ========
======== || || | === | ========
======== || KICKSTART.NVIM || |-----| ========
======== || || | === | ========
======== || || |-----| ========
======== ||:Tutor || |:::::| ========
======== |'-..................-'| |____o| ========
======== `"")----------------(""` ___________ ========
======== /::::::::::| |::::::::::\ \ no mouse \ ========
======== /:::========| |==hjkl==:::\ \ required \ ========
======== '""""""""""""' '""""""""""""' '""""""""""' ========
======== ========
=====================================================================
=====================================================================

What is Kickstart?

Kickstart.nvim is *not* a distribution.

Kickstart.nvim is a starting point for your own configuration.
The goal is that you can read every line of code, top-to-bottom, understand
what your configuration is doing, and modify it to suit your needs.

Once you've done that, you can start exploring, configuring and tinkering to
make Neovim your own! That might mean leaving Kickstart just the way it is for a while
or immediately breaking it into modular pieces. It's up to you!

If you don't know anything about Lua, I recommend taking some time to read through
a guide. One possible example which will only take 10-15 minutes:
- https://learnxinyminutes.com/docs/lua/

After understanding a bit more about Lua, you can use `:help lua-guide` as a
reference for how Neovim integrates Lua.
- :help lua-guide
- (or HTML version): https://neovim.io/doc/user/lua-guide.html

Kickstart Guide:

TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.

If you don't know what this means, type the following:
- <escape key>
- :
- Tutor
- <enter key>

(If you already know the Neovim basics, you can skip this step.)

Once you've completed that, you can continue working through **AND READING** the rest
of the kickstart init.lua.

Next, run AND READ `:help`.
This will open up a help window with some basic information
about reading, navigating and searching the builtin help documentation.

This should be the first place you go to look when you're stuck or confused
with something. It's one of my favorite Neovim features.

MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation,
which is very useful when you're not exactly sure of what you're looking for.

I have left several `:help X` comments throughout the init.lua
These are hints about where to find more information about the relevant settings,
plugins or Neovim features used in Kickstart.

NOTE: Look for lines like this

Throughout the file. These are for you, the reader, to help you understand what is happening.
Feel free to delete them once you know what you're doing, but they should serve as a guide
for when you are first encountering a few different constructs in your Neovim config.

If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.

I hope you enjoy your Neovim journey,
- TJ

P.S. You can delete this when you're done too. It's your config now! :)
--]]

-- Set <space> as the leader key
-- Set <comma> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.g.mapleader = ','
vim.g.maplocalleader = ','

-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true

-- [[ Setting options ]]
-- See `:help vim.opt`
Expand Down Expand Up @@ -161,6 +75,9 @@ vim.opt.scrolloff = 10
vim.opt.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')

-- M64 additional settings
vim.opt.colorcolumn = '80'

-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
Expand All @@ -176,10 +93,10 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })

-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')

-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
Expand All @@ -190,6 +107,18 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })

-- M64 additional keymaps
vim.keymap.set('n', '<leader>v', '<cmd>vnew<CR>', { desc = 'New vertical spit' })
-- vim.keymap.set('n', '<leader>mm', '<cmd>vsplit | terminal make<CR>', { desc = 'make' })
vim.keymap.set('n', '<leader>mm', '<cmd>TermExec cmd=make direction=vertical<CR>', { desc = 'make' })
-- vim.keymap.set('n', '<leader>mc', '<cmd>vsplit | terminal make<CR>', { desc = 'make clean' })
vim.keymap.set('n', '<leader>mc', '<cmd>TermExec cmd="make clean" direction=vertical<CR>', { desc = 'make' })
-- vim.keymap.set('n', '<leader>tt', '<cmd>vnew | terminal<CR>', { desc = 'New vertical spit with a terminal' })
vim.keymap.set('n', '<leader>tt', '<cmd>ToggleTerm direction=vertical size=80<CR>', { desc = 'New vertical spit with a terminal' })
vim.keymap.set('n', '<C-t>', '<cmd>ToggleTerm direction=vertical size=80<CR>', { desc = 'New vertical spit with a terminal' })
vim.keymap.set('n', '<c-g>', '<cmd>Neotree toggle position=right<CR>', { desc = 'Toggle Neotree' })
vim.keymap.set('n', ';', ':', { desc = 'For my lazy fingers ;)' })

-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`

Expand Down Expand Up @@ -239,7 +168,6 @@ require('lazy').setup({

-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },

-- Here is a more advanced example where we pass configuration
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
-- require('gitsigns').setup({ ... })
Expand Down Expand Up @@ -323,6 +251,7 @@ require('lazy').setup({
end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
{ 'LinArcX/telescope-env.nvim' },

-- Useful for getting pretty icons, but requires a Nerd Font.
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
Expand Down Expand Up @@ -369,6 +298,8 @@ require('lazy').setup({
-- Enable Telescope extensions if they are installed
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
pcall(require('telescope').load_extension, 'env')
pcall(require('telescope').load_extension, 'notify')

-- See `:help telescope.builtin`
local builtin = require 'telescope.builtin'
Expand All @@ -381,7 +312,10 @@ require('lazy').setup({
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })

-- M64
vim.keymap.set('n', '<C-p>', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader><leader>', builtin.find_files, { desc = '[S]earch [F]iles' })

-- Slightly advanced example of overriding default behavior and theme
vim.keymap.set('n', '<leader>/', function()
Expand Down Expand Up @@ -733,7 +667,7 @@ require('lazy').setup({

-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),

Expand Down Expand Up @@ -784,7 +718,7 @@ require('lazy').setup({
-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night'
vim.cmd.colorscheme 'tokyonight-moon'

-- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none'
Expand Down Expand Up @@ -873,19 +807,26 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
-- M64
require 'kickstart.plugins.neo-tree',
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' },

-- M64 additional plugins
'tpope/vim-fugitive',
'rcarriga/nvim-notify',
'dstein64/nvim-scrollview',
{ 'akinsho/toggleterm.nvim', version = '*', config = true },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
Expand All @@ -908,5 +849,8 @@ require('lazy').setup({
},
})

-- M64
vim.notify = require 'notify'

-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
Loading