Commit b2f26495 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

always default to some local settings.json file for user settings

parent bd6cb9a5
......@@ -34,6 +34,7 @@
#include <KSharedConfig>
#include <QDir>
#include <QStandardPaths>
static const QString CONFIG_LSPCLIENT {QStringLiteral("lspclient")};
static const QString CONFIG_SYMBOL_DETAILS {QStringLiteral("SymbolDetails")};
......@@ -55,7 +56,11 @@ K_PLUGIN_FACTORY_WITH_JSON(LSPClientPluginFactory, "lspclientplugin.json", regis
LSPClientPlugin::LSPClientPlugin(QObject *parent, const QList<QVariant> &)
: KTextEditor::Plugin(parent)
, m_settingsPath(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + QStringLiteral("/lsp"))
{
// ensure settings path exist, for e.g. local settings.json
QDir().mkpath(m_settingsPath);
/**
* handle plugin verbosity
* the m_debugMode will be used to e.g. set debug level for started clangd, too
......@@ -111,6 +116,11 @@ void LSPClientPlugin::readConfig()
m_configPath = config.readEntry(CONFIG_SERVER_CONFIG, QUrl());
m_semanticHighlighting = config.readEntry(CONFIG_SEMANTIC_HIGHLIGHTING, false);
// ensure we default to the default local config path for server config
if (m_configPath.isEmpty()) {
m_configPath = QUrl::fromLocalFile(m_settingsPath + QStringLiteral("/settings.json"));
}
emit update();
}
......
......@@ -47,6 +47,9 @@ public:
void readConfig();
void writeConfig() const;
// path for local setting files, auto-created on load
const QString m_settingsPath;
// settings
bool m_symbolDetails;
bool m_symbolExpand;
......
......@@ -599,9 +599,9 @@ private:
Q_ASSERT(defaultConfigFile.isOpen());
m_serverConfig = QJsonDocument::fromJson(defaultConfigFile.readAll()).object();
// consider specified configuration
// consider specified configuration if existing
const auto &configPath = m_plugin->m_configPath.path();
if (!configPath.isEmpty()) {
if (!configPath.isEmpty() && QFile::exists(configPath)) {
QFile f(configPath);
if (f.open(QIODevice::ReadOnly)) {
auto data = f.readAll();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>556</width>
<height>528</height>
<width>758</width>
<height>907</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
......@@ -24,143 +24,181 @@
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Symbol Outline Options</string>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chkSymbolDetails">
<property name="text">
<string>Display symbol details</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSymbolTree">
<property name="text">
<string>Tree mode outline</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSymbolExpand">
<property name="text">
<string>Automatically expand nodes in tree mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSymbolSort">
<property name="text">
<string>Sort symbols alphabetically</string>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Client</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>General Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="chkComplDoc">
<property name="text">
<string>Show selected completion documentation</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRefDeclaration">
<property name="text">
<string>Include declaration in references</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAutoHover">
<property name="text">
<string>Show hover information</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkOnTypeFormatting">
<property name="text">
<string>Format on typing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkIncrementalSync">
<property name="text">
<string>Incremental document synchronization</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSemanticHighlighting">
<property name="text">
<string>Enable semantic highlighting</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="chkDiagnostics">
<property name="text">
<string>Show diagnostics notifications</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDiagnosticsHighlight">
<property name="text">
<string>Add highlights</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDiagnosticsMark">
<property name="text">
<string>Add markers</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Symbol Outline Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chkSymbolDetails">
<property name="text">
<string>Display symbol details</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSymbolTree">
<property name="text">
<string>Tree mode outline</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSymbolExpand">
<property name="text">
<string>Automatically expand nodes in tree mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSymbolSort">
<property name="text">
<string>Sort symbols alphabetically</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Server</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Server Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="KUrlRequester" name="edtConfigPath"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>General Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="chkComplDoc">
<property name="text">
<string>Show selected completion documentation</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRefDeclaration">
<property name="text">
<string>Include declaration in references</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAutoHover">
<property name="text">
<string>Show hover information</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkOnTypeFormatting">
<property name="text">
<string>Format on typing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkIncrementalSync">
<property name="text">
<string>Incremental document synchronization</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSemanticHighlighting">
<property name="text">
<string>Enable semantic highlighting</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="chkDiagnostics">
<property name="text">
<string>Show diagnostics notifications</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDiagnosticsHighlight">
<property name="text">
<string>Add highlights</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDiagnosticsMark">
<property name="text">
<string>Add markers</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Server Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="KUrlRequester" name="edtConfigPath"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
......
......@@ -31,6 +31,12 @@
"url": "https://github.com/sourcegraph/go-langserver",
"highlightingModeRegex": "^Go$"
},
"haskell": {
"command": ["hie-wrapper"],
"rootIndicationFileNames": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml"],
"url": "https://github.com/haskell/haskell-ide-engine",
"highlightingModeRegex": "^Haskell$"
},
"javascript": {
"command": ["javascript-typescript-stdio"],
"commandDebug": ["javascript-typescript-stdio", "-t"],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment