Skip to content

Commit

Permalink
✨ Feat: Support executing SQL query
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen-Hoang-Nam committed Jul 10, 2022
1 parent de36cb8 commit c2f87ef
Show file tree
Hide file tree
Showing 11 changed files with 334 additions and 224 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add cmp-cmdline
- Add sqls.nvim

### Changed

- Refactor Telescope buffer previewer
- Refactor Telescope hologram
- Disable Cmp in comment
- Set cmdheight to 0
- Set rest keymap to buffer

### Fixed

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ _Kitty with Fira, Cascadia, and Mini-File-Icons_
(Thanks to [Efm-Langsever](https://github.com/mattn/efm-langserver))
- Previewing PNG image ([#4341](https://github.com/kovidgoyal/kitty/issues/4341))
(Thanks to [Hologram](https://github.com/edluffy/hologram.nvim))
- Executing SQL
(Thanks to [SQLS.nvim](https://github.com/nanotee/sqls.nvim))
- Managing plugins manually.

## Why I choose Kitty Terminal
Expand Down Expand Up @@ -386,7 +388,7 @@ Please store below plugins in `~/.local/share/nvim/site/pack/*/start/`.
| [nvim-dap-virtual-text](https://github.com/theHamsta/nvim-dap-virtual-text) | Jun 26 2021 |
| [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) | Jun 30 2022 |
| [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) | Jul 07 2022 |
| [nvim-mini-file-icons](https://github.com/Nguyen-Hoang-Nam/nvim-mini-file-icons) | |
| [nvim-mini-file-icons](https://github.com/Nguyen-Hoang-Nam/nvim-mini-file-icons) | Jul 09 2022 |
| [nvim-minimal-dashboard](https://github.com/Nguyen-Hoang-Nam/nvim-minimal-dashboard) | Jul 03 2022 |
| [nvim-scrollbar](https://github.com/petertriho/nvim-scrollbar) | Jun 14 2022 |
| [nvim-scrollview](https://github.com/dstein64/nvim-scrollview) | Jun 07 2022 |
Expand All @@ -395,6 +397,7 @@ Please store below plugins in `~/.local/share/nvim/site/pack/*/start/`.
| [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring) | Apr 07 2022 |
| [nvim-ts-rainbow](https://github.com/p00f/nvim-ts-rainbow) | Jul 08 2022 |
| [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) | Jul 04 2022 |
| [sqls.nvim](https://github.com/nanotee/sqls.nvim) | Jul 08 2022 |
| [rest.nvim](https://github.com/NTBBloodbath/rest.nvim) | May 13 2022 |
| [tabout.nvim](https://github.com/abecodes/tabout.nvim) | May 07 2022 |
| [telescope-fzf-native.nvim](https://github.com/nvim-telescope/telescope-fzf-native.nvim) | Jun 09 2022 |
Expand Down
9 changes: 9 additions & 0 deletions after/ftplugin/sql.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
vim.opt.indentexpr = "nvim_treesitter#indent()"

require("cmp").setup.buffer({
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "nvim_lsp_signature_help" },
},
})
1 change: 1 addition & 0 deletions lua/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ augroup StatusLine
autocmd FileType dapui* lua require('statusline').load()
autocmd FileType dap-repl lua require('statusline').load()
autocmd FileType aerial lua require('statusline').load()
autocmd FileType sqls_output lua require('statusline').load()
augroup END
]],
true
Expand Down
55 changes: 28 additions & 27 deletions lua/languages/languages.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
return {
sh = require('languages.bash'),
cmake = require('languages.cmake'),
css = require('languages.css'),
cpp = require('languages.cpp'),
dart = require('languages.dart'),
dockerfile = require('languages.docker'),
elixir = require('languages.elixir'),
go = require('languages.go'),
haskell = require('languages.haskell'),
html = require('languages.html'),
java = require('languages.java'),
javascript = require('languages.javascript'),
javascriptreact = require('languages.javascript'),
json = require('languages.json'),
lua = require('languages.lua'),
markdown = require('languages.markdown'),
php = require('languages.php'),
python = require('languages.python'),
rust = require('languages.rust'),
solidity = require('languages.solidity'),
svelte = require('languages.svelte'),
tex = require('languages.tex'),
typescript = require('languages.javascript'),
typescriptreact = require('languages.javascript'),
xml = require('languages.xml'),
yaml = require('languages.yaml'),
zig = require('languages.zig'),
sh = require("languages.bash"),
cmake = require("languages.cmake"),
css = require("languages.css"),
cpp = require("languages.cpp"),
dart = require("languages.dart"),
dockerfile = require("languages.docker"),
elixir = require("languages.elixir"),
go = require("languages.go"),
haskell = require("languages.haskell"),
html = require("languages.html"),
java = require("languages.java"),
javascript = require("languages.javascript"),
javascriptreact = require("languages.javascript"),
json = require("languages.json"),
lua = require("languages.lua"),
markdown = require("languages.markdown"),
php = require("languages.php"),
python = require("languages.python"),
rust = require("languages.rust"),
solidity = require("languages.solidity"),
sql = require("languages.sql"),
svelte = require("languages.svelte"),
tex = require("languages.tex"),
typescript = require("languages.javascript"),
typescriptreact = require("languages.javascript"),
xml = require("languages.xml"),
yaml = require("languages.yaml"),
zig = require("languages.zig"),
}
37 changes: 37 additions & 0 deletions lua/languages/sql.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local lsp = require("languages.lsp")
local M = {}

M.efm = {
-- {
-- formatCommand = "prettier --tab-width=4 --use-tabs=false --stdin-filepath ${INPUT}",
-- formatStdin = true,
-- },

-- {
-- lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}",
-- lintIgnoreExitCode = true,
-- lintStdin = true,
-- lintFormats = { "%f:%l:%c: %m" },
-- },
}

M.all_format = {
efm = "",
}

M.default_format = "efm"

M.lsp_server = "sqls"

M.lsp = {
capabilities = lsp.capabilities,
on_attach = function(client, bufnr)
require("sqls").on_attach(client, bufnr)
end,
root_dir = function()
return vim.fn.getcwd()
end,
cmd = { "sqls" },
}

return M
3 changes: 2 additions & 1 deletion lua/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ map("n", "[q", "<Cmd>tabp<CR>", cmd_options)

map("n", "<Leader>z", "", cmd_option(goto_preview.goto_preview_definition))

map("n", "<Leader>v", "", cmd_option(require("rest-nvim").run))
map("n", "<M-r>", "", cmd_option(utils_core.rest))

map("n", "<M-s>", "", cmd_option(utils_core.sql))
4 changes: 1 addition & 3 deletions lua/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ option.scrolloff = 18
option.termguicolors = true
option.shortmess = "atOIc"
-- option.completeopt = 'menuone,noselect'
-- option.shortmess:append({ c = true, F = true, T = true })
option.clipboard:append({ "unnamedplus" })
option.fillchars = "eob: "
option.cmdheight = 0
option.splitbelow = true

-- NOTE: Local to window
option.number = true
Expand All @@ -25,8 +25,6 @@ option.list = true
option.listchars = "tab:\\ ,trail:-,eol:↵"
option.foldmethod = "expr"
option.foldexpr = "nvim_treesitter#foldexpr()"
-- HACK: indent-blankline https://github.com/lukas-reineke/indent-blankline.nvim/issues/59#issuecomment-806398054
option.colorcolumn = "99999"

-- NOTE: Local to buffer
option.shiftwidth = 4
Expand Down
Loading

0 comments on commit c2f87ef

Please sign in to comment.