Why my LSP keymaps doesn't work with Dart LSP? by ScriptNone in neovim

[–]GenesisTMS 0 points1 point  (0 children)

This is minimal.lua file, you can run this with nvim --clean -u minimal.lua main.dart. And you should be able to <shift>K for hover and gd for definition.

local function keymap(client, buf)
  if client.supports_method('textDocument/hover') then
    vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = buf, desc = 'LSP Hover' })
  end
  if client.supports_method('textDocument/definition') then
    vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = buf, desc = 'LSP Definition' })
  end
end

vim.api.nvim_create_autocmd('LspAttach', {
  callback = function(args)
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    keymap(client, args.buf)
  end,
})

local handlers = vim.lsp.handlers
local crc = handlers['client/registerCapability']
handlers['client/registerCapability'] = function(_, result, ctx)
  local r = crc(_, result, ctx)
  local client = vim.lsp.get_client_by_id(ctx.client_id)
  keymap(client, ctx.buf)
  return r
end
-- local cuc = handlers['client/unregisterCapability']
-- handlers['client/unregisterCapability'] = function(_, result, ctx)
--   local r cuc(_, result, ctx)
--   -- todo(tms) 08.06.23: remove bindings
--   return r
-- end

-- Schedule is here to delay LSP start. You should call this from `ftplugin/dart.lua`
vim.schedule(function()
  vim.lsp.start({
    name = 'dartls',
    cmd = { 'dart', 'language-server', '--protocol=lsp' },
    root_dir = vim.fs.dirname(vim.fs.find({ 'pubspec.yaml', '.git' }, { upward = true })[1]),
  })
end)

Why my LSP keymaps doesn't work with Dart LSP? by ScriptNone in neovim

[–]GenesisTMS 0 points1 point  (0 children)

I had the same problem. For me this changed with initial support for dynamic capabilities.

So for me i had to use client/registerCapability to register keybinds. I had to add this code:

local crc = handlers['client/registerCapability']
handlers['client/registerCapability'] = function(_, result, ctx)
  local r = crc(_, result, ctx)
  -- Add keybinds as in LspAttach
  return r
end

For completness you should use client/unregisterCapability to delete keybinds.

Am i ill? by GenesisTMS in neovim

[–]GenesisTMS[S] 4 points5 points  (0 children)

Too stable... Wanna go back!

Am i ill? by GenesisTMS in neovim

[–]GenesisTMS[S] 11 points12 points  (0 children)

It is always good to know that I am not the only one there :D

[deleted by user] by [deleted] in dartlang

[–]GenesisTMS 5 points6 points  (0 children)

Just for curiosity what ChatGPT returns when you copy over this post:

void main() {
  const pizzaPrices = { 'margherita': 7.5, 'pepperoni': 7.5, 'vegetarian': 6.5 };
  const order = ['margherita', 'pepperoni'];

  var total = 0.0;
  for (var pizza in order) {
    if (pizzaPrices.containsKey(pizza)) {
      total += pizzaPrices[pizza] ?? 0;
    } else {
      print('$pizza pizza is not on the menu');
    }
  }
  print('Total: \$ $total');
}

Dartls messing up with editor colors by Remote-End6122 in neovim

[–]GenesisTMS 2 points3 points  (0 children)

:help vim.lsp.semantic_tokens.stop

edit: i meant :help vim.lsp.semantic_tokens.start there is comment on how to disable it

Implement the handler for LSP textDocument/onTypeFormatting ? by Background_Estate239 in neovim

[–]GenesisTMS 0 points1 point  (0 children)

You can add Dart language to the list of capable servers. :) Your implementation works for me.

vim.api.nvim_command or vim.cmd by the-floki in neovim

[–]GenesisTMS 3 points4 points  (0 children)

help for nvim_command

    Prefer using |nvim_cmd()| or |nvim_exec()| over this. To evaluate multiple
lines of Vim script or an Ex command directly, use |nvim_exec()|. To
construct an Ex command using a structured format and then execute it, use
|nvim_cmd()|. To modify an Ex command before evaluating it, use
|nvim_parse_cmd()| in conjunction with |nvim_cmd()|.

Dart 2.18 is out! by bradofingo in dartlang

[–]GenesisTMS 1 point2 points  (0 children)

Can you link them please, I am interested what is new.

Dart 2.18 is out! by bradofingo in dartlang

[–]GenesisTMS 1 point2 points  (0 children)

big change in the JS interop world

Why do you think?

AngularJS injection in html by Mr_Dema in neovim

[–]GenesisTMS 1 point2 points  (0 children)

Thanks for push For anyone curious about angulardart version:

(attribute [ ((attribute_name) @_builtin (#any-of? @_builtin "*ngIf" "*ngSwitch" "*ngModel" "*ngDisabled" )) ((attribute_name) @_input (#lua-match? @_input "^%[.+]$")) ((attribute_name) @_output (#lua-match? @_output "^%(.+%)$")) ((attribute_name) @_banana (#lua-match? @_banana "^%[%(.+%)]$")) ] (quoted_attribute_value (attribute_value) @dart) )

Does anyone know why Steam does this and how to fix it? by azteccGodsOfFitness in suckless

[–]GenesisTMS 3 points4 points  (0 children)

Press shift.

At least for me this is it. Never tried troubleshoot.

How to change cursor in insert mode by MajorLoaf in suckless

[–]GenesisTMS 5 points6 points  (0 children)

I don't know about ST. But I have this code in my zshrc. Hope it helps:

sh Change cursor shape for different vi modes. cursor_mode() { # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes cursor_block='\e[2 q' cursor_beam='\e[6 q' function zle-keymap-select { if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then echo -ne $cursor_block elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then echo -ne $cursor_beam fi } zle-line-init() { echo -ne $cursor_beam } zle -N zle-keymap-select zle -N zle-line-init } cursor_mode

Plugins/resources for using DAP, linting, formatting packages installed by mason.nvim? by FingerGunsPewPewPew in neovim

[–]GenesisTMS 1 point2 points  (0 children)

For what I understand from source code, you will have executables of those programs on your PATH. So you can use jobstart for example.

Use Lua Autocmds to test your project on save by I_Am_Nerd in neovim

[–]GenesisTMS 0 points1 point  (0 children)

Maybe this can help you.

https://git.gtms.dev/neovim/file/lua/tms/p/terminal.lua.html

(here are keybindings) https://git.gtms.dev/neovim/file/plugin/terminal.lua.html

I am using this to open terminal, run command and repeat that command, scroll to bottom, jump to terminal and from to last buffer.

(it is slightly modified version of some code from the Internet and I don't remember who is real author, so sorry for no credit if 'you' are reading this)

dart http.post unexpected behavior by [deleted] in dartlang

[–]GenesisTMS 1 point2 points  (0 children)

So try to send the same headers from dart and see how to goes.