diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5672525 --- /dev/null +++ b/init.lua @@ -0,0 +1,28 @@ +vim.cmd("let mapleader = ' '") + +require('preferences') +require('keymaps') + +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) + +require('lazy').setup({ + spec = { + { import = 'plugins' }, + }, +}) + +vim.cmd('colorscheme onedark') diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..c698ae8 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,19 @@ +{ + "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, + "none-ls.nvim": { "branch": "main", "commit": "cfa65d86e21eeb60544d5e823f6db43941322a53" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lspconfig": { "branch": "master", "commit": "ff97d376b1d22b2eaf9274605531babf0cd0cf21" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "1420fb9e07b1d80cc6d87e7d90827fb2c1109cb3" } +} diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..13157f3 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,10 @@ +vim.keymap.set('n', '', ':Neotree filesystem reveal left toggle') + +vim.keymap.set('n', 'ff', ':Telescope find_files') +vim.keymap.set('n', 'tc', ':Telescope colorscheme') +vim.keymap.set('n', 'of', ':Telescope oldfiles') +vim.keymap.set('n', 'tl', ':Telescope live_grep') +vim.keymap.set('n', 'km', ':Telescope keymaps') + +vim.keymap.set('n', 'ft', vim.lsp.buf.format, {}) + diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/plugins/auto-pairs.lua b/lua/plugins/auto-pairs.lua new file mode 100644 index 0000000..4b256c2 --- /dev/null +++ b/lua/plugins/auto-pairs.lua @@ -0,0 +1,8 @@ +return { + 'altermo/ultimate-autopair.nvim', + event = { 'InsertEnter', 'CmdlineEnter' }, + branch = 'v0.6', --recommended as each new version will have breaking changes + opts = { + --Config goes here + }, +} diff --git a/lua/plugins/colorschemes.lua b/lua/plugins/colorschemes.lua new file mode 100644 index 0000000..3b137c9 --- /dev/null +++ b/lua/plugins/colorschemes.lua @@ -0,0 +1,27 @@ +return { + 'navarasu/onedark.nvim', + + config = function() + require('onedark').setup({ + style = 'deep', + transparent = true, + term_colors = false, + ending_tildes = false, + cmp_itemkind_reverse = false, + -- toggle_style_key = 'ot', + -- toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' }, + + -- Options are italic, bold, underline, none and combos 'italic,bold' + code_style = { + comments = 'italic', + keywords = 'none', + functions = 'none', + strings = 'none', + variables = 'none', + }, + + lualine = { transparent = true }, + diagnostics = { darker = true, undercurl = true, background = false }, + }) + end, +} diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua new file mode 100644 index 0000000..6f7b0a1 --- /dev/null +++ b/lua/plugins/completions.lua @@ -0,0 +1,62 @@ +return { + { + 'hrsh7th/cmp-nvim-lsp', + }, + { + 'hrsh7th/nvim-cmp', + + dependencies = { + 'saadparwaiz1/cmp_luasnip', + 'L3MON4D3/LuaSnip', + 'rafamadriz/friendly-snippets', + 'onsails/lspkind.nvim', + }, + + config = function() + local cmp = require('cmp') + local lspkind = require('lspkind') + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + require('luasnip.loaders.from_vscode').lazy_load() + 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 = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }), + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- can also be a function to dynamically calculate max width such as + -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + show_labelDetails = true, -- show labelDetails in menu. Disabled by default + + -- The function below will be called before any actual modifications from lspkind + -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) + before = function(entry, vim_item) + return vim_item + end, + }), + }, + }) + end, + }, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..ccc14a3 --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,29 @@ +return { + { + 'williamboman/mason.nvim', + + config = function() + require('mason').setup() + end, + }, + + { + 'neovim/nvim-lspconfig', + + config = function() + local lspconfig = require('lspconfig') + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + lspconfig.lua_ls.setup({ + settings = { + Lua = { + diagnostics = { + globals = { 'vim' }, + }, + }, + }, + capabilities = capabilities, + }) + end, + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..a8ab6fc --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,9 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua new file mode 100644 index 0000000..bd61589 --- /dev/null +++ b/lua/plugins/none-ls.lua @@ -0,0 +1,13 @@ +return { + 'nvimtools/none-ls.nvim', + + config = function() + local null_ls = require('null-ls') + + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + }, + }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..1bbb767 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,13 @@ +return { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + + config = function() + require('telescope').setup({ + pickers = { + colorscheme = { enable_preview = true }, + }, + }) + end, +} diff --git a/lua/preferences.lua b/lua/preferences.lua new file mode 100644 index 0000000..8799634 --- /dev/null +++ b/lua/preferences.lua @@ -0,0 +1,8 @@ +vim.cmd([[autocmd FileType * set formatoptions-=ro]]) + +vim.cmd('set number') +vim.cmd('set relativenumber') +vim.cmd('set noexpandtab') +vim.cmd('set tabstop=6') +vim.cmd('set shiftwidth=6') +vim.cmd('set nowrap')