|
| 1 | + |
| 2 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 3 | +-- ───────────────────────────────────────────────── -- |
| 4 | +-- Plugin: null-ls.nvim |
| 5 | +-- Github: github.com/jose-elias-alvarez/null-ls.nvim |
| 6 | +-- ───────────────────────────────────────────────── -- |
| 7 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 14 | +-- ━━━━━━━━━━━━━━━━━━━❰ configs ❱━━━━━━━━━━━━━━━━━━━ -- |
| 15 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 16 | +-- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md |
| 17 | + |
| 18 | +local builtins = require("null-ls.builtins") |
| 19 | +local formatting = builtins.formatting |
| 20 | +-- local completion = builtins.completion |
| 21 | +-- local diagnostics = builtins.diagnostics |
| 22 | +-- local code_actions = builtins.code_actions |
| 23 | + |
| 24 | +-- ───────────────────────────────────────────────── -- |
| 25 | +-- ─────────────────❰ FORMATTING ❱────────────────── -- |
| 26 | +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting |
| 27 | + |
| 28 | +-- register any number of sources simultaneously |
| 29 | +local sources = {} |
| 30 | +local ld = false |
| 31 | + |
| 32 | +-- Lua |
| 33 | +if vim.fn.executable("lua-format") == 1 then |
| 34 | + ld = true |
| 35 | + sources[#sources+1] = formatting.lua_format.with({ |
| 36 | + command = "lua-format", |
| 37 | + args = { |
| 38 | + "--indent-width", |
| 39 | + "1", |
| 40 | + "--tab-width", |
| 41 | + "4", |
| 42 | + "--use-tab", |
| 43 | + "--chop-down-table", |
| 44 | + "--extra-sep-at-table-end", |
| 45 | + }, |
| 46 | + }) |
| 47 | +end |
| 48 | + |
| 49 | + -- C, C++, CS, Java |
| 50 | +if vim.fn.executable("clang-format") == 1 then |
| 51 | + ld = true |
| 52 | + sources[#sources+1] = formatting.clang_format.with({ |
| 53 | + command = "clang-format", |
| 54 | + args = { |
| 55 | + "-assume-filename", |
| 56 | + "$FILENAME", |
| 57 | + "-style", |
| 58 | + "{BasedOnStyle: Microsoft, UseTab: Always}", |
| 59 | + }, |
| 60 | + to_stdin = true, |
| 61 | + }) |
| 62 | +end |
| 63 | + |
| 64 | +-- "javascript", "javascriptreact", "typescript", "typescriptreact", "vue", |
| 65 | +-- "css", "scss", "less", "html", "json", "yaml", "markdown", "graphql" |
| 66 | +if vim.fn.executable("prettier") == 1 then |
| 67 | + ld = true |
| 68 | + sources[#sources+1] = formatting.prettier.with({ |
| 69 | + command = "prettier", |
| 70 | + args = {"--stdin-filepath", "$FILENAME"}, |
| 71 | + }) |
| 72 | +end |
| 73 | + |
| 74 | +-- Python |
| 75 | +if vim.fn.executable("black") == 1 then |
| 76 | + ld = true |
| 77 | + sources[#sources+1] = formatting.black.with({ |
| 78 | + command = "black", |
| 79 | + args = {"--quiet", "--fast", "-"}, |
| 80 | + }) |
| 81 | +end |
| 82 | + |
| 83 | +if ld then |
| 84 | + require("null-ls").setup({sources = sources}) |
| 85 | +end |
| 86 | + |
| 87 | +-- ───────────────❰ end FORMATTING ❱──────────────── -- |
| 88 | +-- ───────────────────────────────────────────────── -- |
| 89 | + |
| 90 | + |
| 91 | +-- ───────────────────────────────────────────────── -- |
| 92 | +-- ─────────────────❰ COMPLETION ❱────────────────── -- |
| 93 | +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/completion |
| 94 | +-- ───────────────❰ end COMPLETION ❱──────────────── -- |
| 95 | +-- ───────────────────────────────────────────────── -- |
| 96 | + |
| 97 | +-- ───────────────────────────────────────────────── -- |
| 98 | +-- ─────────────────❰ DIAGNOSTICS ❱───────────────── -- |
| 99 | +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics |
| 100 | +-- ───────────────❰ end DIAGNOSTICS ❱─────────────── -- |
| 101 | +-- ───────────────────────────────────────────────── -- |
| 102 | + |
| 103 | +-- ───────────────────────────────────────────────── -- |
| 104 | +-- ─────────────────❰ CODEACTION ❱────────────────── -- |
| 105 | +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/code_actions |
| 106 | +-- ───────────────❰ end CODEACTION ❱──────────────── -- |
| 107 | +-- ───────────────────────────────────────────────── -- |
| 108 | + |
| 109 | +-- ───────────────────────────────────────────────── -- |
| 110 | +-- ───────────────────❰ HOVER ❱───────────────────── -- |
| 111 | +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/hover |
| 112 | +-- ─────────────────❰ end HOVER ❱─────────────────── -- |
| 113 | +-- ───────────────────────────────────────────────── -- |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 122 | +-- ━━━━━━━━━━━━━━━━━❰ end configs ❱━━━━━━━━━━━━━━━━━ -- |
| 123 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 124 | +-- -- |
| 125 | +-- -- |
| 126 | +-- -- |
| 127 | +-- -- |
| 128 | +-- -- |
| 129 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 130 | +-- ━━━━━━━━━━━━━━━━━━━❰ Mappings ❱━━━━━━━━━━━━━━━━━━ -- |
| 131 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 132 | + |
| 133 | +local keymap = vim.api.nvim_set_keymap |
| 134 | +keymap('n', '<Space>fm', '<ESC>:lua vim.lsp.buf.formatting()<CR>', {noremap = true, silent = true}) |
| 135 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 136 | +-- ━━━━━━━━━━━━━━━━━❰ end Mappings ❱━━━━━━━━━━━━━━━━ -- |
| 137 | +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- |
| 138 | + |
0 commit comments