diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..2fb22b9 --- /dev/null +++ b/init.lua @@ -0,0 +1,26 @@ +vim.g.mapleader = " " + +require('packer') + +require("config.lsp") +require("config.diagnostics") +require("config.mappings") +require("config.commands") + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.smartindent= true + +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 + +vim.opt.ignorecase = true +vim.opt.smartcase = true + +vim.opt.linebreak = true +vim.opt.showbreak = "—>" + +vim.opt.mouse = "n" +vim.opt.mousemodel = "popup" +vim.opt.mousescroll = {"ver:1", "hor:0"} diff --git a/lua/config/commands.lua b/lua/config/commands.lua new file mode 100644 index 0000000..e69de29 diff --git a/old/lua/config/diagnostics.lua b/lua/config/diagnostics.lua similarity index 100% rename from old/lua/config/diagnostics.lua rename to lua/config/diagnostics.lua diff --git a/old/lua/config/lsp.lua b/lua/config/lsp.lua similarity index 100% rename from old/lua/config/lsp.lua rename to lua/config/lsp.lua diff --git a/old/lua/config/mappings.lua b/lua/config/mappings.lua similarity index 87% rename from old/lua/config/mappings.lua rename to lua/config/mappings.lua index b19d600..360b6d4 100644 --- a/old/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -19,6 +19,4 @@ vim.keymap.set('n', ld('fg'), builtin.live_grep, { desc = 'Telescope live grep' vim.keymap.set('n', ld('fb'), builtin.buffers, { desc = 'Telescope buffers' }) vim.keymap.set('n', ld('fh'), builtin.help_tags, { desc = 'Telescope help tags' }) -vim.keymap.set('n', ld('t'), auto('Trouble diagnostics toggle'), {desc = 'Toggle diagnostics (Trouble)'}) - vim.keymap.set('n', ld('q'), auto('NERDTreeToggle'), {desc = 'toggle nerdtree'}) diff --git a/lua/packer.lua b/lua/packer.lua new file mode 100644 index 0000000..037ba23 --- /dev/null +++ b/lua/packer.lua @@ -0,0 +1,25 @@ +local config_module_dir = 'packs/' +local packs_file = 'packs.lua' + +vim.pack.add(require(packs_file)) + +local config_module_path = vim.fs.joinpath(vim.fn.stdpath('config'), 'lua/' .. config_module_dir) +for name, _ in vim.fs.dir(config_module_path) do + if name == 'lua.lua' then + goto continue + end + local ok, config = pcall(require,config_module_dir .. name:gsub('%.lua','')) + if ok then + if config[1] ~= nil then + config[1]() + end + if config['config'] ~= nil then + config['config']() + end + end + ::continue:: +end + +vim.api.nvim_create_user_command('UpdatePacks', function () + vim.pack.update() +end, {}) diff --git a/lua/packs/cmp.lua b/lua/packs/cmp.lua new file mode 100644 index 0000000..3d33c2d --- /dev/null +++ b/lua/packs/cmp.lua @@ -0,0 +1,56 @@ +function config_cmp() + local cmp = require'cmp' + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + 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 }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + }) + }) + + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + matching = { disallow_symbol_nonprefix_matching = false } + }) + +-- local capabilities = require('cmp_nvim_lsp').default_capabilities() +-- vim.lsp.config('', { +-- capabilities = capabilities +-- }) +-- vim.lsp.enable('') + +end + +return { + config_cmp +} diff --git a/lua/packs/lua.lua b/lua/packs/lua.lua new file mode 100644 index 0000000..1199522 --- /dev/null +++ b/lua/packs/lua.lua @@ -0,0 +1,22 @@ +function gh(link) + return 'https://github.com/' .. link +end + +return { + gh('L3MON4D3/LuaSnip'), + gh('folke/which-key.nvim'), + gh('hrsh7th/cmp-buffer'), + gh('hrsh7th/cmp-cmdline'), + gh('hrsh7th/cmp-nvim-lsp'), + gh('hrsh7th/cmp-path'), + gh('hrsh7th/nvim-cmp'), + gh('iamcco/markdown-preview.nvim'), + gh('midoBB/nvim-quicktype'), + gh('nvim-lua/plenary.nvim'), + gh('neovim/nvim-lspconfig'), + gh('nvim-telescope/telescope.nvim'), + gh('preservim/nerdtree'), + gh('saadparwaiz1/cmp_luasnip'), + gh('sakhnik/nvim-gdb') +} + diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..f85a3b8 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,64 @@ +{ + "plugins": { + "LuaSnip": { + "rev": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24", + "src": "https://github.com/L3MON4D3/LuaSnip" + }, + "cmp-buffer": { + "rev": "b74fab3656eea9de20a9b8116afa3cfc4ec09657", + "src": "https://github.com/hrsh7th/cmp-buffer" + }, + "cmp-cmdline": { + "rev": "d126061b624e0af6c3a556428712dd4d4194ec6d", + "src": "https://github.com/hrsh7th/cmp-cmdline" + }, + "cmp-nvim-lsp": { + "rev": "cbc7b02bb99fae35cb42f514762b89b5126651ef", + "src": "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + "cmp-path": { + "rev": "c642487086dbd9a93160e1679a1327be111cbc25", + "src": "https://github.com/hrsh7th/cmp-path" + }, + "cmp_luasnip": { + "rev": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90", + "src": "https://github.com/saadparwaiz1/cmp_luasnip" + }, + "markdown-preview.nvim": { + "rev": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee", + "src": "https://github.com/iamcco/markdown-preview.nvim" + }, + "nerdtree": { + "rev": "690d061b591525890f1471c6675bcb5bdc8cdff9", + "src": "https://github.com/preservim/nerdtree" + }, + "nvim-cmp": { + "rev": "2ffe79f1f021def8dd1fcd81deb16f1bb0d989f3", + "src": "https://github.com/hrsh7th/nvim-cmp" + }, + "nvim-gdb": { + "rev": "67abac716b626ece57f3a7c72121542f0b3edfe9", + "src": "https://github.com/sakhnik/nvim-gdb" + }, + "nvim-lspconfig": { + "rev": "77b7432d4770d23b277d37923e5a08a442d8bb07", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-quicktype": { + "rev": "6d557a32fec1fb8a0b635e98cb856b24c7f0ef00", + "src": "https://github.com/midoBB/nvim-quicktype" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "telescope.nvim": { + "rev": "40aedd8a68c78a656a10a8d62d80c54af59420fb", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + } + } +} diff --git a/old/init.lua b/old/init.lua deleted file mode 100644 index 7633672..0000000 --- a/old/init.lua +++ /dev/null @@ -1,28 +0,0 @@ -vim.g.mapleader = "" - -require("config.lazy") -require("config.lsp") -require("config.diagnostics") -require("config.mappings") -require("lazy").setup("plugins") - -local opt = vim.opt - -opt.number = true -opt.relativenumber = true - -opt.smartindent= true ---opt.clipboard='unnamedplus' - -opt.tabstop = 4 -opt.shiftwidth = 4 - -opt.ignorecase = true -opt.smartcase = true - -opt.linebreak = true -opt.showbreak = "—>" - -opt.mouse = "n" -opt.mousemodel = "popup" -opt.mousescroll = {"ver:1", "hor:0"} diff --git a/old/lazy-lock.json b/old/lazy-lock.json deleted file mode 100644 index 43f25f6..0000000 --- a/old/lazy-lock.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, - "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, - "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, - "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "nerdtree": { "branch": "master", "commit": "690d061b591525890f1471c6675bcb5bdc8cdff9" }, - "nvim-cmp": { "branch": "main", "commit": "2ffe79f1f021def8dd1fcd81deb16f1bb0d989f3" }, - "nvim-gdb": { "branch": "master", "commit": "67abac716b626ece57f3a7c72121542f0b3edfe9" }, - "nvim-lspconfig": { "branch": "master", "commit": "910f0c4d46aa186641518395bc7e6fffb4d23baf" }, - "nvim-quicktype": { "branch": "main", "commit": "6d557a32fec1fb8a0b635e98cb856b24c7f0ef00" }, - "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, - "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, - "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, - "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, - "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } -} diff --git a/old/lua/config/lazy.lua b/old/lua/config/lazy.lua deleted file mode 100644 index f5ee74c..0000000 --- a/old/lua/config/lazy.lua +++ /dev/null @@ -1,35 +0,0 @@ --- Bootstrap lazy.nvim -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end -end -vim.opt.rtp:prepend(lazypath) - --- Make sure to setup `mapleader` and `maplocalleader` before --- loading lazy.nvim so that mappings are correct. --- This is also a good place to setup other settings (vim.opt) -vim.g.mapleader = " " -vim.g.maplocalleader = "\\" - --- Setup lazy.nvim -require("lazy").setup({ - spec = { - -- import your plugins - { import = "plugins" }, - }, - -- Configure any other settings here. See the documentation for more details. - -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "habamax" } }, - -- automatically check for plugin updates - checker = { enabled = true }, -}) diff --git a/old/lua/plugins/cmp.lua b/old/lua/plugins/cmp.lua deleted file mode 100644 index b26ba89..0000000 --- a/old/lua/plugins/cmp.lua +++ /dev/null @@ -1,93 +0,0 @@ -function config_cmp() - -- Set up nvim-cmp. - local cmp = require'cmp' - - cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - --vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) - - -- For `mini.snippets` users: - -- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert - -- insert({ body = args.body }) -- Insert at cursor - -- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) - -- require("cmp.config").set_onetime({ sources = {} }) - end, - }, - window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - }, - 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 = 'vsnip' }, -- For vsnip users. - { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. - }, { - { name = 'buffer' }, - }) - }) - - -- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below - -- Set configuration for specific filetype. - --[[ cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'git' }, - }, { - { name = 'buffer' }, - }) - }) - require("cmp_git").setup() ]]-- - - -- 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() - -- Replace with each lsp server you've enabled. - vim.lsp.config('', { - capabilities = capabilities - }) - vim.lsp.enable('') - -end - -return { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-cmdline', - { - 'hrsh7th/nvim-cmp', - config = config_cmp - }, -} diff --git a/old/lua/plugins/debug.lua b/old/lua/plugins/debug.lua deleted file mode 100644 index 1af59de..0000000 --- a/old/lua/plugins/debug.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'sakhnik/nvim-gdb', -} diff --git a/old/lua/plugins/diagnostics.lua b/old/lua/plugins/diagnostics.lua deleted file mode 100644 index 9325825..0000000 --- a/old/lua/plugins/diagnostics.lua +++ /dev/null @@ -1,7 +0,0 @@ -return - { - 'folke/trouble.nvim', - opts = {}, - cmd = "Trouble", - } - diff --git a/old/lua/plugins/markdown.lua b/old/lua/plugins/markdown.lua deleted file mode 100644 index bb96fbc..0000000 --- a/old/lua/plugins/markdown.lua +++ /dev/null @@ -1,9 +0,0 @@ -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/old/lua/plugins/misc.lua b/old/lua/plugins/misc.lua deleted file mode 100644 index cc298f1..0000000 --- a/old/lua/plugins/misc.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'neovim/nvim-lspconfig', -} diff --git a/old/lua/plugins/nvim_quicktype.lua b/old/lua/plugins/nvim_quicktype.lua deleted file mode 100644 index d6ae673..0000000 --- a/old/lua/plugins/nvim_quicktype.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - "midoBB/nvim-quicktype" , - cmd = "QuickType", - ft = { "typescript", "python", "java", "go", "rust", "cs", "swift", "elixir", "kotlin", "typescriptreact", "dart" } -} diff --git a/old/lua/plugins/snip.lua b/old/lua/plugins/snip.lua deleted file mode 100644 index 241f02e..0000000 --- a/old/lua/plugins/snip.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', -} diff --git a/old/lua/plugins/telescope.lua b/old/lua/plugins/telescope.lua deleted file mode 100644 index 58427d0..0000000 --- a/old/lua/plugins/telescope.lua +++ /dev/null @@ -1,11 +0,0 @@ -return - { - 'nvim-telescope/telescope.nvim', version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - -- optional but recommended - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - - }, - } - diff --git a/old/lua/plugins/theme.lua b/old/lua/plugins/theme.lua deleted file mode 100644 index 7ed156a..0000000 --- a/old/lua/plugins/theme.lua +++ /dev/null @@ -1,13 +0,0 @@ -function theme() - vim.cmd('colorscheme tokyonight') -end - -return { - { - "folke/tokyonight.nvim", - lazy = false, - priority = 1000, - config = theme, - opts = {}, - }, -} diff --git a/old/lua/plugins/tree.lua b/old/lua/plugins/tree.lua deleted file mode 100644 index a623987..0000000 --- a/old/lua/plugins/tree.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'preservim/nerdtree', -} diff --git a/old/lua/plugins/which.lua b/old/lua/plugins/which.lua deleted file mode 100644 index 57af31e..0000000 --- a/old/lua/plugins/which.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'folke/which-key.nvim', -} diff --git a/old/lua/search.lua b/old/lua/search.lua deleted file mode 100644 index ffb40a9..0000000 --- a/old/lua/search.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt.ignorecase = true -vim.opt.smartcase = true -vim.opt.showmatch = true