Skip to content

Commit

Permalink
Latest neovim; faster clang-format; clean up gdbinit
Browse files Browse the repository at this point in the history
nvim-diagnostics plugin is now deprecated: nvim-lua/diagnostic-nvim#73
  • Loading branch information
jubnzv committed Nov 17, 2020
1 parent 9d854ae commit 8586de8
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 2,332 deletions.
3 changes: 2 additions & 1 deletion .Xdefaults
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Xft.rgba: rgb
! Fix font spacing
URxvt.letterSpace: -1

Xcursor.theme: Breeze
Xcursor.size: 16
! }}}1

Expand Down Expand Up @@ -117,3 +116,5 @@ URxvt.color248: #bdae93
URxvt.color250: #d5c4a1

! vim: foldmethod=marker sw=4

Xcursor.theme: breeze_cursors
34 changes: 34 additions & 0 deletions .config/nvim/UltiSnips/cpp.snippets
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
snippet hdr
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;

$1
endsnippet

snippet exectime
{
auto start__ = std::chrono::high_resolution_clock::now();
Expand All @@ -21,6 +37,24 @@ for (auto const &vv : ${1:v})
std::cout << std::endl;
endsnippet

snippet prm
for (auto const &m : ${1:M})
std::cout << m.first << ":" << m.second << "${2:\n}";
std::cout << std::endl;
endsnippet

snippet qpr
qDebug() << $1;
endsnippet

snippet qprd
qDebug() << __LINE__ << $1; // prdbg
endsnippet

snippet spr
spdlog::debug("${2:\{\}}", $1);
endsnippet

snippet inc
#include <${1:iostream}>
endsnippet
47 changes: 12 additions & 35 deletions .config/nvim/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Plug 'rust-lang/rust.vim' " Rust support
" Native neovim LSP client
if has('nvim-0.5')
Plug 'neovim/nvim-lspconfig'
Plug 'haorenW1025/diagnostic-nvim' " A wrapper for neovim built in LSP diagnosis config
endif
Plug 'sbdchd/neoformat' " Integration with code formatters
Plug 'jubnzv/DoxygenToolkit.vim' " Doxygen utilities
Expand All @@ -71,7 +70,6 @@ Plug 'jpalardy/vim-slime' " REPL integraion
Plug 'bfrg/vim-cpp-modern' " Extended Vim syntax highlighting for C and C++ (C++11/14/17/20)
Plug 'peterhoeg/vim-qml' " QML syntax highlighting
Plug 'derekwyatt/vim-fswitch' " This Vim plugin will help switching between companion files
Plug 'rhysd/vim-clang-format' " Vim plugin for clang-format
Plug 'vim-python/python-syntax' " Extended python syntax
Plug 'luochen1990/rainbow' " Rainbow Parentheses improved
Plug 'pearofducks/ansible-vim' " Ansible configuration files
Expand Down Expand Up @@ -233,6 +231,10 @@ nnoremap <leader>w :w<CR>
" Y yanks from the cursor to the end of line as expected. See :help Y.
nnoremap Y y$
" Replace-paste without yanking deleted lines
nnoremap <leader>y "0y
nnoremap <leader>p "0p
" Insert newline without entering insert mode
" nmap zj o<Esc>k
" nmap zk O<Esc>j
Expand Down Expand Up @@ -559,6 +561,7 @@ function! s:JbzOpenSlimeREPL(repl_exe, ...)

call system("tmux split-window -h \"" . cmd . "\"")
call system("tmux last-pane")
echoerr "cmd=" . cmd
call s:JbzSlimeRight()
endfunction
command! -nargs=+ JbzOpenSlimeREPL call s:JbzOpenSlimeREPL(<f-args>)
Expand Down Expand Up @@ -923,23 +926,6 @@ let g:neoformat_enabled_lua = ['luaformatter']
" let g:neoformat_enabled_ocaml = ['ocamlformat']
" }}}

" {{{ LSP-client
" Auxiliary configuration for haorenW1025/diagnostic-nvim
let g:diagnostic_enable_virtual_text = 0
call sign_define("LspDiagnosticsErrorSign", {"text" : "E", "texthl" : "LspDiagnosticsError"})
call sign_define("LspDiagnosticsWarningSign", {"text" : "W", "texthl" : "LspDiagnosticsWarning"})
call sign_define("LspDiagnosticInformationSign", {"text" : "I", "texthl" : "LspDiagnosticsInformation"})
call sign_define("LspDiagnosticHintSign", {"text" : "H", "texthl" : "LspDiagnosticsHint"})
" Neovim's built-in LSP support will keep sending diagnostic messages when you're in insert mode.
let g:diagnostic_insert_delay = 1
let g:diagnostic_enable_underline = 1

function! LSPKeymap()
nnoremap <buffer>]e :NextDiagnosticCycle<CR>
nnoremap <buffer>[e :PrevDiagnosticCycle<CR>
endfunction
" }}}

" {{{ EditorConfig
let g:EditorConfig_exclude_patterns = ['fugitive://.\*', 'scp://.\*']
" }}}
Expand Down Expand Up @@ -1007,20 +993,13 @@ let g:table_mode_delete_column_map = ',tdc'
let g:clang_include_fixer_path = "clang-include-fixer-8"
let g:clang_rename_path = "clang-rename-8"

" {{{ Custom :ClangFormat with aware of my debug prints
function! s:JbzClangFormat()
let save_cursor = getcurpos()

if search("prdbg")
echo "Remove debug prints before running clang-format"
else
:ClangFormat
endif

call setpos('.', save_cursor)
" {{{ Clang-format function
function! s:JbzClangFormat(first, last)
let l:winview = winsaveview()
execute a:first . "," . a:last . "!clang-format"
call winrestview(l:winview)
endfunction

command! -range=% -nargs=0 JbzClangFormat call s:JbzClangFormat()
command! -range=% JbzClangFormat call <sid>JbzClangFormat (<line1>, <line2>)
" }}}

" {{{ Function to remove my debug prints
Expand All @@ -1041,14 +1020,12 @@ augroup c_cxx_group
au FileType c,cpp nnoremap <buffer><leader>rd :JbzRemoveDebugPrints<CR>
" Autoformatting with clang-format
au FileType c,cpp nnoremap <buffer><leader>lf :<C-u>JbzClangFormat<CR>
au FileType c,cpp vnoremap <buffer><leader>lf :JbzMyClangFormat<CR>
au FileType c,cpp nnoremap <leader>tf :ClangFormatAutoToggle<CR>
au FileType c,cpp vnoremap <buffer><leader>lf :JbzClangFormat<CR>
" Align statements relative to case label
au FileType c,cpp setlocal cinoptions+=l1
" Include fixer
au FileType c,cpp nnoremap <buffer><leader>l# :pyf /usr/lib/llvm-8/share/clang/clang-include-fixer.py<cr>
" Set LSP keybindings
au FileType c,cpp call LSPKeymap()
au FileType c,cpp RainbowToggleOn
au BufEnter *.h let b:fswitchdst = "c,cpp,cc,m"
au BufEnter *.cc let b:fswitchdst = "h,hpp"
Expand Down
44 changes: 20 additions & 24 deletions .config/nvim/lua/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
local api = vim.api
local lsp = require "nvim_lsp"
local lsp_configs = require "nvim_lsp/configs"
local diagnostic = require "diagnostic"
local lsp = require "lspconfig"
local virtualtypes = require "virtualtypes"

local M = {}

-- F# configuration
lsp_configs.fsharp = {
default_config = {
cmd = {"/home/jubnzv/Sources/fsharp-language-server/src/FSharpLanguageServer/bin/Release/netcoreapp3.0/FSharpLanguageServer"};
filetypes = {"fsharp"};
root_dir = lsp.util.root_pattern("*.fsproj", ".git");
};
}

function M.setup()
lsp.clangd.setup {
on_attach=diagnostic.on_attach,
cmd = { "clangd-11", "--background-index" }
}
lsp.pyls.setup { on_attach=diagnostic.on_attach }
lsp.gopls.setup { on_attach=diagnostic.on_attach }
lsp.rls.setup { on_attach=diagnostic.on_attach }
lsp.fsharp.setup { on_attach=diagnostic.on_attach }
lsp.ocamllsp.setup {
on_attach=(function()
diagnostic.on_attach()
virtualtypes.on_attach()
end)
}
lsp.pyls.setup { }
-- lsp.gopls.setup { }
lsp.rls.setup { }
lsp.ocamllsp.setup { on_attach=virtualtypes.on_attach }

vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Enable underline, use default values
underline = true,
-- Disable virtual text
virtual_text=false,
-- Don't update while in insert mode
update_in_insert = false,
}
)

vim.api.nvim_exec([[
nnoremap <silent> gl <cmd>lua vim.lsp.buf.declaration()<CR>
Expand All @@ -42,7 +35,10 @@ function M.setup()
nnoremap <silent> <localleader>a <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <silent> <localleader>r <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent> <localleader>d <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>
nnoremap <buffer>]e <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
nnoremap <buffer>[e <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
nnoremap <silent> <localleader>d <cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>
]], '')
end

Expand Down
Loading

0 comments on commit 8586de8

Please sign in to comment.