diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-11-18 20:32:42 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-11-18 20:32:42 +0100 |
commit | ec53f123399c933f02c9d2a477e15915b7025d62 (patch) | |
tree | b2f8b27e48975ebe5a2549bd7a69999fbd63eded | |
parent | 401a8ab1715e286f9300e67a81785b490915f065 (diff) |
nvim: trouble and null ls
-rw-r--r-- | nvim/init.vim | 52 | ||||
-rw-r--r-- | nvim/lua/feline_style.lua | 16 | ||||
-rw-r--r-- | nvim/lua/git.lua | 4 | ||||
-rw-r--r-- | nvim/lua/lsp_conf.lua | 50 |
4 files changed, 67 insertions, 55 deletions
diff --git a/nvim/init.vim b/nvim/init.vim index 486ada1..d2ce209 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -2,13 +2,12 @@ autocmd! bufwritepost .vimrc source % call plug#begin('~/.vim/plugged') Plug 'cespare/vim-toml', { 'branch': 'main' } -Plug 'rust-lang/rust.vim' +"Plug 'rust-lang/rust.vim' Plug 'nvim-lua/plenary.nvim' Plug 'lewis6991/gitsigns.nvim' Plug 'famiu/feline.nvim' Plug 'kyazdani42/nvim-web-devicons' Plug 'luochen1990/rainbow' " color parentheses -Plug 'dense-analysis/ale' " checker syntax Plug 'terryma/vim-multiple-cursors' Plug 'tpope/vim-fugitive' " git extension for commit logs and etc. Plug 'editorconfig/editorconfig-vim' @@ -33,6 +32,13 @@ if has('nvim') Plug 'saecki/crates.nvim' Plug 'gelguy/wilder.nvim', { 'do': ':UpdateRemotePlugins' } Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + + Plug 'jose-elias-alvarez/null-ls.nvim' + Plug 'folke/trouble.nvim' + Plug 'folke/lsp-colors.nvim' + + Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' } + Plug 'ray-x/navigator.lua' endif @@ -88,38 +94,10 @@ set ttyfast set noswapfile " rust -let g:rustfmt_autosave = 1 -let g:rustfmt_emit_files = 1 -let g:rustfmt_fail_silently = 0 -let g:rust_clip_command = 'xclip -selection clipboard' - -let g:ale_disable_lsp = 1 -let g:ale_fix_on_save = 1 -let g:ale_sign_error = '🛑' -let g:ale_sign_warning = '⚠️' -let g:ale_sign_info = '💭' -let g:ale_echo_msg_error_str = 'E' -let g:ale_echo_msg_warning_str = 'W' -let g:ale_echo_msg_format = '[%severity%] [%linter%] %s' -let g:ale_open_list = 1 -let g:ale_keep_list_window_open = 0 -let g:ale_list_window_size = 3 - -let b:ale_linters = { -\ 'python': ['flake8', 'pylint', 'mypy'], -\ 'cpp': ['clang'], -\ 'c': ['clang'], -\} - -let b:ale_fixers = { -\ 'python': ['black', 'isort'], -\ 'javascript': ['prettier'], -\ 'typescript': ['prettier'], -\ 'vue': ['prettier'], -\ 'cpp': ['clang-format'], -\ 'c': ['clang-format'], -\} - +" let g:rustfmt_autosave = 1 +" let g:rustfmt_emit_files = 1 +" let g:rustfmt_fail_silently = 0 +" let g:rust_clip_command = 'xclip -selection clipboard' if has('nvim') set termguicolors @@ -147,6 +125,11 @@ if has('nvim') \ ], \ }))) lua require('nvim-treesitter.configs').setup({ highlight = { enable = true, }, }) + + lua require("lsp-colors").setup() + + lua require('navigator').setup() + else colorscheme miramare endif @@ -185,7 +168,6 @@ nnoremap <leader>b <cmd>Telescope buffers<cr> " tabs nnoremap ]t :tabn<CR> nnoremap [t :tabp<CR> -nnoremap <leader>t :tabs<CR> " only one window nnoremap <leader>o :only<CR> diff --git a/nvim/lua/feline_style.lua b/nvim/lua/feline_style.lua index a211832..5159759 100644 --- a/nvim/lua/feline_style.lua +++ b/nvim/lua/feline_style.lua @@ -60,7 +60,7 @@ local comps = { vi_mode = { left = { provider = function() - return ' ' .. vi_mode_utils.get_vim_mode() + return vi_mode_utils.get_vim_mode() end, hl = function() local val = { @@ -72,19 +72,6 @@ local comps = { end, right_sep = ' ' }, - right = { - -- provider = '▊', - provider = '' , - hl = function() - local val = { - name = vi_mode_utils.get_mode_highlight_name(), - fg = vi_mode_utils.get_mode_color() - } - return val - end, - left_sep = ' ', - right_sep = ' ' - } }, file = { info = { @@ -220,6 +207,7 @@ local comps = { }, change = { provider = 'git_diff_changed', + icon = ' ', hl = { fg = colors.orange } diff --git a/nvim/lua/git.lua b/nvim/lua/git.lua index 4a39d19..bc9ea8f 100644 --- a/nvim/lua/git.lua +++ b/nvim/lua/git.lua @@ -7,7 +7,7 @@ require('gitsigns').setup { changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, }, signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + numhl = true, -- Toggle with `:Gitsigns toggle_numhl` linehl = false, -- Toggle with `:Gitsigns toggle_linehl` word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` keymaps = { @@ -22,7 +22,7 @@ require('gitsigns').setup { ['n hS'] = '<cmd>lua require"gitsigns".stage_buffer()<CR>', ['n hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>', ['n hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>', - ['n hb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>', + ['n hB'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>', }, watch_gitdir = { interval = 1000, diff --git a/nvim/lua/lsp_conf.lua b/nvim/lua/lsp_conf.lua index a63b761..ba574d6 100644 --- a/nvim/lua/lsp_conf.lua +++ b/nvim/lua/lsp_conf.lua @@ -1,5 +1,18 @@ local nvim_lsp = require('lspconfig') local coq = require('coq') +local null_ls = require("null-ls") +local trouble = require("trouble") + +-- Redefine sign. +local signs = { Error = ' ', Warning = ' ', Hint = ' ', Information = ' ' } + +for type, icon in pairs(signs) do + local hl = 'LspDiagnosticsSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) +end + +local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end +local opts = { noremap=true, silent=true } local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end @@ -12,18 +25,31 @@ local on_attach = function(client, bufnr) 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', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) - buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) - buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) end +null_ls.config({ + debug = false, + sources = { + -- Python + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.isort, + null_ls.builtins.diagnostics.flake8, + -- Rust + null_ls.builtins.formatting.rustfmt, + -- C + null_ls.builtins.formatting.clang_format, + -- JS/TS + null_ls.builtins.formatting.prettier, + } +}) + -- Setup lspconfig. --- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches -local servers = { 'jedi_language_server', 'rust_analyzer', 'tsserver', 'clangd' } +local servers = { 'pyright', 'rust_analyzer', 'tsserver', 'clangd' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { capabilities = coq.lsp_ensure_capabilities(), @@ -33,3 +59,19 @@ for _, lsp in ipairs(servers) do } } end + +nvim_lsp["null-ls"].setup({ + on_attach = function(client, bufnr) + -- Format on save. + if client.resolved_capabilities.document_formatting then + buf_set_keymap('n', '<leader>fs', '<cmd>lua vim.lsp.buf.formatting_sync()<cr>', opts) + vim.cmd 'autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()' + end + end +}) + +trouble.setup({ + use_lsp_diagnostic_signs = true, + auto_close = true, + auto_open = true +}) |