Skip to content

Commit

Permalink
disable more nvim-lsp tsserver related, bring back prettier via efm i…
Browse files Browse the repository at this point in the history
…nstead of coc-prettier
  • Loading branch information
dotrakoun-clearstreet committed Sep 24, 2024
1 parent 9dc92bc commit bf681ed
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 71 deletions.
6 changes: 4 additions & 2 deletions nvim/lua/dko/plugins/colorscheme.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local dkosettings = require("dko.settings")

return {
{
"davidosomething/vim-colors-meh",
Expand All @@ -15,8 +17,8 @@ return {
lazy = false,
priority = 1000,
init = function()
require("dko.settings").set("colors.dark", "meh")
require("dko.settings").set("colors.light", "komau")
dkosettings.set("colors.dark", "meh")
dkosettings.set("colors.light", "komau")
end,
config = function()
vim.cmd.colorscheme("meh")
Expand Down
2 changes: 1 addition & 1 deletion nvim/lua/dko/plugins/fixes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return {
-- Disable cursorline when moving, for various perf reasons
{
"yamatsum/nvim-cursorline", -- replaces delphinus/auto-cursorline.nvim",
"yamatsum/nvim-cursorline", -- replaces delphinus/auto-cursorline.nvim
cond = #vim.api.nvim_list_uis() > 0,
config = function()
require("nvim-cursorline").setup({
Expand Down
43 changes: 23 additions & 20 deletions nvim/lua/dko/plugins/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local dkosettings = require("dko.settings")
local dkomappings = require("dko.mappings")
local uis = vim.api.nvim_list_uis()
local has_ui = #uis > 0

Expand All @@ -11,7 +12,8 @@ return {
buffer = { suffix = "", options = {} }, -- using cybu
comment = { suffix = "c", options = {} },
conflict = { suffix = "x", options = {} },
-- don't want diagnostic float focus, have in mappings.lua
-- don't want diagnostic float focus, have in mappings.lua with coc
-- support too
diagnostic = { suffix = "", options = {} },
file = { suffix = "f", options = {} },
indent = { suffix = "", options = {} }, -- confusing
Expand Down Expand Up @@ -48,6 +50,8 @@ return {
event = "VeryLazy",
},

-- Show diagnostic as virtual text at EOL
-- https://github.com/rachartier/tiny-inline-diagnostic.nvim
-- {
-- "rachartier/tiny-inline-diagnostic.nvim",
-- -- event = "VeryLazy",
Expand Down Expand Up @@ -100,7 +104,7 @@ return {
"nvim-tree/nvim-web-devicons",
"nvim-lua/plenary.nvim",
},
keys = vim.tbl_values(require("dko.mappings").cybu),
keys = vim.tbl_values(dkomappings.cybu),
config = function()
require("cybu").setup({
display_time = 500,
Expand All @@ -123,7 +127,7 @@ return {
"help",
},
})
require("dko.mappings").bind_cybu()
dkomappings.bind_cybu()
end,
},

Expand All @@ -133,7 +137,7 @@ return {
{
"troydm/zoomwintab.vim",
cond = has_ui,
keys = require("dko.mappings").zoomwintab,
keys = dkomappings.zoomwintab,
cmd = {
"ZoomWinTabIn",
"ZoomWinTabOut",
Expand All @@ -153,13 +157,14 @@ return {
},
},

-- <C-w> hjkl or <leader>w for picker
-- https://github.com/yorickpeterse/nvim-window
{
"yorickpeterse/nvim-window",
cond = has_ui,
config = function()
require("nvim-window").setup({})
require("dko.mappings").bind_nvim_window()
dkomappings.bind_nvim_window()
end,
},

Expand All @@ -176,7 +181,7 @@ return {

{
"akinsho/toggleterm.nvim",
keys = require("dko.mappings").toggleterm_all_keys,
keys = dkomappings.toggleterm_all_keys,
cmd = "ToggleTerm",
cond = has_ui,
config = function()
Expand All @@ -188,7 +193,7 @@ return {
-- the buffer terminal with the floating terminal
open_mapping = nil,
})
require("dko.mappings").bind_toggleterm()
dkomappings.bind_toggleterm()
end,
},

Expand All @@ -212,7 +217,7 @@ return {
cond = has_ui,
config = function()
require("gitsigns").setup({
on_attach = require("dko.mappings").bind_gitsigns,
on_attach = dkomappings.bind_gitsigns,
preview_config = {
border = dkosettings.get("border"),
},
Expand Down Expand Up @@ -241,11 +246,11 @@ return {
-- https://github.com/axieax/urlview.nvim
{
"axieax/urlview.nvim",
keys = vim.tbl_values(require("dko.mappings").urlview),
keys = vim.tbl_values(dkomappings.urlview),
cmd = "UrlView",
cond = has_ui,
config = function()
require("dko.mappings").bind_urlview()
dkomappings.bind_urlview()
end,
},

Expand Down Expand Up @@ -412,12 +417,10 @@ return {
)
return
end
require("Comment").setup(
require("dko.mappings").with_commentnvim_mappings({
-- add treesitter support, want tsx/jsx in particular
pre_hook = tscc_integration.create_pre_hook(),
})
)
require("Comment").setup(dkomappings.with_commentnvim_mappings({
-- add treesitter support, want tsx/jsx in particular
pre_hook = tscc_integration.create_pre_hook(),
}))
end,
},

Expand All @@ -428,13 +431,13 @@ return {
"nvim-treesitter/nvim-treesitter",
},
event = { "BufReadPost", "BufNewFile" },
keys = require("dko.mappings").trees,
keys = dkomappings.trees,
config = function()
require("treesj").setup({
use_default_keymaps = false,
max_join_length = 255,
})
require("dko.mappings").bind_treesj()
dkomappings.bind_treesj()
end,
},

Expand All @@ -455,7 +458,7 @@ return {
"mattn/vim-textobj-url",
},
config = function()
require("dko.mappings").bind_textobj()
dkomappings.bind_textobj()
end,
},

Expand All @@ -464,7 +467,7 @@ return {
cond = has_ui,
config = function()
require("various-textobjs").setup({ useDefaultKeymaps = false })
require("dko.mappings").bind_nvim_various_textobjs()
dkomappings.bind_nvim_various_textobjs()
end,
},
}
39 changes: 18 additions & 21 deletions nvim/lua/dko/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ return {
vim.g.coc_global_extensions = {
"coc-eslint",
"coc-json",
"coc-prettier",
"coc-tsserver",
}
end,
Expand Down Expand Up @@ -65,6 +64,7 @@ return {
-- https://github.com/aznhe21/actions-preview.nvim
{
"aznhe21/actions-preview.nvim",
enabled = dkosettings.get("lsp.code_action") == "actions-preview",
dependencies = {
"nvim-telescope/telescope.nvim",
},
Expand All @@ -75,15 +75,14 @@ return {
-- https://www.reddit.com/r/neovim/comments/1eaxity/rachartiertinycodeactionnvim_a_simple_way_to_run/
{
"rachartier/tiny-code-action.nvim",
enabled = dkosettings.get("lsp.code_action") == "tiny-code-action",
dependencies = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-telescope/telescope.nvim" },
},
event = "LspAttach",
config = function()
require("tiny-code-action").setup({
lsp_timeout = 4000,
})
require("tiny-code-action").setup({ lsp_timeout = 4000 })
end,
},

Expand Down Expand Up @@ -120,7 +119,7 @@ return {
config = function()
-- border on :LspInfo window
require("lspconfig.ui.windows").default_options.border =
require("dko.settings").get("border")
dkosettings.get("border")
end,
},

Expand All @@ -146,22 +145,20 @@ return {
-- end,
-- },

{
"davidosomething/format-ts-errors.nvim", -- extracted ts error formatter
dev = true,
lazy = true,
},
-- {
-- "davidosomething/format-ts-errors.nvim", -- extracted ts error formatter
-- dev = true,
-- lazy = true,
-- },

-- https://github.com/marilari88/twoslash-queries.nvim
{
"marilari88/twoslash-queries.nvim",
cond = has_ui,
config = function()
require("twoslash-queries").setup({
multi_line = true,
})
end,
},
-- {
-- "marilari88/twoslash-queries.nvim",
-- cond = has_ui,
-- config = function()
-- require("twoslash-queries").setup({ multi_line = true })
-- end,
-- },

{
"hrsh7th/cmp-nvim-lsp", -- provides some capabilities
Expand All @@ -184,8 +181,8 @@ return {

-- @TODO move these somewhere else
"b0o/schemastore.nvim", -- wait for schemastore for jsonls
"davidosomething/format-ts-errors.nvim", -- extracted ts error formatter
"marilari88/twoslash-queries.nvim", -- ts_ls comment with ^? comment
-- "davidosomething/format-ts-errors.nvim", -- extracted ts error formatter
-- "marilari88/twoslash-queries.nvim", -- ts_ls comment with ^? comment
},
config = function()
local lspconfig = require("lspconfig")
Expand Down
2 changes: 1 addition & 1 deletion nvim/lua/dko/plugins/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ return {
-- local markview = require("markview")
-- local presets = require("markview.presets")
-- markview.setup({
-- -- headings color bg only, no icon no conceal content
-- -- headings color bg only. no icon no conceal content
-- headings = presets.headings.simple,
-- list_items = { enable = false },
-- tables = { block_decorator = false },
Expand Down
5 changes: 4 additions & 1 deletion nvim/lua/dko/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ local uis = vim.api.nvim_list_uis()
local has_ui = #uis > 0

return {

-- find nerd font glyphs
-- https://github.com/2KAbhishek/nerdy.nvim
{
"2kabhishek/nerdy.nvim",
cmd = "Nerdy",
dependencies = {
"stevearc/dressing.nvim",
"nvim-telescope/telescope.nvim",
},
cmd = "Nerdy",
},

{
Expand Down
4 changes: 2 additions & 2 deletions nvim/lua/dko/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ local settings = {
lsp = {
-- Which code action UI should we try first?
-- The alternative will be tried second
--code_action = "tiny-code-action",
code_action = "actions-preview",
code_action = "tiny-code-action",
-- code_action = "actions-preview",
},
}

Expand Down
44 changes: 21 additions & 23 deletions nvim/lua/dko/utils/format/javascript.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
local dkosettings = require("dko.settings")
local dkonode = require("dko.utils.node")

function format_with_coc(notify)
local function format_with_coc(notify)
local eslint_only = vim.b.has_eslint_plugin_prettier
notify(
eslint_only and { "coc-eslint with eslint-plugin-prettier" }
or { "coc-eslint" }
)
vim.cmd.call("CocAction('runCommand', 'eslint.executeAutofix')")
vim.cmd.sleep(eslint_only and "250m" or "1m")

if not eslint_only then
notify({ "coc-prettier" })
vim.cmd.call("CocAction('runCommand', 'prettier.formatFile')")
vim.cmd.sleep("250m")
end
vim.cmd.sleep(eslint_only and "100m" or "1m")
end

function format_with_lsp(notify)
local function format_with_lsp(notify)
local eslint_only = vim.b.has_eslint_plugin_prettier

-- eslint-lsp
vim.b.has_eslint = vim.b.has_eslint
or #vim.lsp.get_clients({ bufnr = 0, name = "eslint" }) > 0
if vim.b.has_eslint then
if #vim.lsp.get_clients({ bufnr = 0, name = "eslint" }) > 0 then
vim.cmd.EslintFixAll()
notify(eslint_only and { "eslint-plugin-prettier" } or { "eslint" })
return
end
notify("eslint-lsp not found")
end

return function(notify)
if vim.b.has_eslint_plugin_prettier == nil then
vim.b.has_eslint_plugin_prettier = dkonode.has_eslint_plugin("prettier")
end

if not eslint_only then
-- Run eslint via coc or nvim-lsp eslint-lsp
if dkosettings.get("coc.enabled") then
format_with_coc(notify)
else
format_with_lsp(notify)
end

-- Finally, run prettier via efm
if not vim.b.has_eslint_plugin_prettier then
local did_efm_format =
require("dko.utils.format.efm").format({ pipeline = "javascript" })
if not did_efm_format then
Expand All @@ -38,11 +44,3 @@ function format_with_lsp(notify)
end
end
end

return function(notify)
if vim.b.has_eslint_plugin_prettier == nil then
vim.b.has_eslint_plugin_prettier = dkonode.has_eslint_plugin("prettier")
end
return dkosettings.get("coc.enabled") and format_with_coc(notify)
or format_with_lsp(notify)
end

0 comments on commit bf681ed

Please sign in to comment.