summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/plugins.lua')
-rwxr-xr-x.config/nvim/lua/plugins.lua198
1 files changed, 198 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua
new file mode 100755
index 0000000..9655992
--- /dev/null
+++ b/.config/nvim/lua/plugins.lua
@@ -0,0 +1,198 @@
+local ensure_packer = function()
+ local fn = vim.fn
+ local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
+ if fn.empty(fn.glob(install_path)) > 0 then
+ fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
+ vim.cmd [[packadd packer.nvim]]
+ return true
+ end
+ return false
+end
+
+local packer_bootstrap = ensure_packer()
+
+return require('packer').startup(function(use)
+ use 'wbthomason/packer.nvim'
+
+ use {
+ 'rose-pine/neovim',
+ as = 'rose-pine',
+ config = function()
+ vim.cmd('colorscheme rose-pine')
+ end
+ }
+
+ use {
+ "SmiteshP/nvim-navic",
+ requires = "neovim/nvim-lspconfig"
+ }
+
+ use {
+ "folke/which-key.nvim",
+ config = function()
+ require("which-key").setup {
+ -- your configuration comes here
+ -- or leave it empty to use the default settings
+ -- refer to the configuration section below
+ }
+ end
+ }
+
+ use {
+ 'neovim/nvim-lspconfig',
+ config = function()
+ local lspconfig = require('lspconfig')
+ local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
+ local cache = os.getenv("XDG_RUNTIME_DIR") or "/tmp/"
+
+ local on_attach = function(client, bufnr)
+ vim.api.nvim_exec_autocmds('User', {pattern = 'LspAttached'})
+ require('nvim-navic').attach(client, bufnr)
+ end
+
+ lspconfig.ccls.setup {
+ on_attach = on_attach,
+ capabilities = capabilities,
+ single_file_support = true,
+ init_options = {
+ cache = {
+ directory = cache .. "/ccls"
+ }
+ }
+ }
+
+ lspconfig.phpactor.setup {
+ on_attach = on_attach,
+ capabilities = capabilities
+ }
+
+ lspconfig.bashls.setup {
+ on_attach = on_attach,
+ capabilities = capabilities
+ }
+
+ lspconfig.rust_analyzer.setup {
+ on_attach = on_attach,
+ capabilities = capabilities
+ }
+
+ lspconfig.lua_ls.setup {
+ on_attach = on_attach,
+ capabilities = capabilities,
+ settings = {
+ Lua = {
+ runtime = {
+ version = 'LuaJIT',
+ },
+
+ diagnostics = {
+ globals = {'vim'},
+ },
+
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+
+ telemetry = {
+ enable = false,
+ }
+ }
+ }
+ }
+ end
+ }
+
+ use {
+ 'nvim-treesitter/nvim-treesitter',
+ run = ':TSUpdate',
+ config = function()
+ require'nvim-treesitter.configs'.setup {
+ ensure_installed = { "c", "cpp", "php", "lua" },
+ sync_install = false,
+ auto_install = true,
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ }
+ }
+ end
+ }
+
+ use {
+ 'hrsh7th/nvim-cmp',
+ requires = {
+ 'hrsh7th/cmp-nvim-lsp',
+ 'hrsh7th/cmp-vsnip',
+ 'hrsh7th/vim-vsnip',
+ 'hrsh7th/cmp-nvim-lsp-signature-help',
+ 'hrsh7th/cmp-nvim-lsp-document-symbol',
+ },
+ config = function()
+ -- Setup nvim-cmp.
+ local cmp = require'cmp'
+ local has_words_before = function()
+ local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
+ end
+
+ local feedkey = function(key, mode)
+ vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
+ end
+
+ 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,
+ },
+ window = {
+ completion = cmp.config.window.bordered(),
+ documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
+ ['<Tab>'] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif vim.fn["vsnip#available"](1) == 1 then
+ feedkey("<Plug>(vsnip-expand-or-jump)", "")
+ elseif has_words_before() then
+ cmp.complete()
+ else
+ fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
+ end
+ end, { "i", "s" }),
+ ['<S-Tab>'] = cmp.mapping(function()
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif vim.fn["vsnip#jumpable"](-1) == 1 then
+ feedkey("<Plug>(vsnip-jump-prev)", "")
+ end
+ end, { "i", "s" }),
+ }),
+ 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 = 'nvim_lsp_signature_help' }
+ }, {
+ { name = 'buffer' },
+ })
+ })
+ end
+ }
+
+ if packer_bootstrap then
+ require('packer').sync()
+ end
+end)