personal laptop changes
This commit is contained in:
@ -201,9 +201,11 @@ return {
|
||||
capabilities = require("cmp_nvim_ciderlsp").update_capabilities(capabilities)
|
||||
capabilities.workspace.codeLens = { refreshSupport = true }
|
||||
capabilities.workspace.diagnostics = { refreshSupport = true }
|
||||
|
||||
lspconfig.analysislsp.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
lspconfig.ciderlsp.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = cider_on_attach,
|
||||
|
@ -1,10 +1,41 @@
|
||||
return {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
config = function()
|
||||
local TableConcat = require("utils").TableConcat
|
||||
local use_google = require("utils").use_google
|
||||
|
||||
local lsps = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
}
|
||||
|
||||
if not use_google then
|
||||
TableConcat(lsps, {
|
||||
"gopls",
|
||||
"graphql",
|
||||
})
|
||||
end
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "lua_ls", "rust_analyzer" },
|
||||
ensure_installed = lsps,
|
||||
})
|
||||
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
-- The first entry (without a key) will be the default handler
|
||||
-- and will be called for each installed server that doesn't have
|
||||
-- a dedicated handler.
|
||||
function(server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup({})
|
||||
end,
|
||||
-- Next, you can provide a dedicated handler for specific servers.
|
||||
-- For example, a handler override for the `rust_analyzer`:
|
||||
["rust_analyzer"] = function()
|
||||
require("rust-tools").setup({})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ return {
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
local null_ls = require("null-ls")
|
||||
local use_google = require("utils").use_google
|
||||
local TableConcat = require("utils").TableConcat
|
||||
|
||||
local sources = {
|
||||
-- Catch insensitive, inconsiderate writing.
|
||||
@ -12,7 +14,7 @@ return {
|
||||
null_ls.builtins.diagnostics.buildifier,
|
||||
|
||||
-- Codespell finds common misspellings in text files.
|
||||
-- null_ls.builtins.diagnostics.codespell,
|
||||
null_ls.builtins.diagnostics.codespell,
|
||||
-- null_ls.builtins.diagnostics.cspell, null_ls.builtins.code_actions.cspell,
|
||||
|
||||
-- An English prose linter. Can fix some issues via code actions.
|
||||
@ -22,6 +24,22 @@ return {
|
||||
null_ls.builtins.formatting.google_java_format,
|
||||
}
|
||||
|
||||
if not use_google then
|
||||
TableConcat(sources, {
|
||||
-- Bazel
|
||||
null_ls.builtins.diagnostics.buildifier,
|
||||
null_ls.builtins.formatting.buildifier,
|
||||
-- Golang
|
||||
null_ls.builtins.diagnostics.golangci_lint,
|
||||
null_ls.builtins.formatting.gofmt,
|
||||
null_ls.builtins.formatting.goimports_reviser,
|
||||
-- Misc
|
||||
null_ls.builtins.formatting.htmlbeautifier,
|
||||
null_ls.builtins.formatting.jq,
|
||||
null_ls.builtins.formatting.mdformat,
|
||||
})
|
||||
end
|
||||
|
||||
null_ls.setup({
|
||||
sources = sources,
|
||||
})
|
||||
|
@ -1,11 +1,31 @@
|
||||
local use_google = require("utils").use_google
|
||||
local TableConcat = require("utils").TableConcat
|
||||
local keys = {
|
||||
{ "<leader>fb", ":Telescope file_browser path=%:p:h select_buffer=true<CR>", desc = "[F]ile [B]rowser" },
|
||||
{ "<leader>tb", ":Telescope file_buffers<CR>", desc = "[T]elescope [B]uffers" },
|
||||
{ "<leader>th", [[:lua require('telescope.builtin').help_tags<cr>]], desc = "[T]elescope [H]elp" },
|
||||
{ "<leader>t*", [[:lua require('telescope.builtin').grep_string<cr>]], desc = "[T]elescope current [W]ord" },
|
||||
{ "<leader>tg", [[:lua require('telescope.builtin').live_grep<cr>]], desc = "[T]elescope by [G]rep" },
|
||||
}
|
||||
|
||||
if use_google() then
|
||||
TableConcat(keys, {
|
||||
{ "<C-P>", [[:lua require('telescope').extensions.codesearch.find_files{}<CR>]], "n" },
|
||||
{ "<C-Space>", [[:lua require('telescope').extensions.codesearch.find_query{}<CR>]] },
|
||||
{ "<leader>cs", [[:lua require('telescope').extensions.codesearch.find_query{}<CR>]] },
|
||||
{ "<leader>cs", [[:lua require('telescope').extensions.codesearch.find_query{}<CR>]], mode = "v" },
|
||||
{
|
||||
"<leader>CS",
|
||||
[[:lua require('telescope').extensions.codesearch.find_query{default_text_expand='<cword>'}<CR>]],
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
},
|
||||
}, {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
@ -52,51 +72,5 @@ return {
|
||||
})
|
||||
require("telescope").load_extension("file_browser")
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>fb",
|
||||
":Telescope file_browser path=%:p:h select_buffer=true<CR>",
|
||||
{ noremap = true },
|
||||
desc = "[F]ile [B]rowser",
|
||||
},
|
||||
{
|
||||
"<leader>tf",
|
||||
":Telescope file_browser",
|
||||
{ noremap = true },
|
||||
desc = "[T]elescope [F]ilebrowser",
|
||||
},
|
||||
{ "<leader>tb", ":Telescope file_buffers", desc = "[T]elescope [B]uffers" },
|
||||
{ "<leader>th", [[:lua require('telescope.builtin').help_tags<cr>]], desc = "[T]elescope [H]elp" },
|
||||
{ "<leader>tw", [[:lua require('telescope.builtin').grep_string<cr>]], desc = "[T]elescope current [W]ord" },
|
||||
{ "<leader>tg", [[:lua require('telescope.builtin').live_grep<cr>]], desc = "[T]elescope by [G]rep" },
|
||||
|
||||
-- Google mappings
|
||||
{
|
||||
"<C-P>",
|
||||
[[:lua require('telescope').extensions.codesearch.find_files{}<CR>]],
|
||||
"n",
|
||||
{ noremap = true, silent = true },
|
||||
},
|
||||
{
|
||||
"<C-Space>",
|
||||
[[:lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
||||
{ noremap = true, silent = true },
|
||||
},
|
||||
{
|
||||
"<leader>cs",
|
||||
[[:lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
||||
{ noremap = true, silent = true },
|
||||
},
|
||||
{
|
||||
"<leader>cs",
|
||||
[[:lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
||||
mode = "v",
|
||||
{ noremap = true, silent = true },
|
||||
},
|
||||
{
|
||||
"<leader>CS",
|
||||
[[:lua require('telescope').extensions.codesearch.find_query{default_text_expand='<cword>'}<CR>]],
|
||||
{ noremap = true, silent = true },
|
||||
},
|
||||
},
|
||||
keys = keys,
|
||||
}
|
||||
|
@ -1,67 +1,83 @@
|
||||
local M = {}
|
||||
|
||||
function M.map(mode, lhs, rhs, opts)
|
||||
local options = { noremap = true }
|
||||
if opts then
|
||||
options = vim.tbl_extend("force", options, opts)
|
||||
end
|
||||
-- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
vim.keymap.set(mode, lhs, rhs, options)
|
||||
local options = { noremap = true }
|
||||
if opts then
|
||||
options = vim.tbl_extend("force", options, opts)
|
||||
end
|
||||
-- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
vim.keymap.set(mode, lhs, rhs, options)
|
||||
end
|
||||
|
||||
function M.use_google()
|
||||
return M.file_exists(os.getenv("HOME").."/use_google")
|
||||
return M.file_exists(os.getenv("HOME") .. "/use_google")
|
||||
end
|
||||
|
||||
function M.file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
local f = io.open(name, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function M.dump(o)
|
||||
if type(o) == 'table' then
|
||||
local s = '{ '
|
||||
for k,v in pairs(o) do
|
||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
||||
s = s .. '['..k..'] = ' .. M.dump(v) .. ','
|
||||
end
|
||||
return s .. '} '
|
||||
else
|
||||
return tostring(o)
|
||||
end
|
||||
if type(o) == "table" then
|
||||
local s = "{ "
|
||||
for k, v in pairs(o) do
|
||||
if type(k) ~= "number" then
|
||||
k = '"' .. k .. '"'
|
||||
end
|
||||
s = s .. "[" .. k .. "] = " .. M.dump(v) .. ","
|
||||
end
|
||||
return s .. "} "
|
||||
else
|
||||
return tostring(o)
|
||||
end
|
||||
end
|
||||
|
||||
function M.tprint (tbl, indent)
|
||||
if not indent then indent = 0 end
|
||||
local toprint = string.rep(" ", indent) .. "{\r\n"
|
||||
indent = indent + 2
|
||||
for k, v in pairs(tbl) do
|
||||
toprint = toprint .. string.rep(" ", indent)
|
||||
if (type(k) == "number") then
|
||||
toprint = toprint .. "[" .. k .. "] = "
|
||||
elseif (type(k) == "string") then
|
||||
toprint = toprint .. k .. "= "
|
||||
end
|
||||
if (type(v) == "number") then
|
||||
toprint = toprint .. v .. ",\r\n"
|
||||
elseif (type(v) == "string") then
|
||||
toprint = toprint .. "\"" .. v .. "\",\r\n"
|
||||
elseif (type(v) == "table") then
|
||||
toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n"
|
||||
else
|
||||
toprint = toprint .. "\"" .. tostring(v) .. "\",\r\n"
|
||||
end
|
||||
end
|
||||
toprint = toprint .. string.rep(" ", indent-2) .. "}"
|
||||
return toprint
|
||||
function M.tprint(tbl, indent)
|
||||
if not indent then
|
||||
indent = 0
|
||||
end
|
||||
local toprint = string.rep(" ", indent) .. "{\r\n"
|
||||
indent = indent + 2
|
||||
for k, v in pairs(tbl) do
|
||||
toprint = toprint .. string.rep(" ", indent)
|
||||
if type(k) == "number" then
|
||||
toprint = toprint .. "[" .. k .. "] = "
|
||||
elseif type(k) == "string" then
|
||||
toprint = toprint .. k .. "= "
|
||||
end
|
||||
if type(v) == "number" then
|
||||
toprint = toprint .. v .. ",\r\n"
|
||||
elseif type(v) == "string" then
|
||||
toprint = toprint .. '"' .. v .. '",\r\n'
|
||||
elseif type(v) == "table" then
|
||||
toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n"
|
||||
else
|
||||
toprint = toprint .. '"' .. tostring(v) .. '",\r\n'
|
||||
end
|
||||
end
|
||||
toprint = toprint .. string.rep(" ", indent - 2) .. "}"
|
||||
return toprint
|
||||
end
|
||||
|
||||
function M.log(message)
|
||||
local log_file_path = vim.fn.expand('$HOME/nvim.log')
|
||||
local log_file = io.open(log_file_path, "a")
|
||||
io.output(log_file)
|
||||
io.write(message.."\n")
|
||||
io.close(log_file)
|
||||
local log_file_path = vim.fn.expand("$HOME/nvim.log")
|
||||
local log_file = io.open(log_file_path, "a")
|
||||
io.output(log_file)
|
||||
io.write(message .. "\n")
|
||||
io.close(log_file)
|
||||
end
|
||||
|
||||
function M.TableConcat(t1, t2)
|
||||
for i = 1, #t2 do
|
||||
t1[#t1 + 1] = t2[i]
|
||||
end
|
||||
return t1
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user