11 Matching Annotations
  1. Jan 2022
    1. require require('file_path') でluaファイルをモジュールとして読み込みます。Neovimの runtimepath ディレクトリ内の lua ディレクトリに格納されているLuaファイルを require で読み込めます。 例 init.vim lua require('plugins') ~/.config/nvim/lua/plugins/init.lua を読み込みます。 lua require('plugins.completion') ~/.config/nvim/lua/plugins/completion.lua を読み込みます。 lua require('plugins/completion') . or / どっちでもOKです。 . のほうがよく見ます。
    1. Pyright from what I can tell doesn't support formatting. Coc seems to be using autopep8 which is a formatter and not a language server. That being said, for the langauge servers which do support formatting, I use this inside of the on_attach callback from nvim-lspconfig: vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
  2. Dec 2021
    1. How do I format files on save? See the following snippet: require("null-ls").setup({ -- you can reuse a shared lspconfig on_attach callback here on_attach = function(client) if client.resolved_capabilities.document_formatting then vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()") end end, })

      [[null-lsで保存時に自動フォーマットする]]

    1. これは Prettier の設定例です。あらかじめグローバルにprettierをインストールしておく必要があります。 init.lua use { "jose-elias-alvarez/null-ls.nvim", requires = { "nvim-lua/plenary.nvim" } } local nullls = require "null-ls" nullls.config { sources = { nullls.builtins.formatting.prettier, }, } require("lspconfig")["null-ls"].setup {}
    2. neovim でフォーマッタを動かす方法はいろいろありますが、ここではnull-lsを紹介します。 これは様々なツールの出力を LSP の形式に変換して nvim-lsp に送るという仕組みになっています。似たようなツールにdiagnostic-languageserverやefm-langserverがありますが、null-lsはあくまで neovim のプラグインなので外部依存がないことが利点です。
    1. vim.g.indent_blankline_context_patterns = { "abstract_class_declaration", "abstract_method_signature", "accessibility_modifier", "ambient_declaration", "arguments", "array", "array_pattern", "array_type", "arrow_function", "as_expression", "asserts", "assignment_expression", "assignment_pattern", "augmented_assignment_expression", "await_expression", "binary_expression", "break_statement", "call_expression", "call_signature", "catch_clause", "class", "class_body", "class_declaration", "class_heritage", "computed_property_name", "conditional_type", "constraint", "construct_signature", "constructor_type", "continue_statement", "debugger_statement", "declaration", "decorator", "default_type", "do_statement", "else_clause", "empty_statement", "enum_assignment", "enum_body", "enum_declaration", "existential_type", "export_clause", "export_specifier", "export_statement", "expression", "expression_statement", "extends_clause", "finally_clause", "flow_maybe_type", "for_in_statement", "for_statement", "formal_parameters", "function", "function_declaration", "function_signature", "function_type", "generator_function", "generator_function_declaration", "generic_type", "if_statement", "implements_clause", "import", "import_alias", "import_clause", "import_require_clause", "import_specifier", "import_statement", "index_signature", "index_type_query", "infer_type", "interface_declaration", "internal_module", "intersection_type", "jsx_attribute", "jsx_closing_element", "jsx_element", "jsx_expression", "jsx_fragment", "jsx_namespace_name", "jsx_opening_element", "jsx_self_closing_element", "labeled_statement", "lexical_declaration", "literal_type", "lookup_type", "mapped_type_clause", "member_expression", "meta_property", "method_definition", "method_signature", "module", "named_imports", "namespace_import", "nested_identifier", "nested_type_identifier", "new_expression", "non_null_expression", "object", "object_assignment_pattern", "object_pattern", "object_type", "omitting_type_annotation", "opting_type_annotation", "optional_parameter", "optional_type", "pair", "pair_pattern", "parenthesized_expression", "parenthesized_type", "pattern", "predefined_type", "primary_expression", "program", "property_signature", "public_field_definition", "readonly_type", "regex", "required_parameter", "rest_pattern", "rest_type", "return_statement", "sequence_expression", "spread_element", "statement", "statement_block", "string", "subscript_expression", "switch_body", "switch_case", "switch_default", "switch_statement", "template_string", "template_substitution", "ternary_expression", "throw_statement", "try_statement", "tuple_type", "type_alias_declaration", "type_annotation", "type_arguments", "type_parameter", "type_parameters", "type_predicate", "type_predicate_annotation", "type_query", "unary_expression", "union_type", "update_expression", "variable_declaration", "variable_declarator", "while_statement", "with_statement", "yield_expression" }
    1. packer has the cond option that you can pass to optionally load a plugin. I found the disable didn't work for dynamic variables. For instance I have use { 'vimwiki/vimwiki', setup = [[require('config.vimwiki')]], cond = function() return not vim.g.vscode end } to only load vimwiki if not in vs code
  3. Feb 2021
  4. Sep 2020
  5. Jul 2020
  6. Dec 2019