From aa5717f00fd14430c80939a68d7107c26de6e554 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Karimi Date: Tue, 20 Jan 2026 15:55:27 -0500 Subject: first commit --- after/ftplugin/lua.vim | 9 +++++++++ after/ftplugin/mail.vim | 6 ++++++ after/ftplugin/markdown.lua | 14 ++++++++++++++ after/ftplugin/python.lua | 29 +++++++++++++++++++++++++++++ after/ftplugin/tex.lua | 19 +++++++++++++++++++ after/lsp/emmylua_ls.lua | 29 +++++++++++++++++++++++++++++ after/lsp/qmlls.lua | 4 ++++ after/lsp/rust_analyzer.lua | 0 8 files changed, 110 insertions(+) create mode 100644 after/ftplugin/lua.vim create mode 100644 after/ftplugin/mail.vim create mode 100644 after/ftplugin/markdown.lua create mode 100644 after/ftplugin/python.lua create mode 100644 after/ftplugin/tex.lua create mode 100644 after/lsp/emmylua_ls.lua create mode 100644 after/lsp/qmlls.lua create mode 100644 after/lsp/rust_analyzer.lua (limited to 'after') diff --git a/after/ftplugin/lua.vim b/after/ftplugin/lua.vim new file mode 100644 index 0000000..6d9a620 --- /dev/null +++ b/after/ftplugin/lua.vim @@ -0,0 +1,9 @@ +setlocal includeexpr=substitute(v:fname,'\\.','/','g').'.lua' +setlocal comments-=:-- comments+=:---,:-- +setlocal keywordprg=:help + +inoreabbrev lo local +inoreabbrev lf local function() +inoreabbrev fu function() end + +nnoremap K lua vim.lsp.buf.hover() diff --git a/after/ftplugin/mail.vim b/after/ftplugin/mail.vim new file mode 100644 index 0000000..4b76a14 --- /dev/null +++ b/after/ftplugin/mail.vim @@ -0,0 +1,6 @@ +set spell +set formatoptions+=wq + +setlocal tw=72 et cc=73 list + +map g= vipgq diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua new file mode 100644 index 0000000..fe9be18 --- /dev/null +++ b/after/ftplugin/markdown.lua @@ -0,0 +1,14 @@ +local function toggle_tick(buf, lnum, line, to) + local beg, tick, rest = line:match("^(%s*)- %[([x ])%](.*)") +end + +vim.keymap.set("n", "", function() + local curline = vim.fn.getline(".") + local lnum = vim.fn.getpos(".")[2] + local beg, tick, rest = curline:match("^(%s*)- %[([x ])%](.*)") + if beg == nil then return end + + local new_tick = (tick == " " and "x" or " ") + local new_line = beg .. "- [" .. new_tick .. "]" .. rest + vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { new_line }) +end, { buffer = true }) diff --git a/after/ftplugin/python.lua b/after/ftplugin/python.lua new file mode 100644 index 0000000..2f1a564 --- /dev/null +++ b/after/ftplugin/python.lua @@ -0,0 +1,29 @@ +local function keyword_help(kw) + local buf = vim.api.nvim_create_buf(false, true) + local win = vim.api.nvim_open_win(buf, true, { + anchor = "SE", + split = "below", + height = 20, + }) + local obj = vim.system({ "pydoc-markdown", "-m", kw }):wait() -- "--render-toc"?? + vim.api.nvim_buf_set_lines(buf, -1, -1, false, vim.split(obj.stdout, "\n")) + vim.bo[buf].filetype = "markdown" + vim.bo[buf].swapfile = false +end + +vim.api.nvim_create_user_command("PyDoc", function(params) + if #params.fargs > 0 then + keyword_help(params.fargs[1]) + end +end, { + bar = true, + range = true, + addr = "other", + nargs = "*", + complete = function(...) + vim.print("completion request: " .. vim.inspect(...)) + return nil + end, +}) + +vim.cmd([[ setlocal keywordprg=:PyDoc ]]) diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua new file mode 100644 index 0000000..963ab7f --- /dev/null +++ b/after/ftplugin/tex.lua @@ -0,0 +1,19 @@ +vim.cmd([[setlocal shiftwidth=2 tabstop=2]]) + +vim.fn.call("vimtex#imaps#add_map", { + { + lhs = "++", + rhs = "\\item ", + leader = "", + wrapper = "vimtex#imaps#wrap_environment", + context = { "itemize", "enumerate", "description" }, + }, +}) + +vim.fn.call("vimtex#imaps#add_map", { + { + lhs = "e", + rhs = "\\eps", + wrapper = "vimtex#imaps#wrap_math", + }, +}) diff --git a/after/lsp/emmylua_ls.lua b/after/lsp/emmylua_ls.lua new file mode 100644 index 0000000..4e0cd88 --- /dev/null +++ b/after/lsp/emmylua_ls.lua @@ -0,0 +1,29 @@ +return { + cmd = { vim.env.XDG_DATA_HOME .. "/cargo/bin/emmylua_ls" }, + filetypes = { "lua" }, + root_markers = { + ".emmyrc.json", + }, + workspace_required = false, + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if + path ~= vim.fn.stdpath("config") + and ( + vim.uv.fs_stat(path .. "/.luarc.json") + or vim.uv.fs_stat(path .. "/.luarc.jsonc") + or vim.uv.fs_stat(path .. "/.emmyrc.jsonc") + ) + then + return + end + end + + client.config.settings.Lua.workspace = + vim.tbl_deep_extend("force", client.config.settings.Lua.workspace, { + library = vim.api.nvim_get_runtime_file("", true), + }) + end, + settings = { Lua = { workspace = {} } }, +} diff --git a/after/lsp/qmlls.lua b/after/lsp/qmlls.lua new file mode 100644 index 0000000..46c4859 --- /dev/null +++ b/after/lsp/qmlls.lua @@ -0,0 +1,4 @@ +return { + cmd = { "qmlls6" }, + root_markers = { "shell.qml" }, +} diff --git a/after/lsp/rust_analyzer.lua b/after/lsp/rust_analyzer.lua new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-71-gdd5e