Skip to content

Instantly share code, notes, and snippets.

@Gottox
Created April 5, 2022 06:14
Show Gist options
  • Save Gottox/4fe77da00459fdae6470a90d7fcbca27 to your computer and use it in GitHub Desktop.
Save Gottox/4fe77da00459fdae6470a90d7fcbca27 to your computer and use it in GitHub Desktop.
call plug#begin('~/.config/nvim/plugged')
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 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'tibabit/vim-templates'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'sakhnik/nvim-gdb'
Plug 'RishabhRD/popfix'
Plug 'RishabhRD/nvim-lsputils'
Plug 'editorconfig/editorconfig-vim'
Plug 'simrat39/symbols-outline.nvim'
Plug 'github/copilot.vim'
call plug#end()
set completeopt=menu,menuone,noselect
set number
let g:airline_powerline_fonts=1
let g:airline_theme='minimalist'
hi CursorLine cterm=NONE ctermbg=234
hi CursorColumn cterm=NONE ctermbg=235
hi ErrorMsg cterm=NONE ctermbg=16
hi Error ctermbg=DarkRed ctermfg=white
hi FocusedSymbol ctermbg=gray
" mark column 81
highlight ColorColumn ctermbg=DarkRed
call matchadd('ColorColumn', '\%81v', 100)
set cursorline
" mark column for yaml and python
autocmd Filetype yaml set cursorcolumn
autocmd Filetype python set cursorcolumn
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" By default use small tabs
set ts=2 sts=2 noet
set shiftwidth=2
set list listchars=tab:¸\ ,trail:·
let g:indentLine_char = '⦙'
"set mouse=a
let g:tmpl_search_paths = ['~/.config/nvim/templates']
let g:tmpl_author_name = 'Enno Boland'
let g:tmpl_author_email = 'mail@eboland.de'
vnoremap <CR> :'<,'>!sh -c "$(head -n1)"<CR>
nnoremap <silent> <C-l> :nohl<CR><C-l>
nnoremap <silent> <space>o :SymbolsOutline<CR>
imap <silent><script><expr> <A-a> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
lua << EOF
vim.lsp.set_log_level("debug")
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
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.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
-- require'snippy'.expand_snippet(args.body) -- For `snippy` users.
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(),
}),
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
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' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- 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' }
})
})
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
buf_set_keymap('n', '=f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require'lspconfig'.rust_analyzer.setup{
on_attach = on_attach,
capabilities = capabilities
}
require'lspconfig'.clangd.setup{
on_attach = on_attach,
capabilities = capabilities,
--cmd = { "clangd", "--background-index", "--clang-tidy", "--compile-commands-dir=build_dir" }
cmd = { "clangd", "--compile-commands-dir=.", "--query-driver=/home/tox/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++" }
}
--require'lspconfig'.ccls.setup{
-- on_attach = on_attach,
-- capabilities = capabilities,
-- cmd = { "ccls", "--log-file=/tmp/ccls.log", "-v=2" }
--}
require'lspconfig'.tsserver.setup{
on_attach = on_attach,
capabilities = capabilities,
}
require'lspconfig'.bashls.setup{}
vim.g.symbols_outline = {
highlight_hovered_item = true,
show_guides = true,
auto_preview = true,
position = 'right',
relative_width = true,
width = 50,
auto_close = true,
show_numbers = false,
show_relative_numbers = false,
show_symbol_details = true,
preview_bg_highlight = 'Pmenu',
keymaps = { -- These keymaps can be a string or a table for multiple keys
close = {"<Esc>", "q"},
goto_location = "<Cr>",
focus_location = "o",
hover_symbol = "<C-space>",
toggle_preview = "K",
rename_symbol = "r",
code_actions = "a",
},
lsp_blacklist = {},
symbol_blacklist = {},
symbols = {
File = {icon = "", hl = "TSURI"},
Module = {icon = "", hl = "TSNamespace"},
Namespace = {icon = "", hl = "TSNamespace"},
Package = {icon = "", hl = "TSNamespace"},
Class = {icon = "𝓒", hl = "TSType"},
Method = {icon = "ƒ", hl = "TSMethod"},
Property = {icon = "", hl = "TSMethod"},
Field = {icon = "", hl = "TSField"},
Constructor = {icon = "", hl = "TSConstructor"},
Enum = {icon = "ℰ", hl = "TSType"},
Interface = {icon = "ﰮ", hl = "TSType"},
Function = {icon = "", hl = "TSFunction"},
Variable = {icon = "", hl = "TSConstant"},
Constant = {icon = "", hl = "TSConstant"},
String = {icon = "𝓐", hl = "TSString"},
Number = {icon = "#", hl = "TSNumber"},
Boolean = {icon = "⊨", hl = "TSBoolean"},
Array = {icon = "", hl = "TSConstant"},
Object = {icon = "⦿", hl = "TSType"},
Key = {icon = "🔐", hl = "TSType"},
Null = {icon = "NULL", hl = "TSType"},
EnumMember = {icon = "", hl = "TSField"},
Struct = {icon = "𝓢", hl = "TSType"},
Event = {icon = "🗲", hl = "TSType"},
Operator = {icon = "+", hl = "TSOperator"},
TypeParameter = {icon = "𝙏", hl = "TSParameter"}
}
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment