15 -- Some options are more chill in text mode, this unchills them if a LSP is in |
15 -- Some options are more chill in text mode, this unchills them if a LSP is in |
16 -- play. Note they're global |
16 -- play. Note they're global |
17 vim.api.nvim_create_autocmd("LspAttach", { |
17 vim.api.nvim_create_autocmd("LspAttach", { |
18 once = true, |
18 once = true, |
19 group = "lsp_attach", |
19 group = "lsp_attach", |
20 callback = function(args) |
20 callback = function() |
21 vim.opt.number = true |
21 vim.opt.number = true |
22 vim.opt.updatetime = 250 |
22 vim.opt.updatetime = 250 |
23 end, |
23 end, |
24 }) |
24 }) |
25 |
25 |
37 -- Format on write, but only certain languages |
37 -- Format on write, but only certain languages |
38 local autoformat_filetypes = { elixir = true, go = true } |
38 local autoformat_filetypes = { elixir = true, go = true } |
39 |
39 |
40 vim.api.nvim_create_autocmd("BufWritePre", { |
40 vim.api.nvim_create_autocmd("BufWritePre", { |
41 group = vim.api.nvim_create_augroup("lsp_autoformat", { clear = true }), |
41 group = vim.api.nvim_create_augroup("lsp_autoformat", { clear = true }), |
42 callback = function(opts, bufnr) |
42 callback = function() |
43 if autoformat_filetypes[vim.bo.filetype] then |
43 if autoformat_filetypes[vim.bo.filetype] then |
44 vim.lsp.buf.format({ timeout_ms = 100 }) |
44 vim.lsp.buf.format({ timeout_ms = 100 }) |
45 end |
45 end |
46 end, |
46 end, |
47 }) |
47 }) |