change to pylsp add vue change to jaq to run code

This commit is contained in:
gameloader 2022-11-24 19:01:27 +08:00
parent 3eee395fbf
commit bb51b61c79
13 changed files with 188 additions and 23 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ plugin
.DS_Store
snippets/go.json
snippets/python.json

View File

@ -23,12 +23,10 @@ require("plugin-config/dashboard")
require("plugin-config/neoscroll")
require("plugin-config/hop")
require("plugin-config/live_command")
-- require("plugin-config/JABS")
require("plugin-config/jaq")
require("plugin-config/toggleterm")
require("plugin-config/indent-blankline")
require("plugin-config/coderunner")
require("plugin-config/lazygit")
-- require("plugin-config/neogit")
require("autocmd")
require("lsp")

View File

@ -18,8 +18,8 @@ end
local autoCommands = {
-- other autocommands
open_folds = {
{ "BufEnter", "*", "normal zx" },
{ "BufEnter", "*", "normal zR" },
{ "BufAdd", "*", "normal zx" },
{ "BufEnter,BufModifiedSet", "*", "normal zR" },
},
}

View File

@ -31,7 +31,7 @@ end
-- code related
-- 代码相关
map("n", ",", ":RunCode<CR>", opt)
map("n", ",", ":Jaq<CR>", opt)
-- markdown related
-- markdown 相关
@ -115,6 +115,8 @@ wk.register({
b = { ":Telescope buffers<CR>", "Open buffers" },
n = { ":ls<CR>", "Buffer numbers" },
c = { ":noh<CR>", "Cancel highlight" },
C = { ":call setqflist([], 'r')<CR>", "Clear quickfix" },
q = { ":copen<CR>", "Open quickfix" },
s = { ":Telescope current_buffer_fuzzy_find<CR>", "Searching in buffer" },
},
})
@ -207,6 +209,11 @@ function SetKeybinds()
["d"] = { ":HeaderDecrease<CR>", "All header decrease" },
["i"] = { ":HeaderIncrease<CR>", "All header increase" },
}, opts)
elseif fileTy == "python" then
wk.register({
["r"] = { ":MagmaEvaluateOperator<CR>", "Jupyter evaluate" },
["c"] = { ":MagmaEvaluateCell<CR>", "Jupyter evaluate cell" },
}, opts)
-- elseif fileTy == "sh" then
-- wk.register({
-- ["W"] = { ":w<CR>", "test write" },

44
lua/lsp/config/pylsp.lua Normal file
View File

@ -0,0 +1,44 @@
return {
on_setup = function(server)
server.setup({
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = { "E501" },
},
},
},
},
flags = {
debounce_text_changes = 150,
},
on_attach = function(client, bufnr)
-- 禁用格式化功能,交给专门插件插件处理
client.server_capabilities.document_formatting = false
client.server_capabilities.document_range_formatting = false
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = "rounded",
source = "always",
prefix = " ",
scope = "cursor",
}
vim.diagnostic.open_float(nil, opts)
end,
})
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- 绑定快捷键
require("keybindings").maplsp(buf_set_keymap)
end,
})
end,
}

View File

@ -1 +1,43 @@
return require("lsp.config.basic_config")
return {
on_setup = function(server)
server.setup({
filetypes = {
"typescript",
"javascript",
"javascriptreact",
"typescriptreact",
"vue",
"json",
},
flags = {
debounce_text_changes = 150,
},
on_attach = function(client, bufnr)
-- 禁用格式化功能,交给专门插件插件处理
client.server_capabilities.document_formatting = false
client.server_capabilities.document_range_formatting = false
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = "rounded",
source = "always",
prefix = " ",
scope = "cursor",
}
vim.diagnostic.open_float(nil, opts)
end,
})
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- 绑定快捷键
require("keybindings").maplsp(buf_set_keymap)
end,
})
end,
}

View File

