From 0cbe61a255d285b45762bf4518c84913c5cab6ee Mon Sep 17 00:00:00 2001 From: tiyn Date: Wed, 4 Oct 2023 19:12:59 +0200 Subject: [PATCH] nvim: added conform.nvim and updated plugins --- .config/nvim/lazy-lock.json | 47 ++++++++++++++-------------- .config/nvim/lua/keymap.lua | 12 ++++--- .config/nvim/lua/plugins/conform.lua | 11 +++++++ .config/nvim/lua/plugins/mason.lua | 5 ++- 4 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 .config/nvim/lua/plugins/conform.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index f916404..e84c450 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -5,53 +5,54 @@ "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "diffview.nvim": { "branch": "main", "commit": "7e5a85c186027cab1e825d018f07c350177077fc" }, + "conform.nvim": { "branch": "master", "commit": "7ad988c2509ff1869c26ecdabebadc7943e78f6f" }, + "diffview.nvim": { "branch": "main", "commit": "a111d19ccceac6530448d329c63f998f77b5626e" }, "fterm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" }, "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, - "git-blame.nvim": { "branch": "master", "commit": "41e22dc843c6821a410db57be0b7025154f9d8ec" }, - "gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" }, - "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, + "git-blame.nvim": { "branch": "master", "commit": "39df33dad2cbf4eb9d17264bcda0c12e670ef1c2" }, + "gitsigns.nvim": { "branch": "main", "commit": "7f6f1565ac0d9f4e26d87135c6cbe0b9fdcf70b3" }, + "indent-blankline.nvim": { "branch": "master", "commit": "da789082a43e2bb8930c7be0e265ce37768394d8" }, "knap": { "branch": "main", "commit": "503010f541696e99ed5c62f658620e546cebf8b0" }, - "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, - "lsp_signature.nvim": { "branch": "master", "commit": "58d4e810801da74c29313da86075d6aea537501f" }, + "lazy.nvim": { "branch": "main", "commit": "82da5a004867be2cc96c345430d9381f991cf2e6" }, + "lsp_signature.nvim": { "branch": "master", "commit": "bdf3dc7bb03edd25c2173e0e31c2fb122052ed23" }, "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, - "luasnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, + "luasnip": { "branch": "master", "commit": "882a7eb128632ecafe6971f8f7e4870bc0bff3f1" }, "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "e2705063f395b44f676cd26596a11007a2cbd3bd" }, "mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" }, - "mason.nvim": { "branch": "main", "commit": "a51c2d063c5377ee9e58c5f9cda7c7436787be72" }, - "nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" }, + "mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" }, + "nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" }, "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, - "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, - "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, + "nvim-autopairs": { "branch": "master", "commit": "de4f7138a68d5d5063170f2182fd27faf06b0b54" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, "nvim-hlslens": { "branch": "main", "commit": "f0281591a59e95400babf61a96e59ba20e5c9533" }, - "nvim-lspconfig": { "branch": "master", "commit": "f7922e59aeb9bc3e31a660ea4e7405ffa3fc2c3a" }, - "nvim-navbuddy": { "branch": "master", "commit": "b31887435ab7df0f8d646e61c854b61c125596ad" }, - "nvim-navic": { "branch": "master", "commit": "9c89730da6a05acfeb6a197e212dfadf5aa60ca0" }, + "nvim-lspconfig": { "branch": "master", "commit": "71b39616b14c152da34fcc787fa27f09bf280e72" }, + "nvim-navbuddy": { "branch": "master", "commit": "f137a3466a6cd1965cdcc5398daff54e66eebbe5" }, + "nvim-navic": { "branch": "master", "commit": "0ffa7ffe6588f3417e680439872f5049e38a24db" }, "nvim-scrollbar": { "branch": "main", "commit": "35f99d559041c7c0eff3a41f9093581ceea534e8" }, "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" }, - "nvim-tree.lua": { "branch": "master", "commit": "920868dba13466586897a8f40220eca6b2caac41" }, - "nvim-treesitter": { "branch": "master", "commit": "33958915fe03d5f1c37b80cd29fea1a269f563b8" }, + "nvim-tree.lua": { "branch": "master", "commit": "7dcda5d3b6d2fce7b7baa471b7ad6525383e27bb" }, + "nvim-treesitter": { "branch": "master", "commit": "f51d56c261990581289916322005e83446cf49ad" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, - "nvim-ufo": { "branch": "main", "commit": "0c0e1e0af68a608b15d18125be92953c553a5f27" }, - "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, + "nvim-ufo": { "branch": "main", "commit": "6f2ccdf2da390d62f8f9e15fc5ddbcbd312e1e66" }, + "nvim-web-devicons": { "branch": "master", "commit": "45d0237c427baba8cd05e0ab26d30e2ee58c2c82" }, "nvim-yarp": { "branch": "master", "commit": "bb5f5e038bfe119d3b777845a76b0b919b35ebc8" }, - "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, + "plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" }, "popup-menu.nvim": { "branch": "master", "commit": "b618bd0c824a20417d845fa0022327228e6988a2" }, "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, "renamer.nvim": { "branch": "develop", "commit": "1614d466df53899f11dd5395eaac3c09a275c384" }, "spelunker.vim": { "branch": "master", "commit": "a0bc530f62798bbe053905555a4aa9ed713485eb" }, "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, - "tccs.nvim": { "branch": "master", "commit": "e634ee7d46612c6fe514ba0a7114b62e8f8347a6" }, + "tccs.nvim": { "branch": "master", "commit": "7664ee3fff0a1fdd92ce8f424bd68cbf5fba5f1d" }, "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "tidy.nvim": { "branch": "main", "commit": "86eab24e807ed2957d26ca43b2b76b92d0fbf8f4" }, "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, - "trouble.nvim": { "branch": "main", "commit": "40aad004f53ae1d1ba91bcc5c29d59f07c5f01d3" }, + "trouble.nvim": { "branch": "main", "commit": "3f85d8ed30e97ceeddbbcf80224245d347053711" }, "vim-hug-neovim-rpc": { "branch": "master", "commit": "93ae38792bc197c3bdffa2716ae493c67a5e7957" }, - "vim-markdown": { "branch": "master", "commit": "cc82d88e2a791f54d2b6e2b26e41f743351ac947" }, + "vim-markdown": { "branch": "master", "commit": "4e9b4deda11d05a157ab34e97f76089669b5b7af" }, "vim-renamer": { "branch": "master", "commit": "9c6346eb4556cf2d8ca55de6969247ab14fe2383" }, "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" } } \ No newline at end of file diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index 4c2c14b..3ed0f29 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -61,16 +61,16 @@ vim.keymap.set('n', '', ':NvimTreeToggle toggle', {}) -- numtostr/fterm.nvim vim.keymap.set({ 'n', 't' }, 't', require("FTerm").toggle, { noremap = true }) local lazygit = require("FTerm"):new({ - cmd = 'lazygit', + cmd = 'lazygit', }) vim.keymap.set({ 'n', 't' }, 'gt', function() lazygit:toggle() end) -- sindrets/diffview.nvim -vim.keymap.set( 'n', 'gdo', ":DiffviewOpen") -vim.keymap.set( 'n', 'gdc', ":DiffviewClose") +vim.keymap.set('n', 'gdo', ":DiffviewOpen") +vim.keymap.set('n', 'gdc', ":DiffviewClose") -- folke/trouble.nvim -vim.keymap.set( 'n', 'x', ":TroubleToggle") +vim.keymap.set('n', 'x', ":TroubleToggle") -- hrsh7th/nvim-cmp vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { noremap = true }) @@ -79,7 +79,9 @@ vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, { noremap = true }) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { noremap = true }) vim.keymap.set('n', 'gr', vim.lsp.buf.references, { noremap = true }) vim.keymap.set('n', 'K', vim.lsp.buf.hover, { noremap = true }) -vim.keymap.set('n', '', vim.lsp.buf.format, { noremap = true }) +vim.keymap.set('n', '', function() + require("conform").format({ async = true, lsp_fallback = true }) +end, { noremap = true }) -- filipdutescu/renamer.nvim vim.keymap.set('n', '', require("renamer").rename, { noremap = true }) diff --git a/.config/nvim/lua/plugins/conform.lua b/.config/nvim/lua/plugins/conform.lua new file mode 100644 index 0000000..df306f7 --- /dev/null +++ b/.config/nvim/lua/plugins/conform.lua @@ -0,0 +1,11 @@ +return { + { + 'stevearc/conform.nvim', + opts = { + formatters_by_ft = { + python = { "isort", "black" }, + markdown = { "mdformat" }, + }, + } + } +} diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua index 3f93ea6..47a3ca4 100644 --- a/.config/nvim/lua/plugins/mason.lua +++ b/.config/nvim/lua/plugins/mason.lua @@ -8,7 +8,10 @@ return { config = function() require("null-ls").setup({ sources = { + -- python + require("null-ls").builtins.formatting.isort, require("null-ls").builtins.formatting.black, + -- markdown require("null-ls").builtins.formatting.mdformat } }) @@ -18,7 +21,7 @@ return { 'jay-babu/mason-null-ls.nvim', opts = { automatic_installation = true, - ensure_installed = { "black", "mdformat" } + ensure_installed = { "isort", "black", "mdformat" } } },