commit 1994ce652efe465dfd1cf6221b53014a307d4173 Author: george Date: Mon Nov 20 14:38:30 2023 +0000 init diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..fd0831e --- /dev/null +++ b/init.vim @@ -0,0 +1,78 @@ +set noerrorbells +set history=500 +set autoread +set ruler +set number +set expandtab +set smarttab +set smartindent +set nowrap +set smartcase +set noswapfile +set nobackup +set undodir=~/.nvim/undodir +set undofile +set incsearch +set shiftwidth=4 +set tabstop=4 softtabstop=4 +set encoding=utf-8 +set fileencoding=utf-8 +set relativenumber +set scrolloff=8 +set hidden +set signcolumn=yes +set colorcolumn=110 + +autocmd BufWritePost *.tex !echo | pdflatex % >/dev/null + +call plug#begin("~/.nvim/plugged") +Plug 'rust-lang/rust.vim' +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} +Plug 'neovim/nvim-lspconfig' +Plug 'mbbill/undotree' +Plug 'sbdchd/neoformat' +Plug 'gruvbox-community/gruvbox' +Plug 'folke/tokyonight.nvim', { 'branch': 'main' } +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' +Plug 'nvim-telescope/telescope-fzy-native.nvim' +Plug 'psliwka/vim-smoothie' +Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } +"Plug 'fatih/vim-go' +Plug 'preservim/nerdtree' +Plug 'udalov/kotlin-vim' + +Plug 'hrsh7th/cmp-nvim-lsp' +Plug 'hrsh7th/cmp-buffer' +Plug 'hrsh7th/nvim-cmp' +Plug 'L3MON4D3/LuaSnip' +Plug 'EdenEast/nightfox.nvim' +Plug 'itchyny/lightline.vim' +"EEEEEEEEEEEEEEEEEEEEEEEEEEEee +Plug 'ThePrimeagen/vim-be-good' +Plug 'tpope/vim-fugitive' +Plug 'simrat39/rust-tools.nvim' + +call plug#end() + +"colorscheme gruvbox +colorscheme tokyonight + +let mapleader = " " + +nnoremap :lua require ('telescope.builtin').git_files() +nnoremap :lua require ('telescope.builtin').find_files() +nnoremap f :lua require('telescope.builtin').live_grep() +nnoremap :lua require('telescope.builtin').buffers() +"nnoremap :b +nnoremap y "+y + +lua require("init") + +nnoremap gd :lua vim.lsp.buf.definition() +nnoremap K :lua vim.lsp.buf.hover() +nnoremap L :lua vim.diagnostic.open_float() + +"autocmd BufWritePost *.go GoImports + +nnoremap :NERDTreeToggle diff --git a/lua/init.lua b/lua/init.lua new file mode 100644 index 0000000..d5dc379 --- /dev/null +++ b/lua/init.lua @@ -0,0 +1,94 @@ +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({ + [''] = 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' }, + }) + }) + +local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) + +require("lspconfig").tsserver.setup({}) + +require("lspconfig").clangd.setup({}) +require("lspconfig").gopls.setup({ + cmd = { "gopls", "serve" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, +}) + +require("lspconfig").rust_analyzer.setup({ + --cmd = { "rustup", "run", "nightly", "rust-analyzer" }, + settings = { + ['rust-analyzer'] = { + checkOnSave = { + allFeatures = true, + + overrideCommand = { + 'cargo', 'clippy', '--workspace', '--message-format=json', + '--all-targets', '--all-features' + } + } + } + } +}) + + +require('lspconfig').kotlin_language_server.setup({ + cmd = { "kotlin-language-server" }, + filetypes = { "kotlin"} , +}) + +require'nvim-treesitter.configs'.setup { + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + update_in_insert = true, + } + ) +