Setup tab and autocompletion
This commit is contained in:
parent
a579f0011f
commit
93767eb7f4
36
init.lua
36
init.lua
|
|
@ -14,6 +14,8 @@ local set = vim.opt -- set options
|
|||
set.tabstop = 8
|
||||
set.softtabstop = 8
|
||||
set.shiftwidth = 8
|
||||
-- Disable tab settings being overriden
|
||||
vim.cmd("filetype plugin indent off")
|
||||
|
||||
-- Terminal Config
|
||||
-- Exit terminal mode with Esc
|
||||
|
|
@ -198,6 +200,30 @@ require('neogen').setup {
|
|||
-- jump_map = "<C-e>" -- (DROPPED SUPPORT, see [here](#cycle-between-annotations) !) The keymap in order to jump in the annotation fields (in insert mode)
|
||||
}
|
||||
|
||||
-- Built in tabcomplete/autocomplete setup
|
||||
function check_for_whitespace()
|
||||
-- Get the current cursor position (row and column)
|
||||
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
-- Get the text of the current line
|
||||
local linetext = vim.api.nvim_get_current_line()
|
||||
-- Neovim's column is 0-based, Lua's string indices are 1-based.
|
||||
|
||||
-- Return true if we are at the start of the line (col == 0)
|
||||
-- OR if the character before the cursor is a whitespace character (%s)
|
||||
-- linetext:sub(col, col) gets the character at the column index
|
||||
return col == 0 or string.match(linetext:sub(col, col), '%s') ~= nil
|
||||
end
|
||||
-- Tabcomplete:
|
||||
vim.api.nvim_set_keymap('i', '<Tab>', "pumvisible() ? '<C-y>' : v:lua.check_for_whitespace() ? '<Tab>' : '<C-x><C-n>'", { expr = true, silent = true })
|
||||
-- Autocomplete:
|
||||
-- vim.api.nvim_create_autocmd("InsertCharPre", {
|
||||
-- callback = function(ev)
|
||||
-- if vim.bo[ev.buf].buftype == '' and not (vim.fn.pumvisible() == 1) then
|
||||
-- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-x><C-n>", true, false, true), 'i', false)
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- LSP Configuration
|
||||
local lsp_zero = require('lsp-zero')
|
||||
-- https://lsp-zero.netlify.app/v3.x/language-server-configuration.html#default-keybindings
|
||||
|
|
@ -217,15 +243,11 @@ lsp_zero.on_attach(function(client, bufnr)
|
|||
|
||||
vim.lsp.inlay_hint.enable(true, { 0 })
|
||||
|
||||
vim.cmd("set tabstop=8")
|
||||
vim.cmd("set shiftwidth=8")
|
||||
vim.cmd("set softtabstop=8")
|
||||
-- Override default omnifunc completer with LSP completion for LSP buffer
|
||||
-- Tabcomplete:
|
||||
-- vim.api.nvim_set_keymap('i', '<Tab>', "pumvisible() ? '<C-y>' : v:lua.check_for_whitespace() ? '<Tab>' : '<cmd>lua vim.lsp.completion.get()<CR>'", { expr = true, silent = true })
|
||||
end)
|
||||
|
||||
-- LSP Autocompletion settings
|
||||
vim.keymap.set('i', '<c-space>', function()
|
||||
vim.lsp.completion.get()
|
||||
end)
|
||||
|
||||
--local lspconfig = require("lspconfig")
|
||||
vim.lsp.enable("lua_ls")
|
||||
|
|
|
|||
Loading…
Reference in New Issue