style(nvim): format lua
This commit is contained in:
parent
eb86f4860c
commit
3fd3d74ee5
|
@ -47,6 +47,15 @@ function _G.insert_iso8601_timestamp()
|
|||
vim.api.nvim_command([[normal! "up]])
|
||||
end
|
||||
|
||||
|
||||
vim.api.nvim_set_keymap("n", "<leader>pt", [[:lua _G.insert_iso8601_timestamp()<cr>]], {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap("i", "<c-d><c-t>", [[<esc>:lua _G.insert_iso8601_timestamp()<cr>a]], {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"<leader>pt",
|
||||
[[:lua _G.insert_iso8601_timestamp()<cr>]],
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
vim.api.nvim_set_keymap(
|
||||
"i",
|
||||
"<c-d><c-t>",
|
||||
[[<esc>:lua _G.insert_iso8601_timestamp()<cr>a]],
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vim.defer_fn(function()
|
||||
require('copilot').setup({
|
||||
require("copilot").setup({
|
||||
panel = {
|
||||
enabled = false,
|
||||
auto_refresh = true,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
local prettier = function()
|
||||
return {
|
||||
exe = Get_project_node_modules_path() .. "/.bin/prettier",
|
||||
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
|
||||
stdin = true
|
||||
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
|
||||
stdin = true,
|
||||
}
|
||||
end
|
||||
|
||||
require('formatter').setup({
|
||||
require("formatter").setup({
|
||||
log_level = vim.log.levels.INFO,
|
||||
filetype = {
|
||||
javascript = { prettier },
|
||||
|
@ -16,18 +16,21 @@ require('formatter').setup({
|
|||
-- https://github.com/JohnnyMorganz/StyLua
|
||||
-- cargo install stylua --features lua54
|
||||
lua = {
|
||||
require("formatter.filetypes.lua").stylua
|
||||
require("formatter.filetypes.lua").stylua,
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
-- TODO: use vim.api.nvim_create_augroup()
|
||||
vim.api.nvim_exec2([[
|
||||
vim.api.nvim_exec2(
|
||||
[[
|
||||
augroup FormatAutogroup
|
||||
autocmd!
|
||||
autocmd BufWritePost *.js,*.ts,*.tsx,*.lua silent FormatWrite
|
||||
augroup END
|
||||
]], { output = true })
|
||||
]],
|
||||
{ output = true }
|
||||
)
|
||||
|
||||
local bufnr = vim.fn.bufnr("%")
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>F', '<Cmd>silent Format<CR>', { noremap=true, silent=true })
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>F", "<Cmd>silent Format<CR>", { noremap = true, silent = true })
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
local nvim_lsp = require('lspconfig')
|
||||
local nvim_lsp = require("lspconfig")
|
||||
local on_attach = function(client, bufnr)
|
||||
-- TODO: use vim.api.nvim_create_autocmd
|
||||
vim.api.nvim_exec2([[autocmd User LspDiagnosticsChanged call lightline#update()]], { output = false })
|
||||
|
||||
local opts = { noremap = true, silent = false }
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gD', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<Cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>r', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>i', '<Cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<Cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ci', '<Cmd>lua vim.lsp.buf.incoming_calls()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>co', '<Cmd>lua vim.lsp.buf.outgoing_calls()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']e', '<Cmd>lua vim.diagnostic.goto_next({severity="Error"})<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[e', '<Cmd>lua vim.diagnostic.goto_prev({severity="Error"})<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<Cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<Cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'cd', '<Cmd>lua vim.diagnostic.hide(nil, 0)<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>gD", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>e", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>r", "<Cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>i", "<Cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<Cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ci", "<Cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>co", "<Cmd>lua vim.lsp.buf.outgoing_calls()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]e", '<Cmd>lua vim.diagnostic.goto_next({severity="Error"})<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[e", '<Cmd>lua vim.diagnostic.goto_prev({severity="Error"})<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "cd", "<Cmd>lua vim.diagnostic.hide(nil, 0)<CR>", opts)
|
||||
|
||||
-- fzf triggers:
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fr', '<Cmd>References<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fi', '<Cmd>Implementations<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fs', '<Cmd>DocumentSymbols<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fw', '<Cmd>WorkspaceSymbols<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fc', '<Cmd>CodeActions<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fci', '<Cmd>IncomingCalls<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fco', '<Cmd>OutgoingCalls<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fr", "<Cmd>References<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fi", "<Cmd>Implementations<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fs", "<Cmd>DocumentSymbols<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fw", "<Cmd>WorkspaceSymbols<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fc", "<Cmd>CodeActions<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fci", "<Cmd>IncomingCalls<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fco", "<Cmd>OutgoingCalls<CR>", opts)
|
||||
|
||||
require 'lsp_signature'.on_attach({
|
||||
require("lsp_signature").on_attach({
|
||||
hint_enable = false,
|
||||
})
|
||||
|
||||
require 'copilot_cmp'.setup();
|
||||
require("copilot_cmp").setup()
|
||||
end
|
||||
|
||||
-- Go
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = {
|
||||
'documentation',
|
||||
'detail',
|
||||
'additionalTextEdits',
|
||||
}
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits",
|
||||
},
|
||||
}
|
||||
|
||||
nvim_lsp.gopls.setup{
|
||||
nvim_lsp.gopls.setup({
|
||||
settings = {
|
||||
gopls = {
|
||||
staticcheck = true,
|
||||
|
@ -67,10 +67,10 @@ nvim_lsp.gopls.setup{
|
|||
},
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
-- Rust
|
||||
nvim_lsp.rust_analyzer.setup{
|
||||
nvim_lsp.rust_analyzer.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
|
@ -91,23 +91,23 @@ nvim_lsp.rust_analyzer.setup{
|
|||
},
|
||||
diagnostics = {
|
||||
disabled = { "unresolved-proc-macro" },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Ruby
|
||||
|
||||
nvim_lsp.solargraph.setup{
|
||||
nvim_lsp.solargraph.setup({
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
-- Typescript
|
||||
-- https://jose-elias-alvarez.medium.com/configuring-neovims-lsp-client-for-typescript-development-5789d58ea9c
|
||||
|
||||
nvim_lsp.tsserver.setup{
|
||||
nvim_lsp.tsserver.setup({
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
||||
local filetypes = {
|
||||
typescript = "eslint",
|
||||
|
@ -132,40 +132,40 @@ local linters = {
|
|||
endLine = "endLine",
|
||||
endColumn = "endColumn",
|
||||
message = "${message} [${ruleId}]",
|
||||
security = "severity"
|
||||
security = "severity",
|
||||
},
|
||||
securities = { [1] = "error", [2] = "warning" },
|
||||
},
|
||||
securities = {[1] = "error", [2] = "warning"}
|
||||
}
|
||||
}
|
||||
|
||||
nvim_lsp.diagnosticls.setup{
|
||||
nvim_lsp.diagnosticls.setup({
|
||||
on_attach = on_attach,
|
||||
filetypes = vim.tbl_keys(filetypes),
|
||||
init_options = {
|
||||
linters = linters,
|
||||
filetypes = filetypes,
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
-- Lua
|
||||
|
||||
local lua_ls_root_path = os.getenv("HOME") .. "/dev/lua-language-server"
|
||||
local lua_ls_binary = lua_ls_root_path .. "/bin/lua-language-server"
|
||||
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
local runtime_path = vim.split(package.path, ";")
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
nvim_lsp.lua_ls.setup {
|
||||
cmd = {lua_ls_binary, "-E", lua_ls_root_path .. "/main.lua"};
|
||||
nvim_lsp.lua_ls.setup({
|
||||
cmd = { lua_ls_binary, "-E", lua_ls_root_path .. "/main.lua" },
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
version = "LuaJIT",
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = {'vim'},
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
|
@ -176,4 +176,4 @@ nvim_lsp.lua_ls.setup {
|
|||
},
|
||||
},
|
||||
on_attach = on_attach,
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
local cmp = require('cmp')
|
||||
local cmp_buffer = require('cmp_buffer')
|
||||
local cmp = require("cmp")
|
||||
local cmp_buffer = require("cmp_buffer")
|
||||
|
||||
cmp.setup({
|
||||
completion = {
|
||||
completeopt = 'menu,menuone,noinsert',
|
||||
completeopt = "menu,menuone,noinsert",
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
@ -11,37 +11,38 @@ cmp.setup({
|
|||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['C-y'] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'copilot', keyword_length = 0 },
|
||||
{ name = 'nvim_lsp', keyword_length = 3 },
|
||||
{ name = "copilot", keyword_length = 0 },
|
||||
{ name = "nvim_lsp", keyword_length = 3 },
|
||||
{
|
||||
name = 'buffer',
|
||||
name = "buffer",
|
||||
option = {
|
||||
get_bufnrs = function()
|
||||
return vim.api.nvim_list_bufs()
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
{ name = 'path' },
|
||||
{ name = 'calc' },
|
||||
{ name = "path" },
|
||||
{ name = "calc" },
|
||||
}),
|
||||
sorting = {
|
||||
comparators = {
|
||||
function(...) return cmp_buffer:compare_locality(...) end,
|
||||
}
|
||||
function(...)
|
||||
return cmp_buffer:compare_locality(...)
|
||||
end,
|
||||
},
|
||||
},
|
||||
view = {
|
||||
entries = 'native',
|
||||
entries = "native",
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -36,7 +36,12 @@ _G.run_tests = function()
|
|||
|
||||
local winid = _G._test_cmd_to_wins[cmd]
|
||||
local current_winid = vim.fn.win_getid()
|
||||
if winid == nil or not vim.api.nvim_win_is_valid(winid) or winid == current_winid or not vim.fn.win_gotoid(winid) == -1 then
|
||||
if
|
||||
winid == nil
|
||||
or not vim.api.nvim_win_is_valid(winid)
|
||||
or winid == current_winid
|
||||
or not vim.fn.win_gotoid(winid) == -1
|
||||
then
|
||||
vim.api.nvim_command([[10split]])
|
||||
winid = vim.fn.win_getid()
|
||||
_G._test_cmd_to_wins[cmd] = winid
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'nvim-treesitter.configs'.setup {
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = "all",
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
@ -74,20 +74,20 @@ require 'nvim-treesitter.configs'.setup {
|
|||
updatetime = 25,
|
||||
persist_queries = false,
|
||||
keybindings = {
|
||||
toggle_query_editor = 'o',
|
||||
toggle_hl_groups = 'i',
|
||||
toggle_injected_languages = 't',
|
||||
toggle_anonymous_nodes = 'a',
|
||||
toggle_language_display = 'I',
|
||||
focus_language = 'f',
|
||||
unfocus_language = 'F',
|
||||
update = 'R',
|
||||
goto_node = '<cr>',
|
||||
show_help = '?',
|
||||
toggle_query_editor = "o",
|
||||
toggle_hl_groups = "i",
|
||||
toggle_injected_languages = "t",
|
||||
toggle_anonymous_nodes = "a",
|
||||
toggle_language_display = "I",
|
||||
focus_language = "f",
|
||||
unfocus_language = "F",
|
||||
update = "R",
|
||||
goto_node = "<cr>",
|
||||
show_help = "?",
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
require'treesitter-context'.setup{
|
||||
require("treesitter-context").setup({
|
||||
enable = true,
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue