From 430a2879e96dcb601765aa80a0ea1d6976188236 Mon Sep 17 00:00:00 2001 From: Nigel Date: Tue, 28 May 2024 21:11:34 +0200 Subject: [PATCH] FEAT: conform and oil added Changes - Removed hardtime ( messages were too annoying) - Cleaned up key mappings file - Disabled Lazy loading - Added Oil and conform --- lazy-lock.json | 49 +++--- lua/barink/init.lua | 28 ++-- lua/barink/keys.lua | 76 +++++---- lua/barink/plugins/conform.lua | 18 +++ lua/barink/plugins/hardtime.lua | 9 -- lua/barink/plugins/lsp.lua | 266 ++++++++++++++++---------------- lua/barink/plugins/oil.lua | 14 ++ 7 files changed, 255 insertions(+), 205 deletions(-) create mode 100644 lua/barink/plugins/conform.lua delete mode 100644 lua/barink/plugins/hardtime.lua create mode 100644 lua/barink/plugins/oil.lua diff --git a/lazy-lock.json b/lazy-lock.json index b28e403..a6e529d 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,35 +3,36 @@ "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "fidget.nvim": { "branch": "main", "commit": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5" }, - "gen.nvim": { "branch": "main", "commit": "87fbe811155b90eea58622614809705b966009ad" }, + "conform.nvim": { "branch": "master", "commit": "f3b930db4964d60e255c8f9e37b7f2218dfc08cb" }, + "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, + "gen.nvim": { "branch": "main", "commit": "bd19cf584b5b82123de977b44105e855e61e5f39" }, "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, - "hardtime.nvim": { "branch": "main", "commit": "eaf4bc31b86419c26ad7b3a142dd36ca545ca2e4" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, - "lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" }, + "lazy.nvim": { "branch": "main", "commit": "24fa2a97085ca8a7220b5b078916f81e316036fd" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, - "mason-lspconfig": { "branch": "main", "commit": "273fdde8ac5e51f3a223ba70980e52bbc09d9f6f" }, - "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, - "nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" }, - "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, - "nvim-dap": { "branch": "master", "commit": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb" }, - "nvim-dap-ui": { "branch": "master", "commit": "edfa93f60b189e5952c016eee262d0685d838450" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "3e8e207513e6ef520894950acd76b79902714103" }, + "mason-lspconfig": { "branch": "main", "commit": "a4caa0d083aab56f6cd5acf2d42331b74614a585" }, + "mason.nvim": { "branch": "main", "commit": "49ff59aded1047a773670651cfa40e76e63c6377" }, + "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, + "nvim-dap": { "branch": "master", "commit": "abb238f631609ea4be496ba7946f4f3aaec86c6a" }, + "nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" }, "nvim-emmet": { "branch": "main", "commit": "928cfb74ed436d6d326ccab2061cf3592de1bf55" }, - "nvim-highlight-colors": { "branch": "main", "commit": "432dc7a817a4973041f02b418169667c491f60fd" }, - "nvim-jdtls": { "branch": "master", "commit": "8eb5f0dbe6e126b392ddcaf45893358619893e45" }, - "nvim-lspconfig": { "branch": "master", "commit": "7133e85c3df14a387da8942c094c7edddcdef309" }, - "nvim-nio": { "branch": "master", "commit": "5800f585def265d52f1d8848133217c800bcb25d" }, - "nvim-treesitter": { "branch": "master", "commit": "a95de26cd75a04df9283e0af1fd38f001238eb25" }, - "nvim-web-devicons": { "branch": "master", "commit": "27eac98fd6675d29d0e19d4d0622fd7a3968483a" }, - "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, + "nvim-highlight-colors": { "branch": "main", "commit": "582064092cff170331064b7d198a5b97cb261fca" }, + "nvim-jdtls": { "branch": "master", "commit": "10691312d51c5485c656a71258b55d3798d3fb3e" }, + "nvim-lspconfig": { "branch": "master", "commit": "38de86f82efd9ba0881203767d6a8e1815abca28" }, + "nvim-nio": { "branch": "master", "commit": "632024157d01e8bc48fd7df6a7de8ffe3fdd4f3a" }, + "nvim-treesitter": { "branch": "master", "commit": "ea2b137f35fb1e87a6471ec311805920fdf45745" }, + "nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" }, + "oil.nvim": { "branch": "master", "commit": "2cb39e838e9dcd8b374f09a3a87a2e5ec9d372f6" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, - "telescope.nvim": { "branch": "master", "commit": "35f94f0ef32d70e3664a703cefbe71bd1456d899" }, - "tokyonight.nvim": { "branch": "main", "commit": "67afeaf7fd6ebba000633e89f63c31694057edde" }, - "trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" }, + "telescope.nvim": { "branch": "master", "commit": "2df52609a1632de5d77a0b2416db6ad9cf32e463" }, + "tokyonight.nvim": { "branch": "main", "commit": "0fae425aaab04a5f97666bd431b96f2f19c36935" }, + "trouble.nvim": { "branch": "main", "commit": "a8264a65a0b894832ea642844f5b7c30112c458f" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, - "vim-dadbod": { "branch": "master", "commit": "960bbb7de11b7282a68d579a64e838b487934493" }, - "vim-fugitive": { "branch": "master", "commit": "dac8e5c2d85926df92672bf2afb4fc48656d96c7" } + "vim-dadbod": { "branch": "master", "commit": "fb30422b7bee7e2fa4205a4d226f01477f4fc593" }, + "vim-fugitive": { "branch": "master", "commit": "4f59455d2388e113bd510e85b310d15b9228ca0d" }, + "vim-tabby": { "branch": "main", "commit": "afd76df166ed0f223ede1071e0cfde8075cc4a24" } } \ No newline at end of file diff --git a/lua/barink/init.lua b/lua/barink/init.lua index ac71066..72140fc 100644 --- a/lua/barink/init.lua +++ b/lua/barink/init.lua @@ -3,15 +3,23 @@ require("barink.keys") local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) - -require("lazy").setup("barink.plugins") +local opts = { + defaults = { + lazy = false, + }, + change_detection = { + enabled = true, + notify = false, + }, +} +require("lazy").setup("barink.plugins", opts) diff --git a/lua/barink/keys.lua b/lua/barink/keys.lua index 930d945..a3dca3e 100644 --- a/lua/barink/keys.lua +++ b/lua/barink/keys.lua @@ -1,42 +1,54 @@ -- Keymaps vim.g.mapleader = " " -vim.keymap.set('n', '', vim.cmd.UndotreeToggle) -vim.keymap.set('n', 'p', [["_dP]]) -vim.keymap.set('n', 'fa', vim.lsp.buf.format) -vim.keymap.set('n', 'm', ":Mason") -vim.keymap.set('n', 'e',':Explore', {noremap = false, silent=true}) -vim.keymap.set('n', 'le',':Lexplore', {noremap = false, silent=true}) -local osname = vim.loop.os_uname().sysname -if osname == "Windows_NT" then - vim.keymap.set('n', 'x', function() print("sorry this is windows!") end) -elseif osname == "Linux" then - -- Linux only!! - vim.keymap.set('n', 'x', "!chmod +x %", { silent = true }) -end --- Move lines while in visual mode -vim.keymap.set('v', '', ':m \'>+1gv=gv', {noremap = true}) -vim.keymap.set('v', '', ':m \'<-2gv=gv', {noremap = true}) +vim.keymap.set("n", "", vim.cmd.UndotreeToggle) +vim.keymap.set("n", "p", [["_dP]]) +vim.keymap.set("n", "fa", vim.lsp.buf.format) +vim.keymap.set("n", "m", ":Mason") +vim.keymap.set("n", "e", ":Explore", { noremap = false, silent = true }) +vim.keymap.set("n", "le", ":Lexplore", { noremap = false, silent = true }) +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) +-- Move lines while in visual mode +vim.keymap.set("v", "", ":m '>+1gv=gv", { noremap = true }) +vim.keymap.set("v", "", ":m '<-2gv=gv", { noremap = true }) --- Move lines while in normal mode -vim.keymap.set('n', '', ':m .+1==', {noremap = true}) -vim.keymap.set('n', '', ':m .-2==', {noremap = true}) +-- Move lines while in normal mode +vim.keymap.set("n", "", ":m .+1==", { noremap = true }) +vim.keymap.set("n", "", ":m .-2==", { noremap = true }) --- Move line in edit mode -vim.keymap.set('i', '', ':m .+1==gi', {noremap = true}) -vim.keymap.set('i', '', ':m .-2==gi', {noremap = true}) +-- Move line in edit mode +vim.keymap.set("i", "", ":m .+1==gi", { noremap = true }) +vim.keymap.set("i", "", ":m .-2==gi", { noremap = true }) -- Diagnostics ! -vim.keymap.set('n', '', function() require('trouble').toggle() end ) -vim.keymap.set('n', 'd', function () vim.diagnostic.open_float() end ) -vim.keymap.set('n', 'dn', function () vim.diagnostic.goto_next() end ) -vim.keymap.set('n', 'dp', function () vim.diagnostic.goto_prev() end ) +vim.keymap.set("n", "", function() + require("trouble").toggle() +end) +vim.keymap.set("n", "d", function() + vim.diagnostic.open_float() +end) +vim.keymap.set("n", "dn", function() + vim.diagnostic.goto_next() +end) +vim.keymap.set("n", "dp", function() + vim.diagnostic.goto_prev() +end) -- Debugging -vim.keymap.set('n', 'sb', function () require('dap').toggle_breakpoint() end ) -vim.keymap.set('n', 'db', function () require('dapui').toggle() end ) -vim.keymap.set('n', '', function () print("Start debug session" ) require('dap').continue() end ) -vim.keymap.set('n', '', function () require('dap').step_over() end ) -vim.keymap.set('n', '', function () require('dap').step_into() end ) +vim.keymap.set("n", "sb", function() + require("dap").toggle_breakpoint() +end) +vim.keymap.set("n", "db", function() + require("dapui").toggle() +end) +vim.keymap.set("n", "", function() + require("dap").continue() +end) +vim.keymap.set("n", "", function() + require("dap").step_over() +end) +vim.keymap.set("n", "", function() + require("dap").step_into() +end) -vim.keymap.set('n', '=',":Gen Generate") +vim.keymap.set("n", "=", ":Gen Generate") diff --git a/lua/barink/plugins/conform.lua b/lua/barink/plugins/conform.lua new file mode 100644 index 0000000..d0992cc --- /dev/null +++ b/lua/barink/plugins/conform.lua @@ -0,0 +1,18 @@ +return { + "stevearc/conform.nvim", + opts = {}, + config = function() + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + javascript = { { "prettierd", "prettier" } }, + }, + }) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*", + callback = function(args) + require("conform").format({ buffer = args.buf }) + end, + }) + end, +} diff --git a/lua/barink/plugins/hardtime.lua b/lua/barink/plugins/hardtime.lua deleted file mode 100644 index dc39d23..0000000 --- a/lua/barink/plugins/hardtime.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { - 'm4xshen/hardtime.nvim', - dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim"}, - opts = { - restriction_mode = "hint" - } - } -} diff --git a/lua/barink/plugins/lsp.lua b/lua/barink/plugins/lsp.lua index eb52853..6714af0 100644 --- a/lua/barink/plugins/lsp.lua +++ b/lua/barink/plugins/lsp.lua @@ -1,145 +1,151 @@ -return - { - 'neovim/nvim-lspconfig', - dependencies = { - "williamboman/mason-lspconfig", - "williamboman/mason.nvim", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "hrsh7th/nvim-cmp", - { - 'L3MON4D3/LuaSnip', - dependencies = 'hrsh7th/nvim-cmp', - version = "v2.*", - }, - {'mfussenegger/nvim-jdtls', dependencies = {'nvim-dap'}}, - { - "olrtg/nvim-emmet", - config = function() - vim.keymap.set({ "n", "v" }, 'xe', require('nvim-emmet').wrap_with_abbreviation) - end, - } - }, - config = function() - require("mason").setup() - require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls", "bashls", "rust_analyzer" } - }) - local cmp = require('cmp') - cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = cmp.config.sources({ - { name = 'path' }, - { name = 'nvim_lsp', keyword_length = 1 }, - { name = 'luasnip', option = { show_autosnippets = true}}, - }, { - { name = 'buffer', keyword_length = 2 }, - }), - window = { - documentation = cmp.config.window.bordered() - }, +return { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason-lspconfig", + "williamboman/mason.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + { + "L3MON4D3/LuaSnip", + dependencies = "hrsh7th/nvim-cmp", + version = "v2.*", + }, + { "mfussenegger/nvim-jdtls", dependencies = { "nvim-dap" } }, + { + "olrtg/nvim-emmet", + config = function() + vim.keymap.set({ "n", "v" }, "xe", require("nvim-emmet").wrap_with_abbreviation) + end, + }, + }, + config = function() + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "bashls", "rust_analyzer" }, + }) + local cmp = require("cmp") + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "path" }, + { name = "nvim_lsp", keyword_length = 1 }, + { name = "luasnip", option = { show_autosnippets = true } }, + }, { + { name = "buffer", keyword_length = 2 }, + }), + window = { + documentation = cmp.config.window.bordered(), + }, + }) - }) + -- Set configuration for specific filetype. + cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "git" }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = "buffer" }, + }), + }) - -- Set configuration for specific filetype. - cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). - }, { - { name = 'buffer' }, - }) - }) + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) - -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } - }) + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + matching = { disallow_symbol_nonprefix_matching = false }, + }) - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }), - matching = { disallow_symbol_nonprefix_matching = false } - }) + local lsp = require("lspconfig") - local lsp = require("lspconfig") + lsp.emmet_language_server.setup({}) - lsp.emmet_language_server.setup({}) + lsp.lua_ls.setup({ + capabilities = require("cmp_nvim_lsp").default_capabilities(), + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + }, + }, + }) + local ls = require("luasnip") + ls.config.set_config({ + history = true, + updateevents = "TextChanged, TextChangedI", + enable_autosnippets = true, + }) - lsp.lua_ls.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), - settings = { - Lua = { - diagnostics = { - globals = { 'vim' } - } - } - } - }) - local ls = require("luasnip") - ls.config.set_config({ - history = true, - updateevents = "TextChanged, TextChangedI", - enable_autosnippets = true, - }) + vim.keymap.set({ "i", "s" }, "", 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 }) - vim.keymap.set({"i", "s"}, "", 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}) + require("luasnip.loaders.from_lua").load({ paths = "C:\\Users\\nigel\\AppData\\Local\\nvim\\lua\\snippets" }) - require("luasnip.loaders.from_lua").load({paths= "C:\\Users\\nigel\\AppData\\Local\\nvim\\lua\\snippets"}) + -- Set up lspconfig. + local capabilities = require("cmp_nvim_lsp").default_capabilities() - -- Set up lspconfig. - local capabilities = require('cmp_nvim_lsp').default_capabilities() + require("lspconfig")["asm_lsp"].setup({ + capabilities = capabilities, + }) - require('lspconfig')['asm_lsp'].setup({ - capabilities = capabilities - }) + require("lspconfig")["zls"].setup({ + capabilities = capabilities, + }) - require('lspconfig')['zls'].setup({ - capabilities = capabilities - }) + require("lspconfig")["rust_analyzer"].setup({ + capabilities = capabilities, + }) - require('lspconfig')['rust_analyzer'].setup({ - capabilities = capabilities - }) + require("lspconfig")["jdtls"].setup({ + capabilities = capabilities, + }) - require('lspconfig')['jdtls'].setup({ - capabilities = capabilities - }) - - require('lspconfig')['bashls'].setup({ - capabilities = capabilities - }) - - require('lspconfig')['gopls'].setup({ - capabilities = capabilities - }) - end - } + require("lspconfig")["bashls"].setup({ + capabilities = capabilities, + }) + require("lspconfig")["tsserver"].setup({ + capabilities = capabilities, + }) + require("lspconfig")["gopls"].setup({ + capabilities = capabilities, + }) + end, +} diff --git a/lua/barink/plugins/oil.lua b/lua/barink/plugins/oil.lua new file mode 100644 index 0000000..e1b0f0a --- /dev/null +++ b/lua/barink/plugins/oil.lua @@ -0,0 +1,14 @@ +return { + 'stevearc/oil.nvim', + opts = {}, + dependencies = {"nvim-tree/nvim-web-devicons"}, + config = function () + require("oil").setup( + { + default_file_explorer=false + } + ) + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory"}) + + end +}