-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.lua
149 lines (137 loc) · 3.84 KB
/
init.lua
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = ','
-- disable checks for python; there is no plugin dependency using python
-- this is mostly required for legacy vim plugins that depend on python
-- most plugins nowadays use lua instead.
vim.g.loaded_python3_provider = 0
require('lazy').setup('plugins', {
defaults = { lazy = false },
})
vim.o.foldmethod = 'indent'
vim.o.foldlevel = 99
vim.opt.diffopt = vim.opt.diffopt + 'vertical'
vim.o.mouse = ''
vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, {
pattern = '*.py',
callback = function()
vim.bo.tabstop = 4
vim.bo.softtabstop = 4
vim.bo.shiftwidth = 4
vim.bo.expandtab = true
vim.o.smarttab = true
end
})
vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, {
pattern = {'*.js', '*.html', '*.css', '*.ts', '*.yml', '*.yaml', '*.json', '*.lua'},
callback = function()
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
end
})
vim.o.cursorline = true
vim.o.cursorlineopt = 'number'
vim.o.relativenumber = true
vim.o.number = true
vim.o.updatetime = 500
-- cause vim to move the cursor to the previous matching bracket for half a
-- second.
vim.o.showmatch = true
vim.o.laststatus = 2
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.softtabstop = 4
vim.o.smarttab = false
vim.o.wrap = true
vim.o.linebreak = true
vim.o.list = false
vim.o.textwidth = 0
vim.o.wrapmargin = 0
vim.o.backspace = 'indent,eol,start'
vim.o.autoindent = true
vim.o.exrc = true
vim.keymap.set('n', '<leader>b', ':ls<CR>:b<Space>', {remap = false})
do
local vimdir = vim.env.HOME .. '/.vim'
vim.o.backupdir = vimdir .. '/backup//'
vim.o.directory = vimdir .. '/swap//'
vim.o.undodir = vimdir .. '/undodir//'
end
-- better indentation
vim.keymap.set('v', '<', '<gv', {remap = false})
vim.keymap.set('v', '>', '>gv', {remap = false})
-- to easily move through windows
vim.keymap.set('n', '<C-j>', '<c-w>j')
vim.keymap.set('n', '<C-k>', '<c-w>k')
vim.keymap.set('n', '<C-l>', '<c-w>l')
vim.keymap.set('n', '<C-h>', '<c-w>h')
if vim.fn.has('termguicolors') then
vim.o.termguicolors = true
end
vim.o.cc = '80'
-- WSL yank support
if(vim.fn.executable('clip.exe') ~= 0) then
vim.g.clipboard = {
name = 'WslClipboard',
copy = {
['+'] = 'clip.exe',
['*'] = 'clip.exe',
},
paste = {
['+'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
['*'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
},
cache_enabled = 0,
}
end
_G.remote_docker_debug_cmd = function(command)
local container_name = command.args
local dap = require('dap')
local container_ls = ("docker container ls -qf 'name=%s'"):format(container_name)
local function exec(cmd)
return (io.popen(cmd, "r")):read("l")
end
local container_id = exec(container_ls)
if container_id == nil then
print("cannot access the container, make sure it is running")
return
end
local container_ip = exec(
("docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' %s"):format(container_id)
)
dap.run(
{
type = "python",
request = "attach",
justMyCode = false,
name = "docker remote debugger",
connect = {
host = container_ip,
port = 5678
},
pathMappings = {
{
localRoot = vim.fn.getcwd(),
remoteRoot = "/app",
}
},
}
)
end
vim.api.nvim_create_user_command(
"DebugDocker", _G.remote_docker_debug_cmd, {nargs=1}
)