diff options
Diffstat (limited to 'applications/nvim/init.vim')
-rw-r--r-- | applications/nvim/init.vim | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/applications/nvim/init.vim b/applications/nvim/init.vim new file mode 100644 index 0000000..b01c428 --- /dev/null +++ b/applications/nvim/init.vim @@ -0,0 +1,161 @@ +set nu +set shiftwidth=4 +syntax on + +call plug#begin() +Plug 'deoplete-plugins/deoplete-clang' +Plug 'dense-analysis/ale' +Plug 'rust-lang/rust.vim' +Plug 'neovim/nvim-lspconfig' +Plug 'hrsh7th/cmp-nvim-lsp' +Plug 'hrsh7th/cmp-buffer' +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-cmdline' +Plug 'hrsh7th/nvim-cmp' +Plug 'dcampos/nvim-snippy' +Plug 'dcampos/cmp-snippy' +Plug 'folke/tokyonight.nvim' +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} +Plug 'CRAG666/code_runner.nvim' +Plug 'CRAG666/betterTerm.nvim' +call plug#end() +set completeopt=menu,menuone,preview,noselect,noinsert +let g:ale_completion_enabled = 1 +let g:neoformat_cpp_clangformat = { + \ 'exe': 'clang-format', + \ 'args': ['--style="{IndentWidth: 4}"'] +\} +let g:neoformat_enabled_cpp = ['clangformat'] +let g:neoformat_enabled_c = ['clangformat'] +colorscheme tokyonight-night +" colorscheme ~/.config/alacritty/themes/themes/blood_moon.toml +lua <<EOF + -- Set up 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, + }, + 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 = 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 = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { 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' } + }) + }) + + -- Set up lspconfig. + local capabilities = require('cmp_nvim_lsp').default_capabilities() + -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled. + require('lspconfig')['clangd'].setup { + capabilities = capabilities + } + +require'nvim-treesitter.configs'.setup { + ensure_installed = {"java", "javascript"}, + highlight= { + enable = true, + additional_vim_regex_highlighting = { 'java', 'javascript' } + } + } +--require('betterTerm').setup() +require('code_runner').setup({ + filetype = { + java = { + "cd $dir &&", + "javac $fileName &&", + "java $fileNameWithoutExt" + }, + python = "python3 -u", + rust = { + "cd $dir &&", + "rustc $fileName &&", + "$dir/$fileNameWithoutExt" + }, + c = function(...) + c_base = { + "cd $dir &&", + "gcc $fileName -o", + "/tmp/$fileNameWithoutExt", + } + local c_exec = { + "&& /tmp/$fileNameWithoutExt &&", + "rm /tmp/$fileNameWithoutExt", + } + vim.ui.input({ prompt = "Add more args:" }, function(input) + c_base[4] = input + vim.print(vim.tbl_extend("force", c_base, c_exec)) + require("code_runner.commands").run_from_fn(vim.list_extend(c_base, c_exec)) + end) + end, + }, +}) +local betterTerm = require('betterTerm') +require('betterTerm').setup({ + startInserted = false, + position = "bot", + size = 10 + }); +vim.keymap.set({"n", "t"}, "<C-;>", betterTerm.open, { desc = "Open terminal"}) +-- Create new term +-- local betterTerm = require('betterTerm') +-- -- toggle firts term +-- vim.keymap.set({"n", "t"}, "<C-;>", betterTerm.open, { desc = "Open terminal"})-- Create new term +-- local current = 2 +-- vim.keymap.set( +-- {"n"}, "<leader>tn", +-- function() +-- betterTerm.open(current) +-- current = current + 1 +-- end, +-- { desc = "New terminal"} +-- ) +EOF |