changes to lsp regarding deno and tsserver
This commit is contained in:
parent
e87724e019
commit
fa7cf6ee09
@ -39,4 +39,4 @@ require "user.zk"
|
||||
require "user.tabout"
|
||||
require "user.cybu"
|
||||
require "user.dap"
|
||||
require "user.noice"
|
||||
-- require "user.noice"
|
||||
|
||||
@ -82,5 +82,5 @@ vim.cmd [[autocmd VimLeave *.tex !texclear %]]
|
||||
|
||||
-- Run install when editing my scripts
|
||||
vim.cmd [[
|
||||
autocmd BufWritePost ~/repos/inks-scripts/** !~/repos/inks-scripts/install
|
||||
autocmd BufWritePost ~/repos/inks-scripts/scripts/** !~/repos/inks-scripts/install
|
||||
]]
|
||||
|
||||
@ -82,7 +82,7 @@ local function attach_navic(client, bufnr)
|
||||
vim.g.navic_silence = false
|
||||
local status_ok, navic = pcall(require, "nvim-navic")
|
||||
if not status_ok then
|
||||
print"nvim-navic error!"
|
||||
print("nvim-navic error!")
|
||||
return
|
||||
end
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
@ -90,30 +90,35 @@ local function attach_navic(client, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
local function lsp_keymaps(bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>Telescope lsp_declarations<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", "gI", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>Telescope lsp_references<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<M-f>", "<cmd>Format<cr>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<M-a>", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<M-s>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<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>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
||||
-- vim.cmd [[ command! Format execute 'lua vim.lsp.buf.format({ async = true })' ]]
|
||||
local function disable_deno_formatting(client)
|
||||
if client.name == "denols" then
|
||||
require("null-ls").disable({ "prettier" })
|
||||
end
|
||||
end
|
||||
|
||||
local function resolve_tsserver_deno(client)
|
||||
local active_clients = vim.lsp.get_active_clients()
|
||||
if client.name == "denols" then
|
||||
for _, client_ in pairs(active_clients) do
|
||||
-- stop tsserver if denols is already active
|
||||
if client_.name == "tsserver" then
|
||||
client_.stop()
|
||||
end
|
||||
end
|
||||
elseif client.name == "tsserver" then
|
||||
for _, client_ in pairs(active_clients) do
|
||||
-- prevent tsserver from starting if denols is already active
|
||||
if client_.name == "denols" then
|
||||
client.stop()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.on_attach = function(client, bufnr)
|
||||
lsp_keymaps(bufnr)
|
||||
attach_navic(client, bufnr)
|
||||
disable_deno_formatting(client)
|
||||
resolve_tsserver_deno(client)
|
||||
end
|
||||
|
||||
function M.enable_format_on_save()
|
||||
|
||||
@ -18,6 +18,7 @@ local servers = {
|
||||
"sumneko_lua",
|
||||
"omnisharp",
|
||||
"tflint",
|
||||
"denols",
|
||||
"terraformls",
|
||||
"tsserver",
|
||||
"pyright",
|
||||
@ -73,7 +74,7 @@ for _, server in pairs(servers) do
|
||||
capabilities = require("user.lsp.handlers").capabilities,
|
||||
}
|
||||
|
||||
server = vim.split(server, "@")[1]
|
||||
server = vim.split(server, "@", {})[1]
|
||||
|
||||
if server == "yamlls" then
|
||||
local yamlls_opts = require("user.lsp.settings.yamlls")
|
||||
@ -92,11 +93,6 @@ for _, server in pairs(servers) do
|
||||
opts = vim.tbl_deep_extend("force", tsserver_opts, opts)
|
||||
end
|
||||
|
||||
if server == "pyright" then
|
||||
local pyright_opts = require("user.lsp.settings.pyright")
|
||||
opts = vim.tbl_deep_extend("force", pyright_opts, opts)
|
||||
end
|
||||
|
||||
if server == "solc" then
|
||||
local solc_opts = require("user.lsp.settings.solc")
|
||||
opts = vim.tbl_deep_extend("force", solc_opts, opts)
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
return {
|
||||
cmd = { "pyright" },
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = "basic",
|
||||
diagnosticMode = "workspace",
|
||||
inlayHints = {
|
||||
variableTypes = true,
|
||||
functionReturnTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -46,7 +46,7 @@ return packer.startup(function(use)
|
||||
use("wbthomason/packer.nvim") -- Have packer manage inself
|
||||
|
||||
-- Noice :D
|
||||
use("folke/noice.nvim") -- magic by folke.
|
||||
-- use("folke/noice.nvim") -- magic by folke.
|
||||
|
||||
-- Lua Development
|
||||
use("nvim-lua/plenary.nvim") -- useful lua functions
|
||||
@ -66,10 +66,6 @@ return packer.startup(function(use)
|
||||
use({ -- I'm currently just using this for a functional code action menu for omnisharp, I want to look further into its functions though.
|
||||
"glepnir/lspsaga.nvim",
|
||||
branch = "main",
|
||||
config = function ()
|
||||
local saga = require"lspsaga"
|
||||
saga.init_lsp_saga({})
|
||||
end,
|
||||
})
|
||||
use("jose-elias-alvarez/null-ls.nvim")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user