Skip to content

Instantly share code, notes, and snippets.

@matthewbdaly
Last active January 31, 2024 16:34
Show Gist options
  • Save matthewbdaly/80b777ad3db885ebeecd27687fb121cd to your computer and use it in GitHub Desktop.
Save matthewbdaly/80b777ad3db885ebeecd27687fb121cd to your computer and use it in GitHub Desktop.
My NeoVim config
let g:polyglot_disabled = ['markdown']
call plug#begin()
" Project
Plug 'ahmedkhalf/project.nvim'
" Search
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
" LSP Completion
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
" Refactorings in PHP
Plug 'phpactor/phpactor', {'for': 'php', 'tag': '*', 'do': 'composer install --no-dev -o'}
" Tests
Plug 'vim-test/vim-test'
" Copilot
Plug 'github/copilot.vim'
" Snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'mlaursen/vim-react-snippets'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
" Git integration
Plug 'tpope/vim-fugitive'
Plug 'lewis6991/gitsigns.nvim'
" Comments
Plug 'numToStr/Comment.nvim'
" Terminal
Plug 'akinsho/toggleterm.nvim'
" Debugger
Plug 'mfussenegger/nvim-dap'
" Editorconfig
Plug 'editorconfig/editorconfig-vim'
" Feedback and linting
Plug 'jose-elias-alvarez/null-ls.nvim'
Plug 'folke/trouble.nvim'
" Syntax
Plug 'sheerun/vim-polyglot'
Plug 'matthewbdaly/vim-filetype-settings'
Plug 'matthewbdaly/vim-statamic-antlers'
" Status line
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Theme
Plug 'mhartington/oceanic-next'
Plug 'folke/lsp-colors.nvim'
" Which
Plug 'folke/which-key.nvim'
" Icons and tree
Plug 'ryanoasis/vim-devicons'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'preservim/nerdtree'
call plug#end()
" Theme
syntax enable
set background=dark
colorscheme OceanicNext
let g:airline_theme='oceanicnext'
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
set completeopt=menu,menuone,noselect
" General
set nu
filetype plugin indent on
set nocp
set ruler
set wildmenu
set wildignore=.svn,CVS,.git,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
set mouse-=a
set cursorline
" Tabs and spacing
set autoindent
set cindent
set tabstop=4
set expandtab
set shiftwidth=4
set smarttab
set foldmethod=manual
"Search
set hlsearch
set incsearch
set infercase
set smartcase
set diffopt +=iwhite
" Telescope key bindings
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
"Syntax highlighting in Markdown
au BufNewFile,BufReadPost *.md set filetype=markdown
let g:markdown_fenced_languages = ['bash=sh', 'css', 'django', 'javascript', 'js=javascript', 'json=javascript', 'perl', 'php', 'python', 'ruby', 'sass', 'xml', 'html', 'vim']
lua <<EOF
require('null-ls').setup({
sources = {
require('null-ls').builtins.formatting.stylua,
require('null-ls').builtins.formatting.eslint,
require('null-ls').builtins.formatting.phpcbf,
require('null-ls').builtins.formatting.phpcsfixer,
require('null-ls').builtins.diagnostics.luacheck,
require('null-ls').builtins.diagnostics.eslint,
require('null-ls').builtins.diagnostics.luacheck,
require('null-ls').builtins.diagnostics.php,
require('null-ls').builtins.diagnostics.phpcs.with({
command = "vendor/bin/phpcs",
requiredFiles = {"vendor/bin/phpcs"}
}),
require('null-ls').builtins.diagnostics.psalm.with({
command = "./vendor/bin/psalm",
requiredFiles = {"vendor/bin/psalm"}
}),
require('null-ls').builtins.diagnostics.eslint,
require('null-ls').builtins.diagnostics.stylelint,
require('null-ls').builtins.diagnostics.tsc,
},
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
local nvim_lsp = require('lspconfig')
nvim_lsp['tsserver'].setup {
capabilities = capabilities
}
nvim_lsp['tailwindcss'].setup {
capabilities = capabilities
}
nvim_lsp.intelephense.setup{
capabilities = capabilities
}
nvim_lsp.phpactor.setup{
capabilities = capabilities
}
require('Comment').setup()
require("trouble").setup {}
require("toggleterm").setup{}
require("which-key").setup {}
require("project_nvim").setup{}
require('gitsigns').setup()
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'ultisnips' },
}, {
{ name = 'buffer' },
}),
view = {
entries = "native"
}
})
-- 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 `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
},
view = {
entries = "custom"
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
view = {
entries = "custom"
}
})
local actions = require("telescope.actions")
local trouble = require("trouble.providers.telescope")
local telescope = require("telescope")
telescope.load_extension('projects')
telescope.setup {
defaults = {
mappings = {
i = { ["<c-t>"] = trouble.open_with_trouble },
n = { ["<c-t>"] = trouble.open_with_trouble },
},
},
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment