Mercurial > dotfiles
comparison dot_config/nvim/init.lua @ 313:a1ed17cc354b
Add a post-formatting handler to reload the buffer
This fixes some issues with treesitter highlighting/refactor not working
after formatting the buffer.
source: https://github.com/lukas-reineke/dotfiles/blob/97b95c9c27cada6ff73080600f724c58f3d7ebfd/vim/lua/lsp.lua#L31
author | Zeger Van de Vannet <zegervdv@me.com> |
---|---|
date | Thu, 26 Nov 2020 09:07:17 +0100 |
parents | f94a7c50a28d |
children | 7d73e664f702 |
comparison
equal
deleted
inserted
replaced
312:f94a7c50a28d | 313:a1ed17cc354b |
---|---|
100 mapper("i", "<c-n>", "<Plug>(completion_trigger)", false) | 100 mapper("i", "<c-n>", "<Plug>(completion_trigger)", false) |
101 mapper("i", "<c-j>", "<Plug>(completion_next_source)", false) | 101 mapper("i", "<c-j>", "<Plug>(completion_next_source)", false) |
102 mapper("i", "<c-k>", "<Plug>(completion_prev_source)", false) | 102 mapper("i", "<c-k>", "<Plug>(completion_prev_source)", false) |
103 end | 103 end |
104 | 104 |
105 vim.lsp.handlers["textDocument/formatting"] = function(err, _, result, _, bufnr) | |
106 if err ~= nil or result == nil then | |
107 return | |
108 end | |
109 if not vim.api.nvim_buf_get_option(bufnr, "modified") then | |
110 local view = vim.fn.winsaveview() | |
111 vim.lsp.util.apply_text_edits(result, bufnr) | |
112 vim.fn.winrestview(view) | |
113 -- Fix to reload Treesitter | |
114 vim.api.nvim_command("edit") | |
115 end | |
116 end | |
117 | |
105 lsp.pyls.setup{ | 118 lsp.pyls.setup{ |
106 cmd = {"pyls"}, | 119 cmd = {"pyls"}, |
107 on_attach = on_attach; | 120 on_attach = on_attach; |
108 } | 121 } |
109 | 122 |