diff --git a/README.md b/README.md index 586fdeb..5d396c2 100644 --- a/README.md +++ b/README.md @@ -1 +1,291 @@ -Haelnorr's NeoVim config +# Haelnorr's NeoVim config + +This is a list of all the plugins I use and what they do, along with some +documentation on keybinds and other usage. + +## Contents + + - [Plugins](#plugins) + - [Language server](#language-server) + - [Keymappings](#keymappings) + +## Plugins + +Plugins are managed using [lazy.nvim](https://github.com/folke/lazy.nvim) + - [Aerial](#aerial) + - [Comment](#comment) + - [Conform](#conform) + - [Feline](#feline) + - [Fugitive](#fugitive) + - [Gitsigns](#gitsigns) + - [Harpoon](#harpoon) + - [Markdown Preview](#markdown-preview) + - [NVIM Web Devicons](#nvim-web-devicons) + - [SUDA](#suda) + - [Surround](#surround) + - [Telescope](#telescope) + - [TMUXNav](#tmuxnav) + - [TODO Comments](#todo-comments) + - [Treesitter](#treesitter) + - [Trouble](#trouble) + - [Undotree](#undotree) + - [Vim be good](#vim-be-good) + - [Windows](#windows) + +--- +#### [Aerial](https://github.com/stevearc/aerial.nvim) +A code outline window for skimming and quick navigation +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `pa` | Toggle Aerial outline for current window | Normal | +| `{` | Cycle previous item | Inside Aerial | +| `}` | Cycle next item | Inside Aerial | + +--- +#### [Comment](https://github.com/numToStr/Comment.nvim) +Smart and powerful commenting plugin for NeoVim +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `gcc` | Toggles comment on current line using linewise comment | Normal | +| `gbc` | Toggles comment on current line using blockwise comment | Normal | +| `[count]gcc` | Toggles the number of line given as a prefix-count using linewise | Normal | +| `[count]gbc` | Toggles the number of line given as a prefix-count using blockwise | Normal | +| `gc[count]{motion}` | (Op-pending) Toggles the region using linewise comment | Normal | +| `gb[count]{motion}` | (Op-pending) Toggles the region using blockwise comment | Normal | +| `gc` | Toggles region using linewise comment | Visual | +| `gb` | Toggles region using blockwise comment | Visual | +| `gco` | Insert comment to next line and enter insert mode | Normal | +| `gcO` | Insert comment to previous line and enter insert mode | Normal | +| `gcA` | Insert comment to end of the current line and enter insert mode | Normal | + +--- +#### [Conform](https://github.com/stevearc/conform.nvim) +Lightweight yet powerful formatter plugin +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `f` | Formats entire file | Normal | +| `f` | Formats selection | Visual + Select | + +--- +#### [Feline](https://github.com/freddiehaddad/feline.nvim) +Customizable status line + +--- +#### [Fugitive](https://github.com/tpope/vim-fugitive) +Git integration +| Keybind | Functionality | Mode | +|---------|---------------|------| +|`gs` | Opens fugitive window | Normal | +| `gu` | `diffget //2` | Normal | +| `gh` | `diffget //3` | Normal | +| `s` | `:Git add -A` | (inside fugitive) | +| `c` | `:Git commit` | (inside fugitive) | +| `p` | `:Git push` | (inside fugitive) | +| `P` | `:Git pull --rebase` | (inside fugitive) | +| `t` | `:Git push -u origin ` | (inside fugitive) | + +--- +#### [Gitsigns](https://github.com/lewis6991/gitsigns.nvim) +Customizable git diff decorators + +--- +#### [Harpoon](https://github.com/ThePrimeagen/harpoon/tree/harpoon2) +Quick swap between files +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `a` | Add current file | Normal | +| `Alt + e` | Toggle quick menu | Normal | +| `Alt + h` | Swap to file 1 | Normal | +| `Alt + j` | Swap to file 2 | Normal | +| `Alt + k` | Swap to file 3 | Normal | +| `Alt + l` | Swap to file 4 | Normal | +| ` Alt + h` | Replace file 1 with current file | Normal | +| ` Alt + j` | Replace file 2 with current file | Normal | +| ` Alt + k` | Replace file 3 with current file | Normal | +| ` Alt + l` | Replace file 4 with current file | Normal | + +--- +#### [Markdown Preview](https://github.com/iamcco/markdown-preview.nvim) +Live preview of markdown files in browser, with synced scrolling + +**Usage:** +`:MarkdownPreview` - Opens preview window in new tab of browser + +--- +#### [NVIM Web Devicons](https://github.com/nvim-tree/nvim-web-devicons) +Provides Nerd font icons for other plugins to use + +--- +#### [SUDA](https://github.com/lambdalisue/vim-suda) +Write files using sudo inside NeoVim + +**Usage:** +`:SudaRead` - Reread current file using sudo +`:SudaWrite` - Write current file using sudo + +--- +#### [Surround](https://github.com/kylechui/nvim-surround) +Add delete or remove surrounding pairs with Vim shortcuts + +**Usage:** +The three "core" operations of add/delete/change can be done with the keymaps +ys{motion}{char}, ds{char}, and cs{target}{replacement}, respectively. +For the following examples, * will denote the cursor position: +```help + Old text Command New text +-------------------------------------------------------------------------------- + surr*ound_words ysiw) (surround_words) + *make strings ys$" "make strings" + [delete ar*ound me!] ds] delete around me! + remove HTML t*ags dst remove HTML tags + 'change quot*es' cs'" "change quotes" + or tag* types csth1

