From 4108bc6c73ed6ac54123fe3d6b0bb98ca1338fa2 Mon Sep 17 00:00:00 2001 From: luba Date: Mon, 15 Apr 2024 07:47:47 -0300 Subject: [PATCH] updates --- init.lua | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 496f45b8..de6e07e8 100644 --- a/init.lua +++ b/init.lua @@ -100,6 +100,8 @@ vim.g.have_nerd_font = false -- Make line numbers default vim.opt.number = true +vim.opt.relativenumber = true + -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! -- vim.opt.relativenumber = true @@ -162,10 +164,15 @@ vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps +vim.keymap.set('i', '', '') 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' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which @@ -204,6 +211,14 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +vim.cmd [[ +augroup pencil + autocmd! + autocmd FileType markdown,mkd call pencil#init() + autocmd FileType text call pencil#init() +augroup 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' @@ -442,6 +457,7 @@ require('lazy').setup({ -- Neovim. This is where `mason` and related plugins come into play. -- -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- vim.opt.relativenumber = true -- and elegantly composed help section, `:help lsp-vs-treesitter` -- This function gets run when an LSP attaches to a particular buffer. @@ -540,7 +556,7 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -626,15 +642,52 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'isort', 'black' }, -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. - -- javascript = { { "prettierd", "prettier" } }, + json = { 'prettier' }, }, }, }, + { + 'mfussenegger/nvim-lint', + event = { + 'BufReadPre', + 'BufNewFile', + }, + config = function() + local lint = require 'lint' + + lint.linters_by_ft = { + -- python = { 'mypy' }, + -- typescript = { 'eslint_d' }, + -- javascriptreact = { 'eslint_d' }, + -- typescriptreact = { 'eslint_d' }, + -- svelte = { 'eslint_d' }, + -- kotlin = { 'ktlint' }, + -- terraform = { 'tflint' }, + -- ruby = { 'standardrb' }, + dockerfile = { 'hadolint' }, + json = { 'jsonlint' }, + } + + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) + + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set('n', 'll', function() + lint.try_lint() + end, { desc = 'Trigger linting for current file' }) + end, + }, + { -- Autocompletion 'hrsh7th/nvim-cmp', event = 'InsertEnter', @@ -745,13 +798,13 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + 'rebelot/kanagawa.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() -- 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 'kanagawa-dragon' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' @@ -802,7 +855,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -828,6 +881,27 @@ require('lazy').setup({ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects end, }, + { + 'preservim/vim-markdown', + dependencies = { + 'godlygeek/tabular', + }, + config = function() + vim.g.vim_markdown_folding_disabled = 1 + vim.g.vim_markdown_toc_autofit = 1 + vim.g.vim_markdown_borderless_table = 1 + end, + }, + { 'junegunn/goyo.vim' }, + { + 'preservim/vim-pencil', + opt = false, + config = function() + vim.g.tex_conceal = '' + vim.g['pencil#conceallevel'] = 1 + vim.g['pencil#wrapModeDefault'] = 'soft' + end, + }, -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and