@ -10,14 +10,15 @@ local servers = {
gopls = require("lsp.config.gopls"),
eslint = require("lsp.config.eslint"),
-- bashls = require("lsp.config.bash"),
pyright = require("lsp.config.pyright"),
-- pyright = require("lsp.config.pyright"),
pylsp = require("lsp.config.pylsp"),
volar = require("lsp.config.vue"),
-- jedi_language_server = require("lsp.config.jedi"),
vuels = require("lsp.config.vue"),
-- html = require("lsp.config.html"),
-- cssls = require("lsp.config.css"),
-- emmet_ls = require("lsp.config.emmet"),
-- jsonls = require("lsp.config.json"),
tsserver = require("lsp.config.ts"),
-- tsserver = require("lsp.config.ts"),
-- rust_analyzer = require("lsp.config.rust"),
-- yamlls = require("lsp.config.yamlls"),
-- remark_ls = require("lsp.config.markdown"),

View File

@ -16,6 +16,8 @@ require("null-ls").setup({
require("null-ls").builtins.formatting.clang_format,
require("null-ls").builtins.formatting.gofmt,
require("null-ls").builtins.formatting.black,
require("null-ls").builtins.formatting.eslint_d,
require("null-ls").builtins.formatting.jq,
},
-- you can reuse a shared lspconfig on_attach callback here
on_attach = function(client, bufnr)

View File

@ -1 +0,0 @@
require("jabs").setup({})

View File

@ -1,9 +0,0 @@
require("code_runner").setup({
focus = false,
filetype = {
c = "cd $dir && gcc $fileName -o $fileNameWithoutExt -g && $dir/$fileNameWithoutExt",
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt -g -w -std=c++11 && $dir/$fileNameWithoutExt",
go = "cd $dir && go run $fileName",
python = "cd $dir && python3 $fileName",
},
})

72
lua/plugin-config/jaq.lua Normal file
View File

@ -0,0 +1,72 @@
require("jaq-nvim").setup({
cmds = {
-- Uses vim commands
internal = {
lua = "luafile %",
vim = "source %",
},
-- Uses shell commands
external = {
markdown = "glow %",
python = "python %",
go = "go run %",
sh = "sh %",
c = "cd $dir && gcc $file -o $fileBase -g && $dir/$fileBase",
cpp = "cd $dir && g++ $file -o $fileBase -g -w -std=c++11 && $dir/$fileBase",
},
},
behavior = {
-- Default type
default = "terminal",
-- Start in insert mode
startinsert = false,
-- Use `wincmd p` on startup
wincmd = false,
-- Auto-save files
autosave = false,
},
ui = {
float = {
-- See ':h nvim_open_win'
border = "none",
-- See ':h winhl'
winhl = "Normal",
borderhl = "FloatBorder",
-- See ':h winblend'
winblend = 0,
-- Num from `0-1` for measurements
height = 0.8,
width = 0.8,
x = 0.5,
y = 0.5,
},
terminal = {
-- Window position
position = "bot",
-- Window size
size = 10,
-- Disable line numbers
line_no = false,
},
quickfix = {
-- Window position
position = "bot",
-- Window size
size = 10,
},
},
})

View File

@ -153,8 +153,7 @@ return require("packer").startup(function()
-- coderunner
-- 代码运行
use({ "CRAG666/code_runner.nvim", requires = "nvim-lua/plenary.nvim" })
use({ "is0n/jaq-nvim" })
-- cmake support
-- cmake 支持
use("Civitasv/cmake-tools.nvim")
@ -194,6 +193,9 @@ return require("packer").startup(function()
-- copilot 增强
use("github/copilot.vim")
------------------- repl ----------------------
use({ "hkupty/iron.nvim" })
------------------- dap -----------------------
-- dap for neovim
-- dap ui和适配器

View File

@ -13,6 +13,12 @@
"markdown"
],
"path":"./markdown.json"
},
{
"language":[
"python"
],
"path":"./python.json"
}
]
}