or tag types

+ delete(functi*on calls) dsf function calls +``` +--- +#### [Telescope](https://github.com/nvim-telescope/telescope.nvim) +Extensible fuzzy finder for NeoVim +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `pf` | Find files | Normal | +| `Ctrl + p` | Find git files | Normal | +| `pws` | Search files for `` (word the cursor is on) | Normal | +| `pWs` | Search files for `` (WORD the cursor is on) | Normal | +| `ps` | Search files with grep | Normal | +| `vh` | Search builtin documentation | Normal | + +--- +#### [TMUXNav](https://github.com/christoomey/vim-tmux-navigator) +Integrated commands for navigating between tmux panes +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `Ctrl + h` | Navigate left | Normal | +| `Ctrl + j` | Navigate down | Normal | +| `Ctrl + k` | Navigate up | Normal | +| `Ctrl + l` | Navigate right | Normal | +| `Ctrl + \` | Navigate previous | Normal | + +--- +#### [TODO Comments](https://github.com/folke/todo-comments.nvim) +Decorate code with comment highlighting + +**Usage:** +`KEYWORD: comment` +e.g. in Python: +(**NOTE:** the highlighting wont appear in the code snippet below) +```python +## List of available keywords +# TODO: this needs implementing +# HACK: hmmm, this looks a bit funky +# WARN: probably want to fix this soon +# PERF: perfectly optimised +# NOTE: this is a clever use of an example :) +# TEST: just making sure +``` + +`:TodoTelescope` - search project todos with Telescope + +--- +#### [Treesitter](https://github.com/nvim-treesitter/nvim-treesitter) +Syntax highlighting, the best way + +--- +#### [Trouble](https://github.com/folke/trouble.nvim) +Error diagnostics + +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `tt` | Toggle diagnostics tab | Normal | +| `tq` | Toggle quickfix list | Normal | + +--- +#### [Undotree](https://github.com/mbbill/undotree) +Undotree for NeoVim + +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `u` | Open undotree | Normal | + +--- +#### [Vim be good](https://github.com/ThePrimeagen/vim-be-good) +Games for praciticing Vim motions + +**Usage:** +`:VimBeGood` + +--- +#### [Windows](https://github.com/anuvyklack/windows.nvim) +Automatically minimise and maximise windows when focused + +--- +## Language Server + +#### [NVIM-LSPConfig](https://github.com/neovim/nvim-lspconfig) + +LSP has been setup with the following dependencies: + - williamboman/mason.nvim + - williamboman/mason-lspconfig.nvim + - hrsh7th/cmp-nvim-lsp + - hrsh7th/cmp-buffer + - hrsh7th/cmp-path + - hrsh7th/cmp-cmdline + - hrsh7th/nvim-cmp + - L3MON4D3/LuaSnip + - saadparwaiz1/cmp_luasnip + - j-hui/fidget.nvim + + Language servers configured in `ensure_installed`: + - lua_ls + - bashls + - css_variables + - cssls + - cssmodules_ls + - docker_compose_language_service + - dockerls + - html + - jsonls + - pyright + +| Keybind | Functionality | Mode | +|---------|---------------|------| +| `Ctrl + p` | auto-complete select prev item | Normal | +| `Ctrl + n` | auto-complete select next item | Normal | +| `Ctrl + y` | auto-complete confirm selected item | Normal | +| `Ctrl + space` | invoke auto-complete | Normal | +| `gd` | jumps to the definition of the symbol under the cursor | Normal | +| `K` | displays hover information about the symbol under the cursor | Normal | +| `vws` | lists all symbols in the current workspace matching {query} | Normal | +| `vd` | show diagnostics in a floating window | Normal | +| `vca` | selects a code action available at the current cursor (?) | Normal | +| `vrr` | lists all references to the symbol under the cursor | Normal | +| `vrn` | rename all references to the symbol under the cursor | Normal | +| `Ctrl + h` | displays signature information about the symbol under the cursor | Insert | +| `[d` | next diagnostic | Normal | +| `]d` | prev diagnostic | Normal | + +## Keymappings +#### Leader key: `` + +| Keybind | Behaviour | Normal | Visual | Select | +|---------|-----------|--------|--------|--------| +| `pv` | View directory of current file | ✓ | ✗ | ✗ | +| `J` | Move selection down and autoindent | ✗ | ✓ | ✓ | +| `K` | Move selection up and autoindent | ✗ | ✓ | ✓ | +| `J` | Moves line below current line into sameline | ✓ | ✗ | ✗ | +| `Ctrl + d` | Jump down page, keeping cursor centered (zz) | ✓ | ✗ | ✗ | +| `Ctrl + u` | Jump up page, keeping cursor centered (zz) | ✓ | ✗ | ✗ | +| `n` | (in search) Next item, keeping cursor centered | ✓ | ✗ | ✗ | +| `N` | (in search) Prev item, keeping cursor centered | ✓ | ✗ | ✗ | +| `p` | Replaces selection with buffer without overriding buffer | ✗ | ✓ | ✗ | +| `y` | Yanks selection to system clipboard | ✓ | ✓ | ✓ | +| `Y` | Yanks line to system clipboard | ✓ | ✗ | ✗ | +| `d` | Deletes without replacing buffer, can be used with dd to delete line | ✓ | ✓ | ✓ | +| `Ctrl + k` | Quickfix next | ✓ | ✗ | ✗ | +| `Ctrl + j` | Quickfix prev | ✓ | ✗ | ✗ | +| `k` | QF Location next | ✓ | ✗ | ✗ | +| `j` | QF Location prev | ✓ | ✗ | ✗ | +| `s` | search in file for symbol under cursor, and refactor | ✓ | ✗ | ✗ | +| `x` | make file executable | ✓ | ✗ | ✗ | +| `o` | Add new line below current line | ✓ | ✗ | ✗ | +| `Ctrl + Q` | Toggle page right divider (colorcolumn) | ✓ | ✗ | ✗ | + diff --git a/lazy-lock.json b/lazy-lock.json index 5979936..75fa306 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,35 +1,40 @@ { - "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, + "aerial.nvim": { "branch": "master", "commit": "4c959cf65c5420d54b24b61a77b681dcfca0bc57" }, + "animation.nvim": { "branch": "main", "commit": "fb77091ab72ec9971aee0562e7081182527aaa6a" }, "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "feline.nvim": { "branch": "master", "commit": "3587f57480b88e8009df7b36dc84e9c7ff8f2c49" }, + "conform.nvim": { "branch": "master", "commit": "6dc21d4ce050c2e592d9635b7983d67baf216e3d" }, + "feline.nvim": { "branch": "main", "commit": "9f1313f61a75ec5ebe805fedd46bdc130c420963" }, "fidget.nvim": { "branch": "main", "commit": "a0abbf18084b77d28bc70e24752e4f4fd54aea17" }, - "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "abcd00a7d5bc1a9470cb21b023c575acade3e4db" }, + "gitsigns.nvim": { "branch": "main", "commit": "f9170c3b74d94525201e5a40543d8924a2a883a7" }, "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, "hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" }, "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "middleclass": { "branch": "master", "commit": "9fab4d5bca67262614960960ca35c4740eb2be2c" }, "nvim": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" }, "nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" }, - "nvim-lspconfig": { "branch": "master", "commit": "0913481440219390969ab56a3c33089679365ef7" }, - "nvim-surround": { "branch": "main", "commit": "9f0cb495f25bff32c936062d85046fbda0c43517" }, - "nvim-treesitter": { "branch": "master", "commit": "c7dc251cddf2cdef1fa279fa797799728a5bfd78" }, + "nvim-lspconfig": { "branch": "master", "commit": "3d4180a5ef085b9da249919cce01c62b53c07d6a" }, + "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, + "nvim-treesitter": { "branch": "master", "commit": "07bd1b53bf465e42d53253b48b7437892d6c45e8" }, "nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" }, "plenary": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, - "trouble.nvim": { "branch": "main", "commit": "4d36b8979287f5facc03fd6d955ace67db667e1d" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "trouble.nvim": { "branch": "main", "commit": "50481f414bd3c1a40122c1d759d7e424d5fafe84" }, "undotree": { "branch": "master", "commit": "2556c6800b210b2096b55b66e74b4cc1d9ebbe4f" }, "vim-be-good": { "branch": "master", "commit": "0ae3de14eb8efc6effe7704b5e46495e91931cc5" }, - "vim-fugitive": { "branch": "master", "commit": "174230d6a7f2df94705a7ffd8d5413e27ec10a80" }, + "vim-fugitive": { "branch": "master", "commit": "d74a7cff4cfcf84f83cc7eccfa365488f3bbabc2" }, "vim-suda": { "branch": "master", "commit": "9adda7d195222d4e2854efb2a88005a120296c47" }, "vim-tmux-navigator": { "branch": "master", "commit": "d847ea942a5bb4d4fab6efebc9f30d787fd96e65" }, - "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } + "windows.nvim": { "branch": "main", "commit": "c7492552b23d0ab30325e90b56066ec51242adc8" } } diff --git a/lua/haelnorr/init.lua b/lua/haelnorr/init.lua index 4373b16..5ac51c9 100644 --- a/lua/haelnorr/init.lua +++ b/lua/haelnorr/init.lua @@ -8,7 +8,7 @@ local HaelnorrGroup = augroup('Haelnorr', {}) local autocmd = vim.api.nvim_create_autocmd function R(name) - require("plenary.reload").reload_module(name) + require("plenary.reload").reload_module(name) end autocmd('LspAttach', { diff --git a/lua/haelnorr/lazy/aerial.lua b/lua/haelnorr/lazy/aerial.lua new file mode 100644 index 0000000..aa73a43 --- /dev/null +++ b/lua/haelnorr/lazy/aerial.lua @@ -0,0 +1,21 @@ +return { + "stevearc/aerial.nvim", + opts = {}, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons" + }, + config = function() + require("aerial").setup({ + on_attach = function(bufnr) + vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) + vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) + end, + layout = { + default_direction = "prefer_left", + min_width = 10 + } + }) + vim.keymap.set("n", "pa", "AerialToggle!") + end +} diff --git a/lua/haelnorr/lazy/comment.lua b/lua/haelnorr/lazy/comment.lua new file mode 100644 index 0000000..1a92d26 --- /dev/null +++ b/lua/haelnorr/lazy/comment.lua @@ -0,0 +1,3 @@ +return { + "numToStr/Comment.nvim", +} diff --git a/lua/haelnorr/lazy/conform.lua b/lua/haelnorr/lazy/conform.lua new file mode 100644 index 0000000..558a594 --- /dev/null +++ b/lua/haelnorr/lazy/conform.lua @@ -0,0 +1,48 @@ +return { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + cmd = { "ConformInfo" }, + keys = { + { + -- Customize or remove this keymap to your liking + "f", + function() + require("conform").format({ async = true }) + end, + mode = "", + desc = "Format buffer", + }, + }, + -- This will provide type hinting with LuaLS + ---@module "conform" + ---@type conform.setupOpts + opts = { + -- Define your formatters + formatters_by_ft = { + lua = { "stylua" }, + python = { "isort", "black" }, + javascript = { "prettierd", "prettier", stop_after_first = true }, + typescript = { "prettierd", "prettier", stop_after_first = true }, + typescriptreact = { "prettierd", "prettier", stop_after_first = true }, + json = { "prettierd", "prettier", stop_after_first = true }, + html = { "prettierd", "prettier", stop_after_first = true }, + css = { "prettierd", "prettier", stop_after_first = true }, + }, + -- Set default options + default_format_opts = { + lsp_format = "fallback", + }, + -- Set up format-on-save + format_on_save = { timeout_ms = 500 }, + -- Customize formatters + formatters = { + shfmt = { + prepend_args = { "-i", "2" }, + }, + }, + }, + init = function() + -- If you want the formatexpr, here is the place to set it + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" + end, +} diff --git a/lua/haelnorr/lazy/feline.lua b/lua/haelnorr/lazy/feline.lua index 4c23de6..fb5d6ee 100644 --- a/lua/haelnorr/lazy/feline.lua +++ b/lua/haelnorr/lazy/feline.lua @@ -1,5 +1,5 @@ return { - 'feline-nvim/feline.nvim', + 'freddiehaddad/feline.nvim', config = function () local ctp_feline = require('catppuccin.groups.integrations.feline') diff --git a/lua/haelnorr/lazy/lsp.lua b/lua/haelnorr/lazy/lsp.lua index 4c24e6f..4b546ea 100644 --- a/lua/haelnorr/lazy/lsp.lua +++ b/lua/haelnorr/lazy/lsp.lua @@ -27,8 +27,6 @@ return { require("mason-lspconfig").setup({ ensure_installed = { "lua_ls", - "ansiblels", - "astro", "bashls", "css_variables", "cssls", @@ -38,7 +36,6 @@ return { "html", "jsonls", "pyright", - "tailwindcss", }, handlers = { function(server_name) -- default handler (optional) diff --git a/lua/haelnorr/lazy/markdown-preview.lua b/lua/haelnorr/lazy/markdown-preview.lua new file mode 100644 index 0000000..bb96fbc --- /dev/null +++ b/lua/haelnorr/lazy/markdown-preview.lua @@ -0,0 +1,9 @@ +return { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, +} diff --git a/lua/haelnorr/lazy/snippets.lua b/lua/haelnorr/lazy/snippets.lua deleted file mode 100644 index ffa5add..0000000 --- a/lua/haelnorr/lazy/snippets.lua +++ /dev/null @@ -1,29 +0,0 @@ -return { - { - "L3MON4D3/LuaSnip", - -- follow latest release. - version = "v2.*", -- Replace by the latest released major (first number of latest release) - -- install jsregexp (optional!). - build = "make install_jsregexp", - - dependencies = { "rafamadriz/friendly-snippets" }, - - config = function() - local ls = require("luasnip") - ls.filetype_extend("javascript", { "jsdoc" }) - - --- TODO: What is expand? - vim.keymap.set({"i"}, "e", function() ls.expand() end, {silent = true}) - - vim.keymap.set({"i", "s"}, ";", function() ls.jump(1) end, {silent = true}) - vim.keymap.set({"i", "s"}, ",", function() ls.jump(-1) end, {silent = true}) - - vim.keymap.set({"i", "s"}, "", function() - if ls.choice_active() then - ls.change_choice(1) - end - end, {silent = true}) - end, - } -} - diff --git a/lua/haelnorr/lazy/windows.lua b/lua/haelnorr/lazy/windows.lua new file mode 100644 index 0000000..5e5e501 --- /dev/null +++ b/lua/haelnorr/lazy/windows.lua @@ -0,0 +1,13 @@ +return { + "anuvyklack/windows.nvim", + dependencies = { + "anuvyklack/middleclass", + "anuvyklack/animation.nvim" + }, + config = function() + vim.o.winwidth = 10 + vim.o.winminwidth = 10 + vim.o.equalalways = false + require('windows').setup() + end +} diff --git a/lua/haelnorr/lazy/zenmode.lua b/lua/haelnorr/lazy/zenmode.lua deleted file mode 100644 index 03915b7..0000000 --- a/lua/haelnorr/lazy/zenmode.lua +++ /dev/null @@ -1,19 +0,0 @@ - -return { - "folke/zen-mode.nvim", - config = function() - vim.keymap.set("n", "zz", function() - require("zen-mode").setup { - window = { - width = 90, - options = { } - }, - } - require("zen-mode").toggle() - vim.wo.wrap = false - vim.wo.number = true - vim.wo.rnu = true - end) - end -} - diff --git a/lua/haelnorr/remap.lua b/lua/haelnorr/remap.lua index 6ca7e20..d7adfe9 100644 --- a/lua/haelnorr/remap.lua +++ b/lua/haelnorr/remap.lua @@ -16,15 +16,24 @@ vim.keymap.set("n", "N", "Nzzzv") vim.keymap.set("x", "p", [["_dP]]) -- yanks to system clipboard -vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set({ "n", "v" }, "y", [["+y]]) vim.keymap.set("n", "Y", [["+Y]]) --- pretty sure this deletes without replacing buffer but idk -vim.keymap.set({"n", "v"}, "d", [["_d]]) +-- deletes without replacing buffer +vim.keymap.set({ "n", "v" }, "d", [["_d]]) --- idk something with tmux, ill come back to this -vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer") -vim.keymap.set("n", "f", vim.lsp.buf.format) +-- formats file using LSP +-- vim.keymap.set("n", "f", vim.lsp.buf.format) +vim.keymap.set("", "f", function() + require("conform").format({ async = true }, function(err) + if not err then + local mode = vim.api.nvim_get_mode().mode + if vim.startswith(string.lower(mode), "v") then + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + end + end + end) +end, { desc = "Format code" }) vim.keymap.set("n", "", "cnextzz") vim.keymap.set("n", "", "cprevzz") @@ -43,4 +52,3 @@ vim.keymap.set("n", "", function() vim.opt.colorcolumn = "" end end) -