diff --git a/documentation/content/en/articles/freebsd-src-lsp/_index.adoc b/documentation/content/en/articles/freebsd-src-lsp/_index.adoc index ac916d756e..8320e25df3 100644 --- a/documentation/content/en/articles/freebsd-src-lsp/_index.adoc +++ b/documentation/content/en/articles/freebsd-src-lsp/_index.adoc @@ -1,289 +1,289 @@ --- title: Use Language Servers for Development in the FreeBSD Src Tree authors: - author: Ka Ho Ng email: khng@FreeBSD.org copyright: 2021 The FreeBSD Foundation description: Use Language Servers for development in the FreeBSD src tree to get precise go-to-definition and completion results. trademarks: ["freebsd"] tags: ["FreeBSD", "Language Server", "LSP"] --- = Use Language Servers for Development in the FreeBSD Src Tree :doctype: article :toc: macro :toclevels: 1 :icons: font :sectnums: :sectnumlevels: 6 :source-highlighter: rouge :experimental: :images-path: articles/freebsd-src-lsp/ ifdef::env-beastie[] ifdef::backend-html5[] include::shared/authors.adoc[] include::shared/mirrors.adoc[] include::shared/releases.adoc[] include::shared/attributes/attributes-{{% lang %}}.adoc[] include::shared/{{% lang %}}/teams.adoc[] include::shared/{{% lang %}}/mailing-lists.adoc[] include::shared/{{% lang %}}/urls.adoc[] :imagesdir: ../../../images/{images-path} endif::[] ifdef::backend-pdf,backend-epub3[] include::../../../../shared/asciidoctor.adoc[] endif::[] endif::[] ifndef::env-beastie[] include::../../../../../shared/asciidoctor.adoc[] endif::[] toc::[] [[intro]] == Introduction This guide is about setting up a FreeBSD src tree with language servers performing source code indexing. The guide describes the steps for Vim/NeoVim and VSCode. If you use a different text editor you can use this guide as a reference and search the equivalent commands for your preferred editor. [[requirements]] == Requirements In order to follow this guide we need to install certain requirements. We need a Language server, `ccls` or `clangd`, and optionally a compilation database. The installation of the Language server can be performed via `pkg` or via ports. If we chose `clangd` we need to install `llvm`. Using `pkg` to install `ccls`: [source,shell] .... # pkg install ccls .... If we want to use `clangd` we need to install `llvm` (The example command uses `llvm15` but choose the version you desire): [source,shell] .... # pkg install llvm15 .... To install via ports choose a favorite combination of tools from each category below: * Language server implementations ** package:devel/ccls[] ** package:devel/llvm12[] (Other versions are okay, but newer is better. Replace `clangd12` with clangdN in case other versions are used.) * Editors ** package:editors/vim[] ** package:editors/neovim[] ** package:editors/vscode[] * Compilation database generator ** package:devel/python[] (For llvm's scan-build-py implementation) ** package:devel/py-pip[] (For rizsotto's scan-build implementation) ** package:devel/bear[] [[editor-settings]] == Editor settings [[settings-vim]] === Vim/Neovim ==== LSP client plugins The built-in plugin manager is used for both editors in this example. The LSP client plugin used is link:https://github.com/prabirshrestha/vim-lsp[prabirshrestha/vim-lsp]. To set up the LSP client plugin for Neovim: [source,shell] .... # mkdir -p ~/.config/nvim/pack/lsp/start # git clone https://github.com/prabirshrestha/vim-lsp ~/.config/nvim/pack/lsp/start/vim-lsp .... and for Vim: [source,shell] .... # mkdir -p ~/.vim/pack/lsp/start # git clone https://github.com/prabirshrestha/vim-lsp ~/.vim/pack/lsp/start/vim-lsp .... To enable the LSP client plugin in the editor, add the following snippet into [.filepath]#~/.config/nvim/init.vim# when using Neovim, or [.filepath]#~/.vim/vimrc# when using Vim: .For ccls [source,vim] .... au User lsp_setup call lsp#register_server({ \ 'name': 'ccls', \ 'cmd': {server_info->['ccls']}, \ 'allowlist': ['c', 'cpp', 'objc'], \ 'initialization_options': { \ 'cache': { \ 'hierarchicalPath': v:true \ } \ }}) .... .For clangd [source,vim] .... au User lsp_setup call lsp#register_server({ \ 'name': 'clangd', \ 'cmd': {server_info->['clangd15', '--background-index', '--header-insertion=never']}, \ 'allowlist': ['c', 'cpp', 'objc'], \ 'initialization_options': {}, \ }) .... Depending on the version that you installed for `clangd` you might need to update the `server-info` to point to the correct binary. Please refer to link:https://github.com/prabirshrestha/vim-lsp/blob/master/README.md#registering-servers[] to learn about setting up key bindings and code completion. The official site of clangd is link:https://clangd.llvm.org[], and the repository link of ccls is link:https://github.com/MaskRay/ccls/[]. Below are the reference settings of keybindings and code completions. Put the following snippet into [.filepath]#~/.config/nvim/init.vim#, or [.filepath]#~/.vim/vimrc# for Vim users to use it: [source,vim] .... function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal completeopt-=preview setlocal keywordprg=:LspHover nmap (lsp-definition) nmap ] (lsp-peek-definition) nmap (lsp-peek-definition) nmap gr (lsp-references) nmap (lsp-next-reference) nmap (lsp-previous-reference) nmap gI (lsp-implementation) nmap go (lsp-document-symbol) nmap gS (lsp-workspace-symbol) nmap ga (lsp-code-action) nmap gR (lsp-rename) nmap gm (lsp-signature-help) endfunction augroup lsp_install au! autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END .... [[settings-vscode]] === VSCode ==== LSP client plugins LSP client plugins are required to launch the language server daemon. Press `Ctrl+Shift+X` to show the extension online search panel. Enter `llvm-vs-code-extensions.vscode-clangd` when running clangd, or `ccls-project.ccls` when running ccls. Then, press `Ctrl+Shift+P` to show the editor commands palette. Enter `Preferences: Open Settings (JSON)` into the palette and hit `Enter` to open [.filepath]#settings.json#. Depending on the language server implementations, put one of the following JSON key/value pairs in [.filepath]#settings.json#: .For clangd [source,json] .... [ /* Begin of your existing configurations */ ... /* End of your existing configurations */ "clangd.arguments": [ "--background-index", "--header-insertion=never" ], "clangd.path": "clangd12" ] .... .For ccls [source,json] .... [ /* Begin of your existing configurations */ ... /* End of your existing configurations */ "ccls.cache.hierarchicalPath": true ] .... [[cdb]] == Compilation database A Compilation database contains an array of compile command objects. Each object specifies a way of compiling a source file. -The compilation database file is usually [.filename]#compiler_commands.json#. +The compilation database file is usually [.filename]#compile_commands.json#. The database is used by language server implementations for indexing purpose. Please refer to link:https://clang.llvm.org/docs/JSONCompilationDatabase.html#format[] for details on the format of the compilation database file. [[cdb-generators]] === Generators [[generators-scan-build-py]] ==== Using scan-build-py ===== Installation `intercept-build` tool from scan-build-py is used to generate compilation database. Install package:devel/python[] to get python interpreter first. To get `intercept-build` from LLVM: [source,shell] .... # git clone https://github.com/llvm/llvm-project /path/to/llvm-project .... where [.filename]#/path/to/llvm-project/# is your desired path for the repository. Make an alias in the shell configuration file for convenience: [source,shell] .... alias intercept-build='/path/to/llvm-project/clang/tools/scan-build-py/bin/intercept-build' .... link:https://github.com/rizsotto/scan-build[rizsotto/scan-build] can be used instead of LLVM's scan-build-py. The LLVM's scan-build-py was rizsotto/scan-build merged into the LLVM tree. This implementation can be installed by `pip install --user scan-build`. The `intercept-build` script is in [.filename]#~/.local/bin# by default. ===== Usage In the top-level directory of the FreeBSD src tree, generate the compilation database with `intercept-build`: [source,shell] .... # intercept-build --append make buildworld buildkernel -j`sysctl -n hw.ncpu` .... The `--append` flag tells the `intercept-build` to read an existing compilation database (if a compilation database exists) and append the results to the database. Entries with duplicated command keys are merged. -The generated compilation database by default is saved in the current working directory as [.filename]#compiler_commands.json#. +The generated compilation database by default is saved in the current working directory as [.filename]#compile_commands.json#. [[generators-bear]] ==== Using devel/bear ===== Usage In the top-level directory of the FreeBSD src tree, to generate compilation database with `bear`: [source,shell] .... # bear --append -- make buildworld buildkernel -j`sysctl -n hw.ncpu` .... The `--append` flag tells `bear` to read an existing compilation database if it is present, and append the results to the database. Entries with duplicated command key are merged. -The generated compilation database by default is saved in the current working directory as [.filename]#compiler_commands.json#. +The generated compilation database by default is saved in the current working directory as [.filename]#compile_commands.json#. [[final]] == Final Once the compilation database is generated, open any source files in the FreeBSD src tree and LSP server daemon will be launched as well in background. Opening source files in the src tree for the first time takes significantly longer time before the LSP server is able to give a complete result, due to initial background indexing by the LSP server compiling all the listed entries in the compilation database. The language server daemon however does not index the source files not appearing in the compilation database, thus no complete results are shown on source files not being compiled during the `make`. diff --git a/documentation/content/en/articles/freebsd-src-lsp/_index.po b/documentation/content/en/articles/freebsd-src-lsp/_index.po index 7293a4afc5..206926dae4 100644 --- a/documentation/content/en/articles/freebsd-src-lsp/_index.po +++ b/documentation/content/en/articles/freebsd-src-lsp/_index.po @@ -1,487 +1,487 @@ # SOME DESCRIPTIVE TITLE # Copyright (C) YEAR The FreeBSD Project # This file is distributed under the same license as the FreeBSD Documentation package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: FreeBSD Documentation VERSION\n" "POT-Creation-Date: 2022-07-07 23:23-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: YAML Front Matter: description #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:1 #, no-wrap msgid "Use Language Servers for development in the FreeBSD src tree to get precise go-to-definition and completion results." msgstr "" #. type: Title = #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:1 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:13 #, no-wrap msgid "Use Language Servers for Development in the FreeBSD Src Tree" msgstr "" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:47 #, no-wrap msgid "Introduction" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:50 msgid "" "This guide is about setting up a FreeBSD src tree with language servers " "performing source code indexing." msgstr "" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:52 #, no-wrap msgid "Required Ports" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:56 msgid "" "Some ports are required throughout the guide. Choose a favorite combination " "of tools from each category below:" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:58 msgid "Language server implementations" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:59 msgid "package:devel/ccls[]" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:60 msgid "" "package:devel/llvm12[] (Other versions are okay, but newer is better. " "Replace `clangd12` with clangdN in case other versions are used.)" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:61 msgid "Editors" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:62 msgid "package:editors/vim[]" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:63 msgid "package:editors/neovim[]" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:64 msgid "package:editors/vscode[]" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:65 msgid "Compilation database generator" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:66 msgid "package:devel/python[] (For llvm's scan-build-py implementation)" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:67 msgid "package:devel/py-pip[] (For rizsotto's scan-build implementation)" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:68 msgid "package:devel/bear[]" msgstr "" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:70 #, no-wrap msgid "Editor settings" msgstr "" #. type: Title === #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:73 #, no-wrap msgid "Vim/Neovim" msgstr "" #. type: Title ==== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:75 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:159 #, no-wrap msgid "LSP client plugins" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:79 msgid "" "The built-in plugin manager is used for both editors in this example. The " "LSP client plugin used is link:https://github.com/prabirshrestha/vim-" "lsp[prabirshrestha/vim-lsp]." msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:81 msgid "To set up the LSP client plugin for Neovim:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:86 #, no-wrap msgid "" "# mkdir -p ~/.config/nvim/pack/lsp/start\n" "# git clone https://github.com/prabirshrestha/vim-lsp ~/.config/nvim/pack/lsp/start/vim-lsp\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:89 msgid "and for Vim:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:94 #, no-wrap msgid "" "# mkdir -p ~/.vim/pack/lsp/start\n" "# git clone https://github.com/prabirshrestha/vim-lsp ~/.vim/pack/lsp/start/vim-lsp\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:97 msgid "" "To enable the LSP client plugin in the editor, add the following snippet " "into [.filepath]#~/.config/nvim/init.vim# when using Neovim, or [." "filepath]#~/.vim/vimrc# when using Vim:" msgstr "" #. type: Block title #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:98 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:184 #, no-wrap msgid "For ccls" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:110 #, no-wrap msgid "" "au User lsp_setup call lsp#register_server({\n" " \\ 'name': 'ccls',\n" " \\ 'cmd': {server_info->['ccls']},\n" " \\ 'allowlist': ['c', 'cpp', 'objc'],\n" " \\ 'initialization_options': {\n" " \\ 'cache': {\n" " \\ 'hierarchicalPath': v:true\n" " \\ }\n" " \\ }})\n" msgstr "" #. type: Block title #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:112 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:169 #, no-wrap msgid "For clangd" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:121 #, no-wrap msgid "" "au User lsp_setup call lsp#register_server({\n" " \\ 'name': 'clangd',\n" " \\ 'cmd': {server_info->['clangd12', '--background-index', '--header-insertion=never']},\n" " \\ 'allowlist': ['c', 'cpp', 'objc'],\n" " \\ 'initialization_options': {},\n" " \\ })\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:125 msgid "" "Please refer to link:https://github.com/prabirshrestha/vim-lsp/blob/master/" "README.md#registering-servers[] to learn about setting up key bindings and " "code completion. The official site of clangd is link:https://clangd.llvm." "org[], and the repository link of ccls is link:https://github.com/MaskRay/" "ccls/[]." msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:128 msgid "" "Below are the reference settings of keybindings and code completions. Put " "the following snippet into [.filepath]#~/.config/nvim/init.vim#, or [." "filepath]#~/.vim/vimrc# for Vim users to use it:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:135 #, no-wrap msgid "" "function! s:on_lsp_buffer_enabled() abort\n" " setlocal omnifunc=lsp#complete\n" " setlocal completeopt-=preview\n" " setlocal keywordprg=:LspHover\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:149 #, no-wrap msgid "" " nmap (lsp-definition)\n" " nmap ] (lsp-peek-definition)\n" " nmap (lsp-peek-definition)\n" " nmap gr (lsp-references)\n" " nmap (lsp-next-reference)\n" " nmap (lsp-previous-reference)\n" " nmap gI (lsp-implementation)\n" " nmap go (lsp-document-symbol)\n" " nmap gS (lsp-workspace-symbol)\n" " nmap ga (lsp-code-action)\n" " nmap gR (lsp-rename)\n" " nmap gm (lsp-signature-help)\n" "endfunction\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:154 #, no-wrap msgid "" "augroup lsp_install\n" " au!\n" " autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()\n" "augroup END\n" msgstr "" #. type: Title === #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:157 #, no-wrap msgid "VSCode" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:164 msgid "" "LSP client plugins are required to launch the language server daemon. Press " "`Ctrl+Shift+X` to show the extension online search panel. Enter `llvm-vs-" "code-extensions.vscode-clangd` when running clangd, or `ccls-project.ccls` " "when running ccls." msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:168 msgid "" "Then, press `Ctrl+Shift+P` to show the editor commands palette. Enter " "`Preferences: Open Settings (JSON)` into the palette and hit `Enter` to open " "[.filepath]#settings.json#. Depending on the language server " "implementations, put one of the following JSON key/value pairs in [." "filepath]#settings.json#:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:182 #, no-wrap msgid "" "[\n" " /* Begin of your existing configurations */\n" " ...\n" " /* End of your existing configurations */\n" " \"clangd.arguments\": [\n" " \"--background-index\",\n" " \"--header-insertion=never\"\n" " ],\n" " \"clangd.path\": \"clangd12\"\n" "]\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:193 #, no-wrap msgid "" "[\n" " /* Begin of your existing configurations */\n" " ...\n" " /* End of your existing configurations */\n" " \"ccls.cache.hierarchicalPath\": true\n" "]\n" msgstr "" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:196 #, no-wrap msgid "Compilation database" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:202 msgid "" "A Compilation database contains an array of compile command objects. Each " "object specifies a way of compiling a source file. The compilation database " -"file is usually [.filename]#compiler_commands.json#. The database is used " +"file is usually [.filename]#compile_commands.json#. The database is used " "by language server implementations for indexing purpose." msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:204 msgid "" "Please refer to link:https://clang.llvm.org/docs/JSONCompilationDatabase." "html#format[] for details on the format of the compilation database file." msgstr "" #. type: Title === #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:206 #, no-wrap msgid "Generators" msgstr "" #. type: Title ==== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:209 #, no-wrap msgid "Using scan-build-py" msgstr "" #. type: Title ===== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:211 #, no-wrap msgid "Installation" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:215 msgid "" "`intercept-build` tool from scan-build-py is used to generate compilation " "database." msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:218 msgid "" "Install package:devel/python[] to get python interpreter first. To get " "`intercept-build` from LLVM:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:222 #, no-wrap msgid "# git clone https://github.com/llvm/llvm-project /path/to/llvm-project\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:225 msgid "" "where [.filename]#/path/to/llvm-project/# is your desired path for the " "repository. Make an alias in the shell configuration file for convenience:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:229 #, no-wrap msgid "alias intercept-build='/path/to/llvm-project/clang/tools/scan-build-py/bin/intercept-build'\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:235 msgid "" "link:https://github.com/rizsotto/scan-build[rizsotto/scan-build] can be used " "instead of LLVM's scan-build-py. The LLVM's scan-build-py was rizsotto/scan-" "build merged into the LLVM tree. This implementation can be installed by " "`pip install --user scan-build`. The `intercept-build` script is in [." "filename]#~/.local/bin# by default." msgstr "" #. type: Title ===== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:236 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:252 #, no-wrap msgid "Usage" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:239 msgid "" "In the top-level directory of the FreeBSD src tree, generate the compilation " "database with `intercept-build`:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:243 #, no-wrap msgid "# intercept-build --append make buildworld buildkernel -j`sysctl -n hw.ncpu`\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:248 msgid "" "The `--append` flag tells the `intercept-build` to read an existing " "compilation database (if a compilation database exists) and append the " "results to the database. Entries with duplicated command keys are merged. " "The generated compilation database by default is saved in the current " -"working directory as [.filename]#compiler_commands.json#." +"working directory as [.filename]#compile_commands.json#." msgstr "" #. type: Title ==== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:250 #, no-wrap msgid "Using devel/bear" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:255 msgid "" "In the top-level directory of the FreeBSD src tree, to generate compilation " "database with `bear`:" msgstr "" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:259 #, no-wrap msgid "# bear --append -- make buildworld buildkernel -j`sysctl -n hw.ncpu`\n" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:264 msgid "" "The `--append` flag tells `bear` to read an existing compilation database if " "it is present, and append the results to the database. Entries with " "duplicated command key are merged. The generated compilation database by " "default is saved in the current working directory as [." -"filename]#compiler_commands.json#." +"filename]#compile_commands.json#." msgstr "" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:266 #, no-wrap msgid "Final" msgstr "" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:270 msgid "" "Once the compilation database is generated, open any source files in the " "FreeBSD src tree and LSP server daemon will be launched as well in " "background. Opening source files in the src tree for the first time takes " "significantly longer time before the LSP server is able to give a complete " "result, due to initial background indexing by the LSP server compiling all " "the listed entries in the compilation database. The language server daemon " "however does not index the source files not appearing in the compilation " "database, thus no complete results are shown on source files not being " "compiled during the `make`." msgstr "" diff --git a/documentation/content/es/articles/freebsd-src-lsp/_index.adoc b/documentation/content/es/articles/freebsd-src-lsp/_index.adoc index ef1be49b50..472e48585f 100644 --- a/documentation/content/es/articles/freebsd-src-lsp/_index.adoc +++ b/documentation/content/es/articles/freebsd-src-lsp/_index.adoc @@ -1,248 +1,248 @@ --- authors: - author: 'Ka Ho Ng' email: khng@FreeBSD.org copyright: '2021 The FreeBSD Foundation' description: 'Uso de Servidores de Lenguajes para desarrollo en el árbol de src de FreeBSD para obtener resultados precisos para saltar a definiciones o auto completado.' tags: ["FreeBSD", "Language Server", "LSP"] title: 'Uso de Servidores de Lenguajes para Desarrollo en el Árbol Src de FreeBSD' trademarks: ["freebsd"] --- = Uso de Servidores de Lenguajes para Desarrollo en el Árbol Src de FreeBSD :doctype: article :toc: macro :toclevels: 1 :icons: font :sectnums: :sectnumlevels: 6 :source-highlighter: rouge :experimental: :images-path: articles/freebsd-src-lsp/ ifdef::env-beastie[] ifdef::backend-html5[] include::shared/authors.adoc[] include::shared/mirrors.adoc[] include::shared/releases.adoc[] include::shared/attributes/attributes-{{% lang %}}.adoc[] include::shared/{{% lang %}}/teams.adoc[] include::shared/{{% lang %}}/mailing-lists.adoc[] include::shared/{{% lang %}}/urls.adoc[] :imagesdir: ../../../images/{images-path} endif::[] ifdef::backend-pdf,backend-epub3[] include::../../../../shared/asciidoctor.adoc[] endif::[] endif::[] ifndef::env-beastie[] include::../../../../../shared/asciidoctor.adoc[] endif::[] toc::[] [[intro]] == Introducción Esta guía es acerca de cómo configurar un árbol src de FreeBSD con servidores de lenguajes para realizar indexado de código fuente. [[ports-required]] == Ports Requeridos Se necesitan algunos ports a lo largo de esta guía. Escoge tu combinación favorita de herramientas de cada una de las categorías siguientes: * Implementaciones de servidores de lenguajes ** package:devel/ccls[] ** package:devel/llvm12[] (Otras versiones son válidas, pero cuanto más nuevo, mejor. Reemplaza `clangd12` con clangdN en caso de usar otra versión.) * Editores ** package:editors/vim[] ** package:editors/neovim[] ** package:editors/vscode[] * Generador de base de datos de compilación ** package:devel/python[] (Para la implementación de scan-build-py de llvm) ** package:devel/py-pip[] (Para la implementación de scan-build de rizsotto) ** package:devel/bear[] [[editor-settings]] == Configuración del editor [[settings-vim]] === Vim/Neovim ==== Plugins de LSP para el cliente Este ejemplo utiliza el gestor de plugins incorporado en ambos editores. El plugin de LSP para el cliente es link:https://github.com/prabirshrestha/vim-lsp[prabirshrestha/vim-lsp]. Para configurar el plugin cliente de LSP en Neovim: [source, shell] .... # mkdir -p ~/.config/nvim/pack/lsp/start # git clone https://github.com/prabirshrestha/vim-lsp ~/.config/nvim/pack/lsp/start/vim-lsp .... y para Vim: [source, shell] .... # mkdir -p ~/.vim/pack/lsp/start # git clone https://github.com/prabirshrestha/vim-lsp ~/.vim/pack/lsp/start/vim-lsp .... Para activar el plugin cliente de LSP en el editor, añade el siguiente fragmento en [.filepath]#~/.config/nvim/init.vim# cuando uses Neovim, o [.filepath]#~/.vim/vimrc# cuando uses Vim: .Para ccls [source, vim] .... au User lsp_setup call lsp#register_server({ \ 'name': 'ccls', \ 'cmd': {server_info->['ccls']}, \ 'allowlist': ['c', 'cpp', 'objc'], \ 'initialization_options': { \ 'cache': { \ 'hierarchicalPath': v:true \ } \ }}) .... .Para clangd [source, vim] .... au User lsp_setup call lsp#register_server({ \ 'name': 'clangd', \ 'cmd': {server_info->['clangd12', '--background-index', '--header-insertion=never']}, \ 'allowlist': ['c', 'cpp', 'objc'], \ 'initialization_options': {}, \ }) .... Por favor, dirígete a link:https://github.com/prabirshrestha/vim-lsp/blob/master/README.md#registering-servers[] para aprender cómo configurar los atajos de teclado y el auto completado de código. El sitio oficial de clangd es link:https://clangd.llvm.org[], y el enlace al repositorio de ccls es link:https://github.com/MaskRay/ccls/[]. Abajo se muestra la configuración de referencia para los atajos de teclado y el auto completado de código. Pon el siguiente fragmento en [.filepath]#~/.config/nvim/init.vim#, o [.filepath]#~/.vim/vimrc# para usarlo con Vim: [source, vim] .... function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal completeopt-=preview setlocal keywordprg=:LspHover nmap (lsp-definition) nmap ] (lsp-peek-definition) nmap (lsp-peek-definition) nmap gr (lsp-references) nmap (lsp-next-reference) nmap (lsp-previous-reference) nmap gI (lsp-implementation) nmap go (lsp-document-symbol) nmap gS (lsp-workspace-symbol) nmap ga (lsp-code-action) nmap gR (lsp-rename) nmap gm (lsp-signature-help) endfunction augroup lsp_install au! autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END .... [[settings-vscode]] === VSCode ==== Plugins de LSP para el cliente Los plugins de cliente de LSP son necesarios para arrancar un demonio de servidor de lenguajes. Presiona `Ctrl+Shift+X` para mostrar el panel de búsquedas online de extensiones. Teclea `llvm-vs-code-extensions.vscode-clangd` cuando utilices clangd, o `ccls-project.ccls` cuando utilices ccls. Después, presiona `Ctrl+Shift+P` para mostrar la paleta del editor de comandos. Teclea `Preferences: Open Settings (JSON)` y presiona `Enter` para abrir [.filepath]#settings.json#. Dependiendo de la implementación del servidor de lenguajes, utiliza uno de los siguientes pares de clave/valor de JSON en [.filepath]#settings.json#: .Para clangd [source, json] .... [ /* Begin of your existing configurations */ ... /* End of your existing configurations */ "clangd.arguments": [ "--background-index", "--header-insertion=never" ], "clangd.path": "clangd12" ] .... .Para ccls [source, json] .... [ /* Begin of your existing configurations */ ... /* End of your existing configurations */ "ccls.cache.hierarchicalPath": true ] .... [[cdb]] == Base de datos de compilación -Una base de datos de compilación contiene un array de objetos de comandos de compilación. Cada objeto especifica una forma de compilar un fichero fuente. El fichero de la base de datos de compilación es normalmente [.filename]#compiler_commands.json#. La base de datos es utilizada por el servidor de lenguajes con propósitos de indexado. +Una base de datos de compilación contiene un array de objetos de comandos de compilación. Cada objeto especifica una forma de compilar un fichero fuente. El fichero de la base de datos de compilación es normalmente [.filename]#compile_commands.json#. La base de datos es utilizada por el servidor de lenguajes con propósitos de indexado. Por favor consulta link:https://clang.llvm.org/docs/JSONCompilationDatabase.html#format[] para detalles acerca del formato del fichero de la base de datos de compilación. [[cdb-generators]] === Generadores [[generators-scan-build-py]] ==== Utilizando scan-build-py ===== Instalación La herramienta `intercept-build` de scan-build-py se utiliza para generar la base de datos de compilación. Instala package:devel/python[] primero para tener el intérprete de python. Para obtener `intercept-build` de LLVM: [source, shell] .... # git clone https://github.com/llvm/llvm-project /path/to/llvm-project .... donde [.filename]#/path/to/llvm-project/# es la ruta que quieres en el repositorio. Crea un alias en el fichero de configuración del shell para tu comodidad: [source, shell] .... alias intercept-build='/path/to/llvm-project/clang/tools/scan-build-py/bin/intercept-build' .... Se puede usar link:https://github.com/rizsotto/scan-build[rizsotto/scan-build] en lugar del scan-build-py de LLVM. El scan-build-py de LLVM era rizsotto/scan-build que se integró en el árbol de LLVM.Se puede instalar esta implementación mediante `pip install --user scan-build`. El script `intercept-build` está en [.filename]#~/.local/bin# por defecto. ===== Uso En el directorio de más alto nivel en el árbol src de FreeBSD, genera la base de datos de compilación con `intercept-build`: [source, shell] .... # intercept-build --append make buildworld buildkernel -j`sysctl -n hw.ncpu` .... -El flag `--apend` le dice a `intercept-build` que lea una base de datos de compilación existente (si es que existe) y que añada los resultados a dicha base de datos. Las entradas con claves duplicadas de comandos son integradas. La base de datos de compilación generada por defecto se salva en el directorio de trabajo actual como [.filename]#compiler_commands.json#. +El flag `--apend` le dice a `intercept-build` que lea una base de datos de compilación existente (si es que existe) y que añada los resultados a dicha base de datos. Las entradas con claves duplicadas de comandos son integradas. La base de datos de compilación generada por defecto se salva en el directorio de trabajo actual como [.filename]#compile_commands.json#. [[generators-bear]] ==== Usando devel/bear ===== Uso En el directorio de más alto nivel en el árbol src de FreeBSD, genera la base de datos de compilación con `bear`: [source, shell] .... # bear --append -- make buildworld buildkernel -j`sysctl -n hw.ncpu` .... -El flag `--apend` le dice a `bear` que lea una base de datos de compilación existente (si es que existe) y que añada los resultados a dicha base de datos. Las entradas con claves duplicadas de comandos son integradas. La base de datos de compilación generada por defecto se salva en el directorio de trabajo actual como [.filename]#compiler_commands.json#. +El flag `--apend` le dice a `bear` que lea una base de datos de compilación existente (si es que existe) y que añada los resultados a dicha base de datos. Las entradas con claves duplicadas de comandos son integradas. La base de datos de compilación generada por defecto se salva en el directorio de trabajo actual como [.filename]#compile_commands.json#. [[final]] == Final Una vez que la base de datos de compilación ha sido generada, abre cualquier fichero fuente del árbol src de FreeBSD y el demonio servidor de LSP será arrancado también en segundo plano. Abrir ficheros fuente en el árbol src la primera vez lleva significativamente más tiempo antes de que el servidor LSP sea capaz de completar el resultado, debido al indexado inicial en segundo plano que realiza el servidor LSP mediante la compilación de todas las entradas listadas en la base de datos de compilación. Sin embargo el demonio de servicio de lenguajes no indexa ficheros fuente que no aparecen en la base de datos de compilación, por lo tanto no se muestran resultados completos para ficheros fuentes que no se compilan durante la ejecución de `make`. diff --git a/documentation/content/es/articles/freebsd-src-lsp/_index.po b/documentation/content/es/articles/freebsd-src-lsp/_index.po index 9c2cccbe75..eef290adb2 100644 --- a/documentation/content/es/articles/freebsd-src-lsp/_index.po +++ b/documentation/content/es/articles/freebsd-src-lsp/_index.po @@ -1,643 +1,643 @@ # SOME DESCRIPTIVE TITLE # Copyright (C) YEAR The FreeBSD Project # This file is distributed under the same license as the FreeBSD Documentation package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: FreeBSD Documentation VERSION\n" "POT-Creation-Date: 2022-07-07 23:23-0300\n" "PO-Revision-Date: 2022-08-04 05:48+0000\n" "Last-Translator: Fernando Apesteguía \n" "Language-Team: Spanish \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: Weblate 4.10.1\n" #. type: YAML Front Matter: description #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:1 #, no-wrap msgid "Use Language Servers for development in the FreeBSD src tree to get precise go-to-definition and completion results." msgstr "" "Uso de Servidores de Lenguajes para desarrollo en el árbol de src de FreeBSD " "para obtener resultados precisos para saltar a definiciones o auto " "completado." #. type: Title = #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:1 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:13 #, no-wrap msgid "Use Language Servers for Development in the FreeBSD Src Tree" msgstr "" "Uso de Servidores de Lenguajes para Desarrollo en el Árbol Src de FreeBSD" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:47 #, no-wrap msgid "Introduction" msgstr "Introducción" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:50 msgid "" "This guide is about setting up a FreeBSD src tree with language servers " "performing source code indexing." msgstr "" "Esta guía es acerca de cómo configurar un árbol src de FreeBSD con " "servidores de lenguajes para realizar indexado de código fuente." #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:52 #, no-wrap msgid "Required Ports" msgstr "Ports Requeridos" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:56 msgid "" "Some ports are required throughout the guide. Choose a favorite combination " "of tools from each category below:" msgstr "" "Se necesitan algunos ports a lo largo de esta guía. Escoge tu combinación " "favorita de herramientas de cada una de las categorías siguientes:" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:58 msgid "Language server implementations" msgstr "Implementaciones de servidores de lenguajes" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:59 msgid "package:devel/ccls[]" msgstr "package:devel/ccls[]" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:60 msgid "" "package:devel/llvm12[] (Other versions are okay, but newer is better. " "Replace `clangd12` with clangdN in case other versions are used.)" msgstr "" "package:devel/llvm12[] (Otras versiones son válidas, pero cuanto más nuevo, " "mejor. Reemplaza `clangd12` con clangdN en caso de usar otra versión.)" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:61 msgid "Editors" msgstr "Editores" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:62 msgid "package:editors/vim[]" msgstr "package:editors/vim[]" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:63 msgid "package:editors/neovim[]" msgstr "package:editors/neovim[]" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:64 msgid "package:editors/vscode[]" msgstr "package:editors/vscode[]" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:65 msgid "Compilation database generator" msgstr "Generador de base de datos de compilación" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:66 msgid "package:devel/python[] (For llvm's scan-build-py implementation)" msgstr "" "package:devel/python[] (Para la implementación de scan-build-py de llvm)" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:67 msgid "package:devel/py-pip[] (For rizsotto's scan-build implementation)" msgstr "" "package:devel/py-pip[] (Para la implementación de scan-build de rizsotto)" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:68 msgid "package:devel/bear[]" msgstr "package:devel/bear[]" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:70 #, no-wrap msgid "Editor settings" msgstr "Configuración del editor" #. type: Title === #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:73 #, no-wrap msgid "Vim/Neovim" msgstr "Vim/Neovim" #. type: Title ==== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:75 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:159 #, no-wrap msgid "LSP client plugins" msgstr "Plugins de LSP para el cliente" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:79 msgid "" "The built-in plugin manager is used for both editors in this example. The " "LSP client plugin used is link:https://github.com/prabirshrestha/vim-" "lsp[prabirshrestha/vim-lsp]." msgstr "" "Este ejemplo utiliza el gestor de plugins incorporado en ambos editores. El " "plugin de LSP para el cliente es link:https://github.com/prabirshrestha/vim-" "lsp[prabirshrestha/vim-lsp]." #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:81 msgid "To set up the LSP client plugin for Neovim:" msgstr "Para configurar el plugin cliente de LSP en Neovim:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:86 #, no-wrap msgid "" "# mkdir -p ~/.config/nvim/pack/lsp/start\n" "# git clone https://github.com/prabirshrestha/vim-lsp ~/.config/nvim/pack/lsp/start/vim-lsp\n" msgstr "" "# mkdir -p ~/.config/nvim/pack/lsp/start\n" "# git clone https://github.com/prabirshrestha/vim-lsp ~/.config/nvim/pack/" "lsp/start/vim-lsp\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:89 msgid "and for Vim:" msgstr "y para Vim:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:94 #, no-wrap msgid "" "# mkdir -p ~/.vim/pack/lsp/start\n" "# git clone https://github.com/prabirshrestha/vim-lsp ~/.vim/pack/lsp/start/vim-lsp\n" msgstr "" "# mkdir -p ~/.vim/pack/lsp/start\n" "# git clone https://github.com/prabirshrestha/vim-lsp ~/.vim/pack/lsp/start/" "vim-lsp\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:97 msgid "" "To enable the LSP client plugin in the editor, add the following snippet " "into [.filepath]#~/.config/nvim/init.vim# when using Neovim, or [." "filepath]#~/.vim/vimrc# when using Vim:" msgstr "" "Para activar el plugin cliente de LSP en el editor, añade el siguiente " "fragmento en [.filepath]#~/.config/nvim/init.vim# cuando uses Neovim, o [." "filepath]#~/.vim/vimrc# cuando uses Vim:" #. type: Block title #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:98 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:184 #, no-wrap msgid "For ccls" msgstr "Para ccls" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:110 #, no-wrap msgid "" "au User lsp_setup call lsp#register_server({\n" " \\ 'name': 'ccls',\n" " \\ 'cmd': {server_info->['ccls']},\n" " \\ 'allowlist': ['c', 'cpp', 'objc'],\n" " \\ 'initialization_options': {\n" " \\ 'cache': {\n" " \\ 'hierarchicalPath': v:true\n" " \\ }\n" " \\ }})\n" msgstr "" "au User lsp_setup call lsp#register_server({\n" " \\ 'name': 'ccls',\n" " \\ 'cmd': {server_info->['ccls']},\n" " \\ 'allowlist': ['c', 'cpp', 'objc'],\n" " \\ 'initialization_options': {\n" " \\ 'cache': {\n" " \\ 'hierarchicalPath': v:true\n" " \\ }\n" " \\ }})\n" #. type: Block title #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:112 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:169 #, no-wrap msgid "For clangd" msgstr "Para clangd" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:121 #, no-wrap msgid "" "au User lsp_setup call lsp#register_server({\n" " \\ 'name': 'clangd',\n" " \\ 'cmd': {server_info->['clangd12', '--background-index', '--header-insertion=never']},\n" " \\ 'allowlist': ['c', 'cpp', 'objc'],\n" " \\ 'initialization_options': {},\n" " \\ })\n" msgstr "" "au User lsp_setup call lsp#register_server({\n" " \\ 'name': 'clangd',\n" " \\ 'cmd': {server_info->['clangd12', '--background-index', '--header-" "insertion=never']},\n" " \\ 'allowlist': ['c', 'cpp', 'objc'],\n" " \\ 'initialization_options': {},\n" " \\ })\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:125 msgid "" "Please refer to link:https://github.com/prabirshrestha/vim-lsp/blob/master/" "README.md#registering-servers[] to learn about setting up key bindings and " "code completion. The official site of clangd is link:https://clangd.llvm." "org[], and the repository link of ccls is link:https://github.com/MaskRay/" "ccls/[]." msgstr "" "Por favor, dirígete a link:https://github.com/prabirshrestha/vim-lsp/blob/" "master/README.md#registering-servers[] para aprender cómo configurar los " "atajos de teclado y el auto completado de código. El sitio oficial de clangd " "es link:https://clangd.llvm.org[], y el enlace al repositorio de ccls es " "link:https://github.com/MaskRay/ccls/[]." #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:128 msgid "" "Below are the reference settings of keybindings and code completions. Put " "the following snippet into [.filepath]#~/.config/nvim/init.vim#, or [." "filepath]#~/.vim/vimrc# for Vim users to use it:" msgstr "" "Abajo se muestra la configuración de referencia para los atajos de teclado y " "el auto completado de código. Pon el siguiente fragmento en [.filepath]#~/." "config/nvim/init.vim#, o [.filepath]#~/.vim/vimrc# para usarlo con Vim:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:135 #, no-wrap msgid "" "function! s:on_lsp_buffer_enabled() abort\n" " setlocal omnifunc=lsp#complete\n" " setlocal completeopt-=preview\n" " setlocal keywordprg=:LspHover\n" msgstr "" "function! s:on_lsp_buffer_enabled() abort\n" " setlocal omnifunc=lsp#complete\n" " setlocal completeopt-=preview\n" " setlocal keywordprg=:LspHover\n" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:149 #, no-wrap msgid "" " nmap (lsp-definition)\n" " nmap ] (lsp-peek-definition)\n" " nmap (lsp-peek-definition)\n" " nmap gr (lsp-references)\n" " nmap (lsp-next-reference)\n" " nmap (lsp-previous-reference)\n" " nmap gI (lsp-implementation)\n" " nmap go (lsp-document-symbol)\n" " nmap gS (lsp-workspace-symbol)\n" " nmap ga (lsp-code-action)\n" " nmap gR (lsp-rename)\n" " nmap gm (lsp-signature-help)\n" "endfunction\n" msgstr "" " nmap (lsp-definition)\n" " nmap ] (lsp-peek-definition)\n" " nmap (lsp-peek-definition)\n" " nmap gr (lsp-references)\n" " nmap (lsp-next-reference)\n" " nmap (lsp-previous-reference)\n" " nmap gI (lsp-implementation)\n" " nmap go (lsp-document-symbol)\n" " nmap gS (lsp-workspace-symbol)\n" " nmap ga (lsp-code-action)\n" " nmap gR (lsp-rename)\n" " nmap gm (lsp-signature-help)\n" "endfunction\n" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:154 #, no-wrap msgid "" "augroup lsp_install\n" " au!\n" " autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()\n" "augroup END\n" msgstr "" "augroup lsp_install\n" " au!\n" " autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()\n" "augroup END\n" #. type: Title === #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:157 #, no-wrap msgid "VSCode" msgstr "VSCode" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:164 msgid "" "LSP client plugins are required to launch the language server daemon. Press " "`Ctrl+Shift+X` to show the extension online search panel. Enter `llvm-vs-" "code-extensions.vscode-clangd` when running clangd, or `ccls-project.ccls` " "when running ccls." msgstr "" "Los plugins de cliente de LSP son necesarios para arrancar un demonio de " "servidor de lenguajes. Presiona `Ctrl+Shift+X` para mostrar el panel de " "búsquedas online de extensiones. Teclea `llvm-vs-code-extensions.vscode-" "clangd` cuando utilices clangd, o `ccls-project.ccls` cuando utilices ccls." #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:168 msgid "" "Then, press `Ctrl+Shift+P` to show the editor commands palette. Enter " "`Preferences: Open Settings (JSON)` into the palette and hit `Enter` to open " "[.filepath]#settings.json#. Depending on the language server " "implementations, put one of the following JSON key/value pairs in [." "filepath]#settings.json#:" msgstr "" "Después, presiona `Ctrl+Shift+P` para mostrar la paleta del editor de " "comandos. Teclea `Preferences: Open Settings (JSON)` y presiona `Enter` para " "abrir [.filepath]#settings.json#. Dependiendo de la implementación del " "servidor de lenguajes, utiliza uno de los siguientes pares de clave/valor de " "JSON en [.filepath]#settings.json#:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:182 #, no-wrap msgid "" "[\n" " /* Begin of your existing configurations */\n" " ...\n" " /* End of your existing configurations */\n" " \"clangd.arguments\": [\n" " \"--background-index\",\n" " \"--header-insertion=never\"\n" " ],\n" " \"clangd.path\": \"clangd12\"\n" "]\n" msgstr "" "[\n" " /* Begin of your existing configurations */\n" " ...\n" " /* End of your existing configurations */\n" " \"clangd.arguments\": [\n" " \"--background-index\",\n" " \"--header-insertion=never\"\n" " ],\n" " \"clangd.path\": \"clangd12\"\n" "]\n" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:193 #, no-wrap msgid "" "[\n" " /* Begin of your existing configurations */\n" " ...\n" " /* End of your existing configurations */\n" " \"ccls.cache.hierarchicalPath\": true\n" "]\n" msgstr "" "[\n" " /* Begin of your existing configurations */\n" " ...\n" " /* End of your existing configurations */\n" " \"ccls.cache.hierarchicalPath\": true\n" "]\n" #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:196 #, no-wrap msgid "Compilation database" msgstr "Base de datos de compilación" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:202 msgid "" "A Compilation database contains an array of compile command objects. Each " "object specifies a way of compiling a source file. The compilation database " -"file is usually [.filename]#compiler_commands.json#. The database is used " +"file is usually [.filename]#compile_commands.json#. The database is used " "by language server implementations for indexing purpose." msgstr "" "Una base de datos de compilación contiene un array de objetos de comandos de " "compilación. Cada objeto especifica una forma de compilar un fichero fuente. " "El fichero de la base de datos de compilación es normalmente [." -"filename]#compiler_commands.json#. La base de datos es utilizada por el " +"filename]#compile_commands.json#. La base de datos es utilizada por el " "servidor de lenguajes con propósitos de indexado." #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:204 msgid "" "Please refer to link:https://clang.llvm.org/docs/JSONCompilationDatabase." "html#format[] for details on the format of the compilation database file." msgstr "" "Por favor consulta link:https://clang.llvm.org/docs/JSONCompilationDatabase." "html#format[] para detalles acerca del formato del fichero de la base de " "datos de compilación." #. type: Title === #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:206 #, no-wrap msgid "Generators" msgstr "Generadores" #. type: Title ==== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:209 #, no-wrap msgid "Using scan-build-py" msgstr "Utilizando scan-build-py" #. type: Title ===== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:211 #, no-wrap msgid "Installation" msgstr "Instalación" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:215 msgid "" "`intercept-build` tool from scan-build-py is used to generate compilation " "database." msgstr "" "La herramienta `intercept-build` de scan-build-py se utiliza para generar la " "base de datos de compilación." #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:218 msgid "" "Install package:devel/python[] to get python interpreter first. To get " "`intercept-build` from LLVM:" msgstr "" "Instala package:devel/python[] primero para tener el intérprete de python. " "Para obtener `intercept-build` de LLVM:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:222 #, no-wrap msgid "# git clone https://github.com/llvm/llvm-project /path/to/llvm-project\n" msgstr "" "# git clone https://github.com/llvm/llvm-project /path/to/llvm-project\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:225 msgid "" "where [.filename]#/path/to/llvm-project/# is your desired path for the " "repository. Make an alias in the shell configuration file for convenience:" msgstr "" "donde [.filename]#/path/to/llvm-project/# es la ruta que quieres en el " "repositorio. Crea un alias en el fichero de configuración del shell para tu " "comodidad:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:229 #, no-wrap msgid "alias intercept-build='/path/to/llvm-project/clang/tools/scan-build-py/bin/intercept-build'\n" msgstr "" "alias intercept-build='/path/to/llvm-project/clang/tools/scan-build-py/bin/" "intercept-build'\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:235 msgid "" "link:https://github.com/rizsotto/scan-build[rizsotto/scan-build] can be used " "instead of LLVM's scan-build-py. The LLVM's scan-build-py was rizsotto/scan-" "build merged into the LLVM tree. This implementation can be installed by " "`pip install --user scan-build`. The `intercept-build` script is in [." "filename]#~/.local/bin# by default." msgstr "" "Se puede usar link:https://github.com/rizsotto/scan-build[rizsotto/scan-" "build] en lugar del scan-build-py de LLVM. El scan-build-py de LLVM era " "rizsotto/scan-build que se integró en el árbol de LLVM.Se puede instalar " "esta implementación mediante `pip install --user scan-build`. El script " "`intercept-build` está en [.filename]#~/.local/bin# por defecto." #. type: Title ===== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:236 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:252 #, no-wrap msgid "Usage" msgstr "Uso" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:239 msgid "" "In the top-level directory of the FreeBSD src tree, generate the compilation " "database with `intercept-build`:" msgstr "" "En el directorio de más alto nivel en el árbol src de FreeBSD, genera la " "base de datos de compilación con `intercept-build`:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:243 #, no-wrap msgid "# intercept-build --append make buildworld buildkernel -j`sysctl -n hw.ncpu`\n" msgstr "" "# intercept-build --append make buildworld buildkernel -j`sysctl -n hw.ncpu`" "\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:248 msgid "" "The `--append` flag tells the `intercept-build` to read an existing " "compilation database (if a compilation database exists) and append the " "results to the database. Entries with duplicated command keys are merged. " "The generated compilation database by default is saved in the current " -"working directory as [.filename]#compiler_commands.json#." +"working directory as [.filename]#compile_commands.json#." msgstr "" "El flag `--apend` le dice a `intercept-build` que lea una base de datos de " "compilación existente (si es que existe) y que añada los resultados a dicha " "base de datos. Las entradas con claves duplicadas de comandos son " "integradas. La base de datos de compilación generada por defecto se salva en " -"el directorio de trabajo actual como [.filename]#compiler_commands.json#." +"el directorio de trabajo actual como [.filename]#compile_commands.json#." #. type: Title ==== #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:250 #, no-wrap msgid "Using devel/bear" msgstr "Usando devel/bear" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:255 msgid "" "In the top-level directory of the FreeBSD src tree, to generate compilation " "database with `bear`:" msgstr "" "En el directorio de más alto nivel en el árbol src de FreeBSD, genera la " "base de datos de compilación con `bear`:" #. type: delimited block . 4 #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:259 #, no-wrap msgid "# bear --append -- make buildworld buildkernel -j`sysctl -n hw.ncpu`\n" msgstr "# bear --append -- make buildworld buildkernel -j`sysctl -n hw.ncpu`\n" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:264 msgid "" "The `--append` flag tells `bear` to read an existing compilation database if " "it is present, and append the results to the database. Entries with " "duplicated command key are merged. The generated compilation database by " "default is saved in the current working directory as [." -"filename]#compiler_commands.json#." +"filename]#compile_commands.json#." msgstr "" "El flag `--apend` le dice a `bear` que lea una base de datos de compilación " "existente (si es que existe) y que añada los resultados a dicha base de " "datos. Las entradas con claves duplicadas de comandos son integradas. La " "base de datos de compilación generada por defecto se salva en el directorio " -"de trabajo actual como [.filename]#compiler_commands.json#." +"de trabajo actual como [.filename]#compile_commands.json#." #. type: Title == #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:266 #, no-wrap msgid "Final" msgstr "Final" #. type: Plain text #: documentation/content/en/articles/freebsd-src-lsp/_index.adoc:270 msgid "" "Once the compilation database is generated, open any source files in the " "FreeBSD src tree and LSP server daemon will be launched as well in " "background. Opening source files in the src tree for the first time takes " "significantly longer time before the LSP server is able to give a complete " "result, due to initial background indexing by the LSP server compiling all " "the listed entries in the compilation database. The language server daemon " "however does not index the source files not appearing in the compilation " "database, thus no complete results are shown on source files not being " "compiled during the `make`." msgstr "" "Una vez que la base de datos de compilación ha sido generada, abre cualquier " "fichero fuente del árbol src de FreeBSD y el demonio servidor de LSP será " "arrancado también en segundo plano. Abrir ficheros fuente en el árbol src la " "primera vez lleva significativamente más tiempo antes de que el servidor " "LSP sea capaz de completar el resultado, debido al indexado inicial en " "segundo plano que realiza el servidor LSP mediante la compilación de todas " "las entradas listadas en la base de datos de compilación. Sin embargo el " "demonio de servicio de lenguajes no indexa ficheros fuente que no aparecen " "en la base de datos de compilación, por lo tanto no se muestran resultados " "completos para ficheros fuentes que no se compilan durante la ejecución de " "`make`." #~ msgid "" #~ "include::shared/attributes/attributes-{{% lang %}}.adoc[] include::shared/" #~ "{{% lang %}}/teams.adoc[] include::shared/{{% lang %}}/mailing-lists." #~ "adoc[] include::shared/{{% lang %}}/urls.adoc[]" #~ msgstr "" #~ "include::shared/attributes/attributes-{{% lang %}}.adoc[]\n" #~ "include::shared/{{% lang %}}/teams.adoc[]\n" #~ "include::shared/{{% lang %}}/mailing-lists.adoc[]\n" #~ "include::shared/{{% lang %}}/urls.adoc[]"