Add prettier formatting to tsserver-attached buffers.
parent
8947e1d2b9
commit
1055847812
|
@ -1,12 +1,21 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
nodePackages.prettier
|
||||
nodePackages.typescript-language-server
|
||||
];
|
||||
|
||||
programs.neovim = {
|
||||
nvim-lspconfig = ''
|
||||
require('init.lsp').setup(require('lspconfig').tsserver) {}
|
||||
require('init.lsp').setup(require('lspconfig').tsserver) {
|
||||
on_attach = function(client, bufnr)
|
||||
require('init.lsp').on_attach(client, bufnr)
|
||||
-- Override the default formatter in typescript-language-server.
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', "<CMD>PrettierAsync<CR>", {
|
||||
silent = true,
|
||||
})
|
||||
end,
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ let
|
|||
"mfussenegger/nvim-dap";
|
||||
config = ''
|
||||
require('dap').defaults.fallback.terminal_win_cmd = 'below 10split new'
|
||||
${config.programs.neovim.nvim-dap};
|
||||
${config.programs.neovim.nvim-dap}
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -123,6 +123,7 @@ in
|
|||
pkgs.vimPlugins.cmp_luasnip
|
||||
pkgs.vimPlugins.luasnip
|
||||
pkgs.vimPlugins.nvim-web-devicons
|
||||
pkgs.vimPlugins.vim-prettier
|
||||
];
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local M = {}
|
||||
|
||||
local function on_attach(client, bufnr)
|
||||
function M.on_attach(client, bufnr)
|
||||
local function set_nnoremap(key, func)
|
||||
vim.keymap.set('n', key, func, { buffer = bufnr })
|
||||
end
|
||||
|
@ -12,14 +12,14 @@ local function on_attach(client, bufnr)
|
|||
set_nnoremap('gr', vim.lsp.buf.rename)
|
||||
end
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
M.capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
function M.setup(client)
|
||||
-- Return a nested function so that we can continue invoking `setup` in the
|
||||
-- familiar way.
|
||||
return function(opts)
|
||||
opts.on_attach = opts.on_attach or on_attach
|
||||
opts.cabailities = opts.cabailities or capabilities
|
||||
opts.on_attach = opts.on_attach or M.on_attach
|
||||
opts.cabailities = opts.cabailities or M.capabilities
|
||||
client.setup(opts)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue