diff --git a/init.lua b/init.lua index b98ffc6198a..ebdd492ab93 100644 --- a/init.lua +++ b/init.lua @@ -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. @@ -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/ @@ -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: - - - - : - - Tutor - - - - (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. @@ -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 as the leader key @@ -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` @@ -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' @@ -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()` @@ -205,6 +188,12 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "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` @@ -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' @@ -347,6 +357,10 @@ require('lazy').setup({ { 's', group = '[S]earch' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'r', group = '[R]efactor' }, + { 'sp', group = '[Sp]elling' }, + { 'g', group = '[G]oto' }, + { 'e', group = '[E]rror Diagnostics' }, }, }, }, @@ -437,6 +451,39 @@ require('lazy').setup({ vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + local themes = require 'telescope.themes' + vim.keymap.set('n', 'sps', function() + builtin.spell_suggest(themes.get_cursor()) + end, { desc = '[sp]elling: [s]uggestions ' }) + + -- toggle spell + vim.keymap.set('n', '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', 'spg', 'zg', { desc = '[sp]elling: mark as [g]ood', silent = true }) + vim.keymap.set('n', 'spw', 'zw', { desc = '[sp]elling: mark as [w]rong', silent = true }) + vim.keymap.set('n', 'spu', 'zug', { desc = '[sp]elling: [u]ndo last mark', silent = true }) + vim.keymap.set('n', 'spn', ']s', { desc = '[sp]elling: [n]ext error', silent = true }) + vim.keymap.set('n', 'spp', '[s', { desc = '[sp]elling: [p]rev error', silent = true }) + + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { desc = '[R]e[n]ame' }) + vim.keymap.set('n', 'rr', vim.lsp.buf.references, { desc = '[R]eferences' }) + vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = '[G]oto [D]efinition' }) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = '[G]oto [D]eclaration' }) + vim.keymap.set('n', 'gi', builtin.lsp_implementations, { desc = '[G]oto [I]mplementation' }) + + vim.keymap.set('n', 'gb', '', { desc = '[G]o [B]ack' }) + vim.keymap.set('n', 'gf', '', { desc = '[G]o [F]orward' }) + + vim.keymap.set('n', 'en', function() + diagnostic_jump(vim.v.count1) + end, { desc = '[E]rror [N]ext' }) + vim.keymap.set('n', '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', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. @@ -672,8 +719,9 @@ 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 -- @@ -681,7 +729,7 @@ require('lazy').setup({ -- 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 = { @@ -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 @@ -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" }, -- @@ -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. @@ -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: @@ -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 `sh` then write `lazy.nvim-plugin` -- you can continue same window with `sr` which resumes last telescope search + -- }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..c037450c47b 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -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, +} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index dec42f097c6..8d95bd5fd54 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -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, diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index c7067891df0..a1d5b791f3f 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -3,6 +3,7 @@ return { 'nvim-neo-tree/neo-tree.nvim', + lazy = false, version = '*', dependencies = { 'nvim-lua/plenary.nvim', @@ -14,12 +15,16 @@ return { { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { + close_if_last_window = true, filesystem = { window = { mappings = { ['\\'] = 'close_window', }, }, + filtered_items = { + hide_dotfiles = false, + }, }, }, }