From 8bfc10c4e6f89da50ea1ffa7c137db8472299378 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Tue, 18 Jan 2022 15:54:13 -0300 Subject: [PATCH] Using the attach from LSP to set buffer options --- nvim/init.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 1f19273..a60cbab 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -21,17 +21,24 @@ vim.cmd [[ -- Keybind: use '-' to open the file explorer vim.api.nvim_set_keymap('n', '-', ':Ex', { noremap=true, silent=true }) --- Rainbow braket configuration -vim.g['rainbow_active'] = true - -- lsp configuration local nvim_lsp = require('lspconfig') +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 + -- let's use the lsp filetype attach to set buffer (and window) options + vim.bo.expandtab = true + vim.bo.tabstop = 4 + vim.bo.shiftwidth = 4 + vim.bo.softtabstop = 4 + vim.bo.textwidth = 79 + + vim.wo.number = true + vim.wo.colorcolumn = '80' - local opts = { noremap=true, silent=true } buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'K', 'Lspsaga hover_doc', opts)