"""""""""""""""""""""""""""""""" " Download vim-plug """""""""""""""""""""""""""""""" if has('nvim') if ! filereadable(system('echo -n "$HOME/.config/nvim/autoload/plug.vim"')) silent !mkdir -p $HOME/.config/nvim/autoload/ silent !curl --silent "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > $HOME/.config/nvim/autoload/plug.vim autocmd VimEnter * PlugInstall endif endif """""""""""""""""""""""""""""""" " Default settings nvim """""""""""""""""""""""""""""""" let g:python3_host_prog = expand('/opt/homebrew/bin/python3.12') let g:loaded_python_provider = 0 let g:python_host_prog = '' set autoindent set expandtab set softtabstop=4 set shiftwidth=4 set tabstop=4 set nocompatible set noshowmode set noerrorbells set wrap set hidden set cmdheight=1 set encoding=utf-8 set undofile set scrolloff=8 set termguicolors set t_BE= au BufWritePre * let &bex = '@' . strftime("%F.%H:%M") filetype plugin indent on syntax on " Disable by default indent line " let g:indentLine_enabled = 0 " ansible let g:ansible_extra_keywords_highlight = 1 " line numbers set number set ruler set title " indent set backspace=indent,eol,start "set list listchars=nbsp:¬,tab:»·,trail:·,extends:> set list listchars=tab:\│\ ,trail:· let g:indentLine_char_list = ['│', '│', '│', '│'] " editing runtime! macros/matchit.vim " visual feedback set laststatus=2 set showmode set showcmd " off mouse set mouse-=a " disable pcspkr beep set visualbell set t_vb= " searching set smartcase set ic " cursor set guicursor= set guicursor+=a:blinkon0 let &t_SI = "\[6 q" let &t_SR = "\[6 q" let &t_EI = "\[6 q" """""""""""""""""""""""""""""""" " Plugins """""""""""""""""""""""""""""""" call plug#begin('~/.config/nvim/plugged') " Markdown Plug 'tpope/vim-markdown' " Live-preview Plug 'nmante/vim-latex-live-preview' " Goyo plugin for writing mutt mail Plug 'junegunn/goyo.vim' " Themes Plug 'gruvbox-community/gruvbox', { 'as': 'gruvbox'} Plug 'Mofiqul/dracula.nvim' " Fzf plugin Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf' " CSS Plug 'ap/vim-css-color' " Copilot Plug 'github/copilot.vim' " PyRight Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh' } " Ansible yaml Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' } Plug 'Yggdroot/indentLine' " Terraform Plug 'hashivim/vim-terraform' " GoLang Plug 'fatih/vim-go' " Multiple cursors Plug 'terryma/vim-multiple-cursors' " Enable gentoo-syntax in vim Plug 'gentoo/gentoo-syntax' Plug 'tpope/vim-commentary' Plug 'tpope/vim-surround' Plug 'junegunn/vim-easy-align' " Git tool Plug 'tpope/vim-fugitive' " Prettier Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' } " Debug Plug 'puremourning/vimspector' Plug 'mfussenegger/nvim-dap' " LSP Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'saadparwaiz1/cmp_luasnip' Plug 'L3MON4D3/LuaSnip' Plug 'sbdchd/neoformat' Plug 'hrsh7th/cmp-vsnip' Plug 'hrsh7th/vim-vsnip' Plug 'hrsh7th/vim-vsnip-integ' " Telescope Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' " Tree Plug 'nvim-tree/nvim-web-devicons' Plug 'nvim-tree/nvim-tree.lua' " SHFMT Plug 'z0mbix/vim-shfmt', { 'for': 'sh' } " Mikrotik Plug 'zainin/vim-mikrotik' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/nvim-treesitter-context' " Autopair Plug 'windwp/nvim-autopairs' call plug#end() " LUA lua<lua vim.lsp.buf.declaration()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ge', 'lua vim.diagnostic.setqflist()', opts) --vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) --vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) --vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) --vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) --vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) end -- LSP settings (for overriding per client) local handlers = { ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border}), ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border }), } -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { 'clangd', 'bashls', 'yamlls', 'ansiblels', 'gopls', 'solargraph', 'terraformls', 'tflint', 'marksman', 'rust_analyzer' } for _, lsp in pairs(servers) do require('lspconfig')[lsp].setup { on_attach = on_attach, handlers=handlers, capabilities = capabilities, flags = { debounce_text_changes = 150, } } end -- Handlers when you are in the insert mode you see the errors vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {update_in_insert = true}) -- Setup a yamlls plugin require'lspconfig'.yamlls.setup{ settings = { json = { schemas = { ["https://raw.githubusercontent.com/quantumblacklabs/kedro/develop/static/jsonschema/kedro-catalog-0.17.json"]= "conf/**/*catalog*", ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", ["https://github.com/ansible/schemas/blob/main/f/ansible.json"] = "*.yaml,*.yml" } }, yaml = { keyOrdering = false }, } } -- Setup GoLang require'lspconfig'.gopls.setup { cmd = {"gopls", "serve"}, filetypes = {"go", "gomod"}, on_attach = on_attach, handlers=handlers, capabilities = capabilities, settings = { gopls = { analyses = { unusedparams = true, }, staticcheck = true, linksInHover = false, codelenses = { generate = true, gc_details = true, regenerate_cgo = true, tidy = true, upgrade_depdendency = true, vendor = true, }, usePlaceholders = true, }, }, } -- Setup Python (ruff) require('lspconfig').ruff.setup({}) -- luasnip setup local luasnip = require 'luasnip' -- nvim-cmp setup local cmp = require 'cmp' cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }), sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'vsnip' }, { name = 'ultisnips' }, { name = 'snippy' }, { name = 'path' }, { name = 'buffer' } }, } cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) cmp.setup.cmdline('/', { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) require("nvim-tree").setup({ }) require'treesitter-context'.setup{} require("nvim-autopairs").setup {} require'lspconfig'.rust_analyzer.setup {} EOF " Added popout window to see diagnostic set updatetime=250 autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"}) " CoPilot imap