diff --git a/config/nvim/init.vim b/config/nvim/init.vim index 4f625a1..978e960 100644 --- a/config/nvim/init.vim +++ b/config/nvim/init.vim @@ -1,36 +1,17 @@ -" Load plugins -call plug#begin() +" Main configuration +set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab autoindent +set mouse= +set laststatus=2 +set t_Co=256 -" CodeStats and Airline -Plug 'https://gitlab.com/code-stats/code-stats-vim.git' -Plug 'vim-airline/vim-airline' +" stop overriding terminal bg colour +highlight Normal guibg=none +highlight NonText guibg=none +highlight Normal ctermbg=none +highlight NonText ctermbg=none -" Syntax highlighters -Plug 'tikhomirov/vim-glsl' - -" Treesitter things -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} - -" Language server protocol -Plug 'neovim/nvim-lspconfig' - -" Autocompletion shenanigans -Plug 'hrsh7th/cmp-nvim-lsp' -Plug 'hrsh7th/cmp-buffer' -Plug 'hrsh7th/cmp-path' -Plug 'hrsh7th/cmp-cmdline' -Plug 'hrsh7th/nvim-cmp' -Plug 'hrsh7th/cmp-vsnip' -Plug 'hrsh7th/vim-vsnip' -Plug 'petertriho/cmp-git' - -call plug#end() - -" Key remap for resizing split windows -nnoremap -nnoremap -nnoremap -nnoremap +source $HOME/.config/nvim/plugins.vim +source $HOME/.config/nvim/keymaps.vim " Set custom glsl extensions autocmd! BufNewFile,BufRead *.effect set ft=glsl @@ -41,106 +22,9 @@ let g:python3_host_prog = '/usr/bin/python' " CodeStats let g:codestats_api_key = $CODESTATS_API_KEY -" Main configuration -set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab autoindent -set mouse= -set laststatus=2 -set t_Co=256 - -lua <'] = 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 = 'vsnip' }, - { name = 'buffer' }, - }) - }) - - -- filetype specific setup - -- gitconfig - cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'git' }, - { name = 'buffer' }, - }) - }) - - -- / andd ? completion - cmp.setup.cmdline({'/', '?'}, { - mapping = cmp.mapping.preset.cmdline(), - sources = { { name = 'buffer' } }, - }) - - -- : completion - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'path' }, - { name = 'cmdline' }, - }, - matching = { disallow_symbol_nonprefix_matching = false }, - }) - - -- Elixir LSP configuration - local capabilities = require('cmp_nvim_lsp').default_capabilities() - require'lspconfig'.elixirls.setup { - capabilities = capabilities, - cmd = { '~/.local/share/lsp-servers/elixir-ls/language_server.sh' } - } -EOF +lua require('treesitter') +lua require('autocomplete') +lua require('lsp') " disable dfraw for text files if did_filetype() diff --git a/config/nvim/keymaps.vim b/config/nvim/keymaps.vim new file mode 100644 index 0000000..4df424a --- /dev/null +++ b/config/nvim/keymaps.vim @@ -0,0 +1,5 @@ +" Key remap for resizing split windows +nnoremap +nnoremap +nnoremap +nnoremap \ No newline at end of file diff --git a/config/nvim/lua/autocomplete.lua b/config/nvim/lua/autocomplete.lua new file mode 100644 index 0000000..1a43db3 --- /dev/null +++ b/config/nvim/lua/autocomplete.lua @@ -0,0 +1,51 @@ +-- Autocompletion shenanigans +local cmp = require'cmp' + +cmp.setup({ +snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](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 = 'vsnip' }, + { name = 'buffer' }, + }) +}) + +-- filetype specific setup +-- gitconfig +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, + { name = 'buffer' }, + }) +}) + +-- / andd ? completion +cmp.setup.cmdline({'/', '?'}, { + mapping = cmp.mapping.preset.cmdline(), + sources = { { name = 'buffer' } }, +}) + +-- : completion +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'path' }, + { name = 'cmdline' }, + }, + matching = { disallow_symbol_nonprefix_matching = false }, +}) diff --git a/config/nvim/lua/lsp.lua b/config/nvim/lua/lsp.lua new file mode 100644 index 0000000..a71730a --- /dev/null +++ b/config/nvim/lua/lsp.lua @@ -0,0 +1,16 @@ +-- Elixir shenanigans +local lspdir = '~/.local/share/lsp-servers' +local capabilities = require('cmp_nvim_lsp').default_capabilities() +require'lspconfig'.elixirls.setup { +capabilities = capabilities, + capabilities = { lspdir .. '/elixir-ls/language_server.sh' } +} + +local elixir = require('elixir') +local elixirls = require('elixir.elixirls') + +elixir.setup { + elixirls = { + cmd = lspdir .. '/elixir-ls/language_server.sh' + } +} diff --git a/config/nvim/lua/treesitter.lua b/config/nvim/lua/treesitter.lua new file mode 100644 index 0000000..33aa79b --- /dev/null +++ b/config/nvim/lua/treesitter.lua @@ -0,0 +1,34 @@ +require'nvim-treesitter.configs'.setup { +ensure_installed = { + "bash", "vim", "regex", + "cpp", "go", "rust", + "diff", "make", + "dockerfile", + "elixir", "erlang", + "godot_resource", "gdscript", + "git_rebase", "gitattributes", "gitcommit", "gitignore", + "html", "scss", + "http", "sql", + "javascript", "jsdoc", "typescript", "vue", + "json", "json5", "jq", + "lua", "php", "phpdoc", + "markdown", "markdown_inline", + "rst", "yaml" + }, + highlight = { + enable = true, + } +} + +-- Parser config for dfraw language +local parser_config = require'nvim-treesitter.parsers'.get_parser_configs() +parser_config.dfraw = { + install_info = { + url = 'https://code.criminallycute.fi/mirrors/tree-sitter-dfraw', + files = {'src/parser.c'}, + branch = 'main', + }, + filetype = 'text', + used_by = {'dfraw'}, +} + diff --git a/config/nvim/plugins.vim b/config/nvim/plugins.vim new file mode 100644 index 0000000..fa1902b --- /dev/null +++ b/config/nvim/plugins.vim @@ -0,0 +1,30 @@ +" Load plugins +call plug#begin() + +" CodeStats and Airline +Plug 'https://gitlab.com/code-stats/code-stats-vim.git' +Plug 'vim-airline/vim-airline' + +" Syntax highlighters +Plug 'tikhomirov/vim-glsl' + +" Treesitter things +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +" Language server protocol +Plug 'neovim/nvim-lspconfig' + +" Autocompletion shenanigans +Plug 'hrsh7th/cmp-nvim-lsp' +Plug 'hrsh7th/cmp-buffer' +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-cmdline' +Plug 'hrsh7th/nvim-cmp' +Plug 'hrsh7th/cmp-vsnip' +Plug 'hrsh7th/vim-vsnip' +Plug 'petertriho/cmp-git' + +Plug 'elixir-tools/elixir-tools.nvim', {'tag': 'stable'} +Plug 'nvim-lua/plenary.nvim' + +call plug#end()