diff --git a/neovim/.config/nvim/.luarc.json b/neovim/.config/nvim/.luarc.json new file mode 100644 index 0000000..e1b9d70 --- /dev/null +++ b/neovim/.config/nvim/.luarc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.workspace.checkThirdParty": false +} \ No newline at end of file diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua index 6ab7bd4..d89f75f 100644 --- a/neovim/.config/nvim/init.lua +++ b/neovim/.config/nvim/init.lua @@ -1,3 +1,7 @@ require("warrenhood.settings") require("warrenhood.keybinds") require("warrenhood.plugins") +require("warrenhood.plugins-config") +require("warrenhood.mason-config") +require("warrenhood.cmp-config") +require("warrenhood.theme") diff --git a/neovim/.config/nvim/lua/warrenhood/cmp-config.lua b/neovim/.config/nvim/lua/warrenhood/cmp-config.lua new file mode 100644 index 0000000..3989cfc --- /dev/null +++ b/neovim/.config/nvim/lua/warrenhood/cmp-config.lua @@ -0,0 +1,64 @@ +-- Setup 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. + end, + vim.lsp.buf.format, + }, + 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. + [""] = cmp.mapping(function() if cmp.visible() then cmp.select_next_item() end end), + [""] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item() end end), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, -- For vsnip users. + { name = "treesitter" }, + }, { + { name = "buffer" }, + }), +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { 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" }, + }, { + { name = "stylua" }, + }), +}) + diff --git a/neovim/.config/nvim/lua/warrenhood/keybinds.lua b/neovim/.config/nvim/lua/warrenhood/keybinds.lua index 9ceb6df..5c47419 100644 --- a/neovim/.config/nvim/lua/warrenhood/keybinds.lua +++ b/neovim/.config/nvim/lua/warrenhood/keybinds.lua @@ -11,4 +11,12 @@ map('i', '', ':wq') map('n', '', ':w') map('i', '', ':w') +-- Telescope +local telescope_builtin = require('telescope.builtin') +map('n', 'ff', telescope_builtin.find_files) +map('n', 'fg', telescope_builtin.live_grep) +map('n', 'fb', telescope_builtin.buffers) +map('n', 'fh', telescope_builtin.help_tags) +-- NvimTree Toggle (File Explorer) +map('n', '', ':NvimTreeToggle') diff --git a/neovim/.config/nvim/lua/warrenhood/mason-config.lua b/neovim/.config/nvim/lua/warrenhood/mason-config.lua new file mode 100644 index 0000000..6753819 --- /dev/null +++ b/neovim/.config/nvim/lua/warrenhood/mason-config.lua @@ -0,0 +1,42 @@ +-- Setup mason and language servers +require("mason").setup() + + +require("mason-lspconfig").setup({ + ensure_installed = { "sumneko_lua", "rust_analyzer", "pyright" } +}) + + +local lspconfig = require('lspconfig') +require("mason-lspconfig").setup_handlers({ + -- default handler + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, + -- Overrides + ["sumneko_lua"] = function() + lspconfig.sumneko_lua.setup { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { 'vim' }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, + } + end, +}) + diff --git a/neovim/.config/nvim/lua/warrenhood/plugins-config.lua b/neovim/.config/nvim/lua/warrenhood/plugins-config.lua new file mode 100644 index 0000000..f960101 --- /dev/null +++ b/neovim/.config/nvim/lua/warrenhood/plugins-config.lua @@ -0,0 +1,2 @@ +-- nvim-tree setup with defaults +require("nvim-tree").setup() diff --git a/neovim/.config/nvim/lua/warrenhood/plugins.lua b/neovim/.config/nvim/lua/warrenhood/plugins.lua index 060abfb..51405e3 100644 --- a/neovim/.config/nvim/lua/warrenhood/plugins.lua +++ b/neovim/.config/nvim/lua/warrenhood/plugins.lua @@ -17,11 +17,17 @@ local packer_bootstrap = ensure_packer() local use = require("packer").use require("packer").startup(function() - use("wbthomason/packer.nvim") -- Package manager + -- Packer package manager + use("wbthomason/packer.nvim") + + -- OneDark color scheme + use("navarasu/onedark.nvim") + + -- LSP Stuff use({ - "williamboman/mason.nvim", -- LSP Server manager etc + "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", -- Configurations for Nvim LSP + "neovim/nvim-lspconfig", }) -- Autocomplete @@ -33,10 +39,24 @@ require("packer").startup(function() use("hrsh7th/cmp-vsnip") use("hrsh7th/vim-vsnip") + -- Treesitter use("nvim-treesitter/nvim-treesitter") - -- Auto format - use("sbdchd/neoformat") + + -- Telescope + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.0', + requires = { { 'nvim-lua/plenary.nvim' } } + } + + -- nvim-tree (File Explorer) + use { + 'nvim-tree/nvim-tree.lua', + requires = { + 'nvim-tree/nvim-web-devicons', -- file icons + }, + tag = 'nightly' +} -- Automatically set up configuration after cloning packer.nvim if packer_bootstrap then @@ -44,88 +64,4 @@ require("packer").startup(function() end end) --- Setup mason -require("mason").setup() -require("mason-lspconfig").setup() - - - --- Setup 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. - end, - vim.lsp.buf.format, - }, - 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" }, - }), -}) - --- Set configuration for specific filetype. -cmp.setup.filetype("gitcommit", { - sources = cmp.config.sources({ - { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { 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" }, - }, { - { name = "stylua" }, - }), -}) - --- Set up lspconfig. -local capabilities = require("cmp_nvim_lsp").default_capabilities() --- Replace with each lsp server you've enabled. ---for lsp_server_name,v in pairs(require('lspconfig')) do --- require('lspconfig')[lsp_server_name].setup { --- capabilities = capabilities --- } --- end --- require('lspconfig')['stylua'].setup { --- capabilities = capabilities --- } diff --git a/neovim/.config/nvim/lua/warrenhood/settings.lua b/neovim/.config/nvim/lua/warrenhood/settings.lua index e3b7d7c..8ef5148 100644 --- a/neovim/.config/nvim/lua/warrenhood/settings.lua +++ b/neovim/.config/nvim/lua/warrenhood/settings.lua @@ -18,3 +18,13 @@ o.smartcase = true -- Enable mouse o.mouse = 'a' + +-- Enable termguicolors +o.termguicolors = true + +-- Use space for leader key +g.mapleader = " " + +-- Disable netrw +g.loaded_netrw = 1 +g.loaded_netrwPlugin = 1 diff --git a/neovim/.config/nvim/lua/warrenhood/theme.lua b/neovim/.config/nvim/lua/warrenhood/theme.lua new file mode 100644 index 0000000..91c19cd --- /dev/null +++ b/neovim/.config/nvim/lua/warrenhood/theme.lua @@ -0,0 +1,5 @@ +-- OneDark Darker theme +require('onedark').setup { + style = 'darker' +} +require('onedark').load()