Skip to content
Closed
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
224 changes: 167 additions & 57 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
--[[

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

TODO: fix leader key for telescope from neo-tree
What is Kickstart?

Kickstart.nvim is *not* a distribution.
Expand All @@ -28,10 +9,6 @@ What is Kickstart?
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/
Expand All @@ -45,17 +22,6 @@ 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.
Expand All @@ -70,18 +36,6 @@ Kickstart Guide:
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
Expand All @@ -91,7 +45,7 @@ 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.o`
Expand Down Expand Up @@ -152,6 +106,19 @@ vim.o.splitbelow = true
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }

vim.opt.spelllang = { 'en_us', 'de_ch' }
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'markdown', 'gitcommit', 'text', 'rst', 'tex' },
callback = function()
vim.opt_local.spell = true
end,
})

-- curl -fLo ~/.config/nvim/spell/de.utf-8.spl https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.spl
-- curl -fLo ~/.config/nvim/spell/de.utf-8.sug https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.sug
-- curl -fLo ~/.config/nvim/spell/en.utf-8.spl https://ftp.nluug.nl/pub/vim/runtime/spell/en.utf-8.spl
-- curl -fLo ~/.config/nvim/spell/en.utf-8.sug https://ftp.nluug.nl/pub/vim/runtime/spell/en.utf-8.sug

-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'

Expand All @@ -166,6 +133,22 @@ vim.o.scrolloff = 10
-- See `:help 'confirm'`
vim.o.confirm = true

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.filetype.add {
filename = { ['Taskfile'] = 'yaml' },
pattern = { ['.*/%.taskfiles/.*%.ya?ml'] = 'yaml' },
}

-- highlight ExtraWhitespace
-- TODO: does not seem to clear all whitespace (-> did not work for yaml file)
vim.api.nvim_set_hl(0, 'ExtraWhitespace', {
fg = nil,
bg = '#ff80ff', -- Hex color
})
vim.cmd [[match ExtraWhitespace /\s\+$/]]

-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`

Expand Down Expand Up @@ -205,6 +188,12 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })

-- helper to jump to diagnostic
local function diagnostic_jump(count, opts)
opts = vim.tbl_extend('force', { count = count, wrap = true, float = true }, opts or {})
vim.diagnostic.jump(opts)
end

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

Expand All @@ -219,6 +208,27 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end,
})

-- Set correct indendation for Go/templ files
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'go', 'templ' },
callback = function()
vim.bo.tabstop = 4
vim.bo.shiftwidth = 4
vim.bo.softtabstop = 4
vim.bo.expandtab = false
end,
})

vim.api.nvim_create_autocmd('FileType', {
pattern = { 'typescript', 'json', 'jsonc' },
callback = function()
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.softtabstop = 2
vim.bo.expandtab = false
end,
})

-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
Expand Down Expand Up @@ -347,6 +357,10 @@ require('lazy').setup({
{ '<leader>s', group = '[S]earch' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
{ '<leader>r', group = '[R]efactor' },
{ '<leader>sp', group = '[Sp]elling' },
{ '<leader>g', group = '[G]oto' },
{ '<leader>e', group = '[E]rror Diagnostics' },
},
},
},
Expand Down Expand Up @@ -437,6 +451,39 @@ require('lazy').setup({
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' })

local themes = require 'telescope.themes'
vim.keymap.set('n', '<leader>sps', function()
builtin.spell_suggest(themes.get_cursor())
end, { desc = '[sp]elling: [s]uggestions ' })

-- toggle spell
vim.keymap.set('n', '<leader>spt', function()
vim.wo.spell = not vim.wo.spell
vim.notify('spell: ' .. (vim.wo.spell and 'ON' or 'OFF'))
end, { desc = '[sp]elling: [t]oggle' })

vim.keymap.set('n', '<leader>spg', 'zg', { desc = '[sp]elling: mark as [g]ood', silent = true })
vim.keymap.set('n', '<leader>spw', 'zw', { desc = '[sp]elling: mark as [w]rong', silent = true })
vim.keymap.set('n', '<leader>spu', 'zug', { desc = '[sp]elling: [u]ndo last mark', silent = true })
vim.keymap.set('n', '<leader>spn', ']s', { desc = '[sp]elling: [n]ext error', silent = true })
vim.keymap.set('n', '<leader>spp', '[s', { desc = '[sp]elling: [p]rev error', silent = true })

vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, { desc = '[R]e[n]ame' })
vim.keymap.set('n', '<leader>rr', vim.lsp.buf.references, { desc = '[R]eferences' })
vim.keymap.set('n', '<leader>gd', builtin.lsp_definitions, { desc = '[G]oto [D]efinition' })
vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, { desc = '[G]oto [D]eclaration' })
vim.keymap.set('n', '<leader>gi', builtin.lsp_implementations, { desc = '[G]oto [I]mplementation' })

