From b844031323ecff57d5810fdc550b8bab6549a0ab Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Tue, 26 Mar 2024 12:51:53 +0100 Subject: [PATCH] FIX: Restructured nvim plugins. moved the configuration for each plugin through Lazy in seperate files. --- init.lua | 4 +- lua/barink/colorscheme.lua | 9 -- lua/barink/init.lua | 181 +----------------------------- lua/barink/keys.lua | 15 +++ lua/barink/lazy.lua | 1 - lua/barink/plugins/fidget.lua | 6 + lua/barink/plugins/fugitive.lua | 1 + lua/barink/plugins/lsp.lua | 88 +++++++++++++++ lua/barink/plugins/telescope.lua | 10 ++ lua/barink/plugins/tokyonight.lua | 18 +++ lua/barink/plugins/treesitter.lua | 14 +++ lua/barink/plugins/undotree.lua | 1 + lua/barink/vim.lua | 26 +++++ 13 files changed, 185 insertions(+), 189 deletions(-) delete mode 100644 lua/barink/colorscheme.lua create mode 100644 lua/barink/keys.lua delete mode 100644 lua/barink/lazy.lua create mode 100644 lua/barink/plugins/fidget.lua create mode 100644 lua/barink/plugins/fugitive.lua create mode 100644 lua/barink/plugins/lsp.lua create mode 100644 lua/barink/plugins/telescope.lua create mode 100644 lua/barink/plugins/tokyonight.lua create mode 100644 lua/barink/plugins/treesitter.lua create mode 100644 lua/barink/plugins/undotree.lua create mode 100644 lua/barink/vim.lua diff --git a/init.lua b/init.lua index 6faa848..ecfc612 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,3 @@ require("barink") -vim.g.netrw_browse_split = 0 -vim.g.netrw_winsize = 25 + + diff --git a/lua/barink/colorscheme.lua b/lua/barink/colorscheme.lua deleted file mode 100644 index 2b7edb3..0000000 --- a/lua/barink/colorscheme.lua +++ /dev/null @@ -1,9 +0,0 @@ - -require("tokyonight").setup({ - style="night", - light_style="day", - transparent=true, - terminal_colors=true, - dim_inactive=false, - lualine_bold=false -}) diff --git a/lua/barink/init.lua b/lua/barink/init.lua index 50cb88b..a248f0f 100644 --- a/lua/barink/init.lua +++ b/lua/barink/init.lua @@ -1,3 +1,6 @@ +require("barink.vim") +require("barink.keys") + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ @@ -10,182 +13,6 @@ if not vim.loop.fs_stat(lazypath) then }) end vim.opt.rtp:prepend(lazypath) -require("lazy").setup({ - { - "folke/tokyonight.nvim", - lazy = false, - priority = 1000, - opts = {}, - config = function() - require("tokyonight").setup({ - style = "night", - light_style = "day", - transparent = true, - terminal_colors = true, - dim_inactive = false, - lualine_bold = false, - }) - vim.cmd [[colorscheme tokyonight]] - end - }, - { - "nvim-telescope/telescope.nvim", - dependencies = { 'nvim-lua/plenary.nvim' } - }, - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - config = function() - local configs = require("nvim-treesitter.configs") +require("lazy").setup("barink.plugins") - configs.setup({ - ensure_installed = { "c", "lua", "vim", "vimdoc", "bash" }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - }) - end - }, - { "mbbill/undotree" }, - { - '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', - }, - 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 = 'nvim_lsp' }, - { name = 'luasnip' }, - }, { - { 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 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 } - }) - - -- Set up lspconfig. - local capabilities = require('cmp_nvim_lsp').default_capabilities() - - require('lspconfig')['asm_lsp'].setup({ - capabilities = capabilities - }) - - local lsp = require("lspconfig") - lsp.lua_ls.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), - settings = { - Lua = { - diagnostics = { - globals = { 'vim' } - } - } - } - }) - end - }, - { 'tpope/vim-fugitive' }, - { - "j-hui/fidget.nvim", - config = function() - require('fidget').setup({}) - end - } - -}, {}) - --- Set basic vim options -vim.opt.guicursor = "" - -vim.opt.nu = true -vim.opt.relativenumber = true - -local tab_spacing = 4 -vim.opt.tabstop = tab_spacing -vim.opt.softtabstop = tab_spacing -vim.opt.shiftwidth = tab_spacing -vim.opt.expandtab = true - -vim.opt.smartindent = true - -vim.opt.wrap = false - -vim.opt.hlsearch = false -vim.opt.incsearch = true - -vim.opt.termguicolors = true - -vim.opt.scrolloff = 8 - --- Keymaps -vim.g.mapleader = " " - -local builtin = require('telescope.builtin') - -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fs', builtin.git_files, {}) - -vim.keymap.set('n', '', vim.cmd.UndotreeToggle) - -vim.keymap.set('n', 'p', [["_dP]]) -vim.keymap.set('n', 'f', vim.lsp.buf.format) -vim.keymap.set('n', 'm', ":Mason") -local osname = vim.loop.os_uname().sysname -if osname == "Windows_NT" then - print("Windows Detected!!") - 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 diff --git a/lua/barink/keys.lua b/lua/barink/keys.lua new file mode 100644 index 0000000..bd0b6c9 --- /dev/null +++ b/lua/barink/keys.lua @@ -0,0 +1,15 @@ +-- 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") +local osname = vim.loop.os_uname().sysname +if osname == "Windows_NT" then + print("Windows Detected!!") + 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 diff --git a/lua/barink/lazy.lua b/lua/barink/lazy.lua deleted file mode 100644 index 8b13789..0000000 --- a/lua/barink/lazy.lua +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lua/barink/plugins/fidget.lua b/lua/barink/plugins/fidget.lua new file mode 100644 index 0000000..8d5b1c9 --- /dev/null +++ b/lua/barink/plugins/fidget.lua @@ -0,0 +1,6 @@ +return { + "j-hui/fidget.nvim", + config = function() + require('fidget').setup({}) + end + } diff --git a/lua/barink/plugins/fugitive.lua b/lua/barink/plugins/fugitive.lua new file mode 100644 index 0000000..f776568 --- /dev/null +++ b/lua/barink/plugins/fugitive.lua @@ -0,0 +1 @@ +return { 'tpope/vim-fugitive' } diff --git a/lua/barink/plugins/lsp.lua b/lua/barink/plugins/lsp.lua new file mode 100644 index 0000000..16055eb --- /dev/null +++ b/lua/barink/plugins/lsp.lua @@ -0,0 +1,88 @@ +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', + }, + 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 = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { 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 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 } + }) + + -- Set up lspconfig. + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + require('lspconfig')['asm_lsp'].setup({ + capabilities = capabilities + }) + + local lsp = require("lspconfig") + lsp.lua_ls.setup({ + capabilities = require('cmp_nvim_lsp').default_capabilities(), + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } + }) + end + } diff --git a/lua/barink/plugins/telescope.lua b/lua/barink/plugins/telescope.lua new file mode 100644 index 0000000..610c4df --- /dev/null +++ b/lua/barink/plugins/telescope.lua @@ -0,0 +1,10 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local builtin = require('telescope.builtin') + + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fs', builtin.git_files, {}) + end +} diff --git a/lua/barink/plugins/tokyonight.lua b/lua/barink/plugins/tokyonight.lua new file mode 100644 index 0000000..a5fef0d --- /dev/null +++ b/lua/barink/plugins/tokyonight.lua @@ -0,0 +1,18 @@ +return { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = {}, + config = function() + require("tokyonight").setup({ + style = "night", + light_style = "day", + transparent = true, + terminal_colors = true, + dim_inactive = false, + lualine_bold = false, + }) + + vim.cmd [[colorscheme tokyonight]] + end + } diff --git a/lua/barink/plugins/treesitter.lua b/lua/barink/plugins/treesitter.lua new file mode 100644 index 0000000..0b0b99e --- /dev/null +++ b/lua/barink/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { "c", "lua", "vim", "vimdoc", "bash" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end + } diff --git a/lua/barink/plugins/undotree.lua b/lua/barink/plugins/undotree.lua new file mode 100644 index 0000000..c04453f --- /dev/null +++ b/lua/barink/plugins/undotree.lua @@ -0,0 +1 @@ +return { "mbbill/undotree" } diff --git a/lua/barink/vim.lua b/lua/barink/vim.lua new file mode 100644 index 0000000..d409e5b --- /dev/null +++ b/lua/barink/vim.lua @@ -0,0 +1,26 @@ +-- Set basic vim options +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +local tab_spacing = 4 +vim.opt.tabstop = tab_spacing +vim.opt.softtabstop = tab_spacing +vim.opt.shiftwidth = tab_spacing +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 + +vim.g.netrw_browse_split = 0 +vim.g.netrw_winsize = 25 +