Browse Source

Using the attach from LSP to set buffer options

master
Julio Biason 3 years ago
parent
commit
8bfc10c4e6
  1. 21
      nvim/init.lua

21
nvim/init.lua

@ -21,17 +21,24 @@ vim.cmd [[
-- Keybind: use '-' to open the file explorer
vim.api.nvim_set_keymap('n', '-', ':Ex<CR>', { noremap=true, silent=true })
-- Rainbow braket configuration
vim.g['rainbow_active'] = true
-- lsp configuration
local nvim_lsp = require('lspconfig')
local on_attach = function(client, bufnr)
local function buf_set_keymap(...)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
end
local opts = { noremap=true, silent=true }
local on_attach = function(client, bufnr)
-- 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', '<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>Lspsaga hover_doc<CR>', opts)

Loading…
Cancel
Save