question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to confirm proper configuration

See original GitHub issue

Thank you for putting this together. Using “format on save” and the like is a big productivity gain for me. I’ve recently migrated to lsp… (like many). I’m still getting my “bearings”. I’m doing some work with css and html. I was using the online prettier parser and decided to see if I could get it running in nvim.

Prettierd is working (status running). I understand where the port and instance id are located to call it via a TCP request.

This said, in my nvim config I’m using the following documented snippet:

-- Prettier
local prettier = require("prettier")
prettier.setup({
    bin = 'prettierd', 
    formatCommand = 'prettierd "${INPUT}"',
    formatStdin = true,
    env = {string.format('PRETTIERD_DEFAULT_CONFIG=%s', vim.fn.expand('~/.config/nvim/utils/linter-config/.prettierrc.json'))},
    filetypes = {
        "css", "graphql", "html", "javascript", "javascriptreact", "json", "less", "markdown", "scss", "typescript", "typescriptreact", "yaml"
    },
})

As a “first go” I chose to use the null-ls plugin as an interface:

--
-- Linters and formatters that do not have an LSP interface; use null-ls to
-- bridge the gap.
local null_ls = require("null-ls")
require("null-ls").setup({
    capabilities = capabilities,
    on_attach = on_attach,
    sources = {
        null_ls.builtins.diagnostics.flake8, -- python
        null_ls.builtins.formatting.rustfmt, -- rust
        null_ls.builtins.formatting.brittany, -- haskell
        null_ls.builtins.diagnostics.yamllint, -- yaml
        null_ls.builtins.formatting.prettierd -- fast prettier
        -- null_ls.builtins.code_actions.eslint, -- html, css, js
    }
})

The nvim :checkhealth reports all is good with prettierd:

null-ls: require("null-ls.health").check()
========================================================================
  - ....
  - OK: yamllint: the command "yamllint" is executable.
  - OK: prettierd: the command "prettierd" is executable.

Yet, when I hit the <leader>f command, I don’t see the css “straighten-up” (i.e., clean-up the formatting).

The mapping is is used by many lsp:

    -- bind conditional on server capabilities
    if client.resolved_capabilities.document_formatting then
        buf_set_keymap('n', '<Leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
    elseif client.resolved_capabilities.document_range_formatting then
        buf_set_keymap('n', '<Leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
    end

Have I failed to “connect all the dots”? How can I tell that prettierd has been invoked when I call <leader>f?

Thanks in advance for any pointers.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
EdmundsEchocommented, Mar 20, 2022

Brilliant minds think alike. Here is the link to the prettier issue

0reactions
fsouzacommented, Mar 20, 2022

Oh interesting, do you have a link to the issue in the prettier repo? I can keep an eye on it and implement any option that they add in prettier.

If there’s a flag in prettier to skip the ignore file, we could eventually support it when #237 is resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved Standard security management practice is to test
Standard security management practice is to test security to confirm proper configuration, performance, and strength against attacks and exploits.
Read more >
How to Check Computer Configuration
How to Check Computer Configuration · 1. Click the Start button and then enter "system" into the search field. · 2. Click "System...
Read more >
Configuration Check - an overview | ScienceDirect Topics
Adapter Configuration Check the configuration of the network adapter. If any of the parameters are doubtful, make appropriate changes.
Read more >
How to determine proper SQL Server configuration settings
You can obtain high levels of performance by using good application and database design, and not by extensive configuration tuning. See the "References"...
Read more >
Using Logs to Verify Proper Configuration
Using Logs to Verify Proper Configuration · Select System Log/Monitoring. · Click the Events tab. · Click the Settings tab to display the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found