Closed ayamir closed 1 day ago
Agreed, but how can we generalize that given no specific Document Capability is assigned to this feature? For instance, I personally found lsp-signature
extremely useful when dealing with Apple's CoreFoundation stuff:
#import <CoreFoundation/CoreFoundation.h>
#import <CoreServices/CoreServices.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
NSString* bundleIdentifierForApplicationName(NSString* appName)
{
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSString* appPath = [workspace fullPathForApplication:appName];
if (appPath) {
NSBundle* appBundle = [NSBundle bundleWithPath:appPath];
return [appBundle bundleIdentifier];
}
return nil;
}
int main(void)
{
CFStringRef unixExecutableContentType = (CFStringRef) @"public.unix-executable";
CFStringRef unixHandler = LSCopyDefaultRoleHandlerForContentType(unixExecutableContentType, kLSRolesAll);
if (unixHandler == NULL) {
NSLog(@"No default handler found for '%@'", unixExecutableContentType);
}
/* handlerBundleId == unixHandler */
NSString* handlerBundleId = (__bridge NSString*) unixHandler;
NSString* kittyBundleId = bundleIdentifierForApplicationName(@"kitty");
NSLog(@"kitty %s the default handler for '%@'", [handlerBundleId isEqualToString:kittyBundleId] ? "is" : "is not",
unixExecutableContentType);
if (unixHandler) {
CFRelease(unixHandler);
}
}
Functions like LSCopyDefaultRoleHandlerForContentType
usually don't provide much information if we only look at their signatures:
LSCopyDefaultRoleHandlerForContentType(CFStringRef _Nonnull inContentType, LSRolesMask inRole) -> CFStringRef _Nullable
Only when the relevant discussion is included does it become easy to use, without needing to open Apple's documentation website (which is conveniently included in lsp-signature
's floating window):
→ CFStringRef _Nullable (aka const struct __CFString *)
Parameters:
- CFStringRef _Nonnull inContentType (aka const struct __CFString *)
- LSRolesMask inRole (aka enum LSRolesMask)
@discussion Returns the application bundle identifier of the default handler for the specified content type (UTI), in the specified role(s).
For any role, specify kLSRolesAll. Returns NULL if no handler is available.
@param inContentType a string UTI type identifier
@param inRole a LSRole
@result an application bundle identifier which is the default handler for the given type and role, or NULL if there is no default handler
I have no idea about to how implement it in a cheap way, i.e., check placeholder whether enabled for a lsp and disable lsp-signature
dynamically, so maybe just leave the freedom to disable it or not for user is better.
Feature description
For the lsp supporting placeholder like
gopls
andclangd
,lsp-signature
is redundant and blocks the view of other lines of code.Additional information