vim.keymap.set('n', '<leader>gb', '<C-o>', { desc = '[G]o [B]ack' })
vim.keymap.set('n', '<leader>gf', '<C-i>', { desc = '[G]o [F]orward' })

vim.keymap.set('n', '<leader>en', function()
diagnostic_jump(vim.v.count1)
end, { desc = '[E]rror [N]ext' })
vim.keymap.set('n', '<leader>ep', function()
diagnostic_jump(-vim.v.count1)
end, { desc = '[E]rror [P]revious' })

-- Slightly advanced example of overriding default behavior and theme
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
Expand Down Expand Up @@ -672,16 +719,17 @@ require('lazy').setup({
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
gopls = {},
bashls = {},
pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
ts_ls = {},
--

lua_ls = {
Expand All @@ -698,6 +746,43 @@ require('lazy').setup({
},
},
},
yamlls = {
settings = {
yaml = {
validate = true,
hover = true,
completion = true,
format = { enable = false },
kubernetes = { enable = true },
schemaStore = { enable = true },
schemas = {
['https://raw.githubusercontent.com/compose-spec/compose-spec/refs/heads/main/schema/compose-spec.json'] = {
'docker-compose*.yml',
'docker-compose*.yaml',
'compose*.yml',
'compose*.yaml',
'dc*.yml',
'dc*.yaml',
},
['https://json.schemastore.org/github-workflow.json'] = {
'.github/workflows/*.yml',
'.github/workflows/*.yaml',
},
['https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json'] = {
'cicd/**/*.yml',
'cicd/**/*.yaml',
'.gitlab-ci.yml',
'.gitlab-ci.yaml',
},
['https://taskfile.dev/schema.json'] = {
'Taskfile',
'Taskfile.yml',
'Taskfile.yaml',
},
},
},
},
},
}

-- Ensure the servers and tools above are installed
Expand Down Expand Up @@ -768,6 +853,17 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
yaml = { 'prettier' },
-- markdown = { 'prettier' },
python = { 'black' },
terraform = { 'terraform_fmt' },
tex = { 'latexindent' },
sql = { 'prettier' },
templ = { 'templ' },
javascript = { 'prettier' },
typescript = { 'prettier' },
-- sql = { 'sql_formatter' },

-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
Expand Down Expand Up @@ -876,6 +972,19 @@ require('lazy').setup({
},
},

{
'Piotr1215/presenterm.nvim',
build = false,
config = function()
require('presenterm').setup {
default_keybindings = true,
picker = {
provider = 'telescope',
},
}
end,
},

{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is.
Expand Down Expand Up @@ -954,7 +1063,7 @@ require('lazy').setup({
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true, disable = { 'ruby' } },
indent = { enable = true, disable = { 'ruby', 'yaml' } },
},
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
Expand All @@ -975,21 +1084,22 @@ require('lazy').setup({
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
require 'kickstart.plugins.lint',
require 'kickstart.plugins.autopairs',
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.
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
--
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope!
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
-- you can continue same window with `<space>sr` which resumes last telescope search
--
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
Expand Down
15 changes: 14 additions & 1 deletion lua/custom/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,17 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}
-- nvim/lua/custom/plugins/taskfile.lua
return {
'dasvh/taskfile.nvim',
lazy = false,
config = function()
require('taskfile').setup {
float = {
width = 0.6,
height = 0.5,
border = 'single',
},
}
end,
}
1 change: 1 addition & 0 deletions lua/kickstart/plugins/lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ return {
local lint = require 'lint'
lint.linters_by_ft = {
markdown = { 'markdownlint' },
python = { 'pylint' },
}

-- To allow other plugins to add linters to require('lint').linters_by_ft,
Expand Down
Loading
Loading