1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
-- Custom filetypes
vim.filetype.add({
extension = {
conf = "conf",
nd = "markdown",
},
pattern = {
[".*%.env.*"] = "sh",
["ignore$"] = "conf",
},
})
local cmd = vim.api.nvim_create_autocmd
-- Go to last location when opening buffer
cmd("BufReadPost", {
command = [[ if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif ]]
})
-- Highlight the region on yank
cmd("TextYankPost", {
group = vim.api.nvim_create_augroup("TextYankGroup", { clear = true }),
callback = function() vim.highlight.on_yank({ higroup = "Visual" }) end,
})
--[[ vim.api.nvim_create_autocmd(
{"TextChangedI", "TextChangedP"},
{
callback = function()
local line = vim.api.nvim_get_current_line()
local cursor = vim.api.nvim_win_get_cursor(0)[2]
local current = string.sub(line, cursor, cursor + 1)
if current == "." or current == "," or current == " " then
require('cmp').close()
end
local before_line = string.sub(line, 1, cursor + 1)
local after_line = string.sub(line, cursor + 1, -1)
if not string.match(before_line, '^%s+$') then
if after_line == "" or string.match(before_line, " $") or string.match(before_line, "%.$") then
require('cmp').complete()
end
end
end,
pattern = "*"
}) ]